Class: ActiveMerchant::Billing::BraintreeGateway
- Defined in:
- lib/active_merchant/billing/gateways/braintree.rb
Constant Summary collapse
- URL =
'https://secure.braintreepaymentgateway.com/api/transact.php'
Constants inherited from Gateway
Constants included from PostsData
PostsData::MAX_RETRIES, PostsData::OPEN_TIMEOUT, PostsData::READ_TIMEOUT
Instance Attribute Summary
Attributes inherited from Gateway
Instance Method Summary collapse
-
#authorize(money, creditcard, options = {}) ⇒ Object
Pass :store => true in the options to store the payment info at BrainTree and get a generated customer_vault_id in the response.
- #capture(money, authorization, options = {}) ⇒ Object
- #delete(vault_id) ⇒ Object
-
#initialize(options = {}) ⇒ BraintreeGateway
constructor
A new instance of BraintreeGateway.
- #purchase(money, payment_source, options = {}) ⇒ Object
-
#update(vault_id, creditcard, options = {}) ⇒ Object
Update the values (such as CC expiration) stored at BrainTree.
- #void(authorization, options = {}) ⇒ Object
Methods inherited from Gateway
Methods included from Utils
Methods included from CreditCardFormatting
Methods included from RequiresParameters
Methods included from PostsData
included, #retry_exceptions, #ssl_post
Constructor Details
#initialize(options = {}) ⇒ BraintreeGateway
Returns a new instance of BraintreeGateway.
13 14 15 16 17 |
# File 'lib/active_merchant/billing/gateways/braintree.rb', line 13 def initialize( = {}) requires!(, :login, :password) @options = super end |
Instance Method Details
#authorize(money, creditcard, options = {}) ⇒ Object
Pass :store => true in the options to store the payment info at BrainTree and get a generated customer_vault_id in the response.
Pass :store => some_number_or_string to specify the customer_vault_id BrainTree should use (make sure it’s unique).
25 26 27 28 29 30 31 32 33 |
# File 'lib/active_merchant/billing/gateways/braintree.rb', line 25 def (money, creditcard, = {}) post = {} add_invoice(post, ) add_payment_source(post, creditcard,) add_address(post, creditcard, ) add_customer_data(post, ) commit('auth', money, post) end |
#capture(money, authorization, options = {}) ⇒ Object
45 46 47 48 49 |
# File 'lib/active_merchant/billing/gateways/braintree.rb', line 45 def capture(money, , = {}) post ={} post[:transactionid] = commit('capture', money, post) end |
#delete(vault_id) ⇒ Object
71 72 73 74 75 76 |
# File 'lib/active_merchant/billing/gateways/braintree.rb', line 71 def delete(vault_id) post = {} post[:customer_vault] = "delete_customer" add_customer_vault_id(post, vault_id) commit(nil, nil, post) end |
#purchase(money, payment_source, options = {}) ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/active_merchant/billing/gateways/braintree.rb', line 35 def purchase(money, payment_source, = {}) post = {} add_invoice(post, ) add_payment_source(post, payment_source, ) add_address(post, payment_source, ) add_customer_data(post, ) commit('sale', money, post) end |
#update(vault_id, creditcard, options = {}) ⇒ Object
Update the values (such as CC expiration) stored at BrainTree. The CC number must be supplied in the CreditCard object.
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/active_merchant/billing/gateways/braintree.rb', line 60 def update(vault_id, creditcard, = {}) post = {} post[:customer_vault] = "update_customer" add_customer_vault_id(post, vault_id) add_creditcard(post, creditcard, ) add_address(post, creditcard, ) add_customer_data(post, ) commit(nil, nil, post) end |
#void(authorization, options = {}) ⇒ Object
51 52 53 54 55 |
# File 'lib/active_merchant/billing/gateways/braintree.rb', line 51 def void(, = {}) post ={} post[:transactionid] = commit('void', nil, post) end |