Class: Bambora::V1::PaymentResource
- Inherits:
-
Object
- Object
- Bambora::V1::PaymentResource
- Defined in:
- lib/bambora/v1/payment_resource.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#sub_path ⇒ Object
readonly
Returns the value of attribute sub_path.
Instance Method Summary collapse
-
#create(payment_data) ⇒ Hash
(also: #make_payment)
Make a payment with a credit card.
-
#create_with_payment_profile(customer_code:, amount:, card_id: 1, complete: false) ⇒ Hash
(also: #make_payment_with_payment_profile)
Make a payment with a credit card.
-
#get(transaction_id:) ⇒ Hash
Retrieve the details of a previously attempted payment.
-
#initialize(client:, api_key:) ⇒ PaymentResource
constructor
A new instance of PaymentResource.
Constructor Details
#initialize(client:, api_key:) ⇒ PaymentResource
Returns a new instance of PaymentResource.
8 9 10 11 12 |
# File 'lib/bambora/v1/payment_resource.rb', line 8 def initialize(client:, api_key:) @client = client @api_key = api_key @sub_path = '/v1/payments' end |
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
6 7 8 |
# File 'lib/bambora/v1/payment_resource.rb', line 6 def api_key @api_key end |
#client ⇒ Object (readonly)
Returns the value of attribute client.
6 7 8 |
# File 'lib/bambora/v1/payment_resource.rb', line 6 def client @client end |
#sub_path ⇒ Object (readonly)
Returns the value of attribute sub_path.
6 7 8 |
# File 'lib/bambora/v1/payment_resource.rb', line 6 def sub_path @sub_path end |
Instance Method Details
#create(payment_data) ⇒ Hash Also known as: make_payment
Make a payment with a credit card. Also aliased as make_payment
.
42 43 44 |
# File 'lib/bambora/v1/payment_resource.rb', line 42 def create(payment_data) client.post(path: sub_path, body: payment_data, api_key: api_key) end |
#create_with_payment_profile(customer_code:, amount:, card_id: 1, complete: false) ⇒ Hash Also known as: make_payment_with_payment_profile
Make a payment with a credit card. Aliased as make_payment_with_payment_profile
.
67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/bambora/v1/payment_resource.rb', line 67 def create_with_payment_profile(customer_code:, amount:, card_id: 1, complete: false) create( amount: amount, payment_method: 'payment_profile', payment_profile: { customer_code: customer_code, card_id: card_id, complete: complete, }, ) end |
#get(transaction_id:) ⇒ Hash
Retrieve the details of a previously attempted payment.
93 94 95 |
# File 'lib/bambora/v1/payment_resource.rb', line 93 def get(transaction_id:) client.get(path: "#{sub_path}/#{transaction_id}", api_key: api_key) end |