Class: Bitkassa::PaymentResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/bitkassa/payment_response.rb

Overview

A PaymentResponse represents the immediate response after requesting a payment. It can will parse the JSON and contain the information nessecary to determine the status of the payment request.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ PaymentResponse

Initialize a new payment response. Usually done by a PaymentRequest.

Attributes:

  • payment_id, Unique ID assigned to this payment by Bitkassa

  • payment_url, The Bitcoin payment URL which you can show (as link and/or QR) for the customer to pay from his wallet (if you’re hosting your own payment page)

  • address The Bitcoin address where the customer is supposed to send his payment.

  • amount, The amount in satoshis to be paid.

  • expire, Unix timestamp when the payment expires (typically 15 minutes after start)

  • error, Reason why the payment could not be initiated. Only set when payment errord.

  • success, Confirmation that the API call was processed successfull



38
39
40
41
42
43
# File 'lib/bitkassa/payment_response.rb', line 38

def initialize(attributes)
  attributes.each do |key, value|
    setter_method = "#{key}=".to_sym
    send(setter_method, value)
  end
end

Instance Attribute Details

#addressObject

Refer to Initialize for the description of all attributes.



8
9
10
# File 'lib/bitkassa/payment_response.rb', line 8

def address
  @address
end

#amountObject

Refer to Initialize for the description of all attributes.



8
9
10
# File 'lib/bitkassa/payment_response.rb', line 8

def amount
  @amount
end

#bitcoin_urlObject

Refer to Initialize for the description of all attributes.



8
9
10
# File 'lib/bitkassa/payment_response.rb', line 8

def bitcoin_url
  @bitcoin_url
end

#errorObject

Refer to Initialize for the description of all attributes.



8
9
10
# File 'lib/bitkassa/payment_response.rb', line 8

def error
  @error
end

#expireObject

Refer to Initialize for the description of all attributes.



8
9
10
# File 'lib/bitkassa/payment_response.rb', line 8

def expire
  @expire
end

#payment_idObject

Refer to Initialize for the description of all attributes.



8
9
10
# File 'lib/bitkassa/payment_response.rb', line 8

def payment_id
  @payment_id
end

#payment_urlObject

Refer to Initialize for the description of all attributes.



8
9
10
# File 'lib/bitkassa/payment_response.rb', line 8

def payment_url
  @payment_url
end

#successObject

Refer to Initialize for the description of all attributes.



8
9
10
# File 'lib/bitkassa/payment_response.rb', line 8

def success
  @success
end

Class Method Details

.from_json(json) ⇒ Object

Generate a PaymentResponse from a JSON payload.



18
19
20
# File 'lib/bitkassa/payment_response.rb', line 18

def self.from_json(json)
  new(JSON.parse(json))
end