Class: MerbMerchant::Billing::BraintreeGateway
- Defined in:
- lib/merb_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, payment_source, 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 (also: #unstore)
-
#initialize(options = {}) ⇒ BraintreeGateway
constructor
A new instance of BraintreeGateway.
- #purchase(money, payment_source, options = {}) ⇒ Object
-
#store(payment_source, options = {}) ⇒ Object
To match the other stored-value gateways, like TrustCommerce, store and unstore need to be defined.
-
#update(vault_id, creditcard, options = {}) ⇒ Object
Update the values (such as CC expiration) stored at BrainTree.
- #void(authorization, options = {}) ⇒ Object
Methods inherited from Gateway
#card_brand, card_brand, inherited, supports?, #test?
Methods included from Utils
Methods included from CreditCardFormatting
Methods included from RequiresParameters
Methods included from PostsData
Constructor Details
#initialize(options = {}) ⇒ BraintreeGateway
Returns a new instance of BraintreeGateway.
13 14 15 16 17 |
# File 'lib/merb_merchant/billing/gateways/braintree.rb', line 13 def initialize( = {}) requires!(, :login, :password) @options = super end |
Instance Method Details
#authorize(money, payment_source, 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/merb_merchant/billing/gateways/braintree.rb', line 25 def (money, payment_source, = {}) post = {} add_invoice(post, ) add_payment_source(post, payment_source, ) add_address(post, payment_source, ) add_customer_data(post, ) commit('auth', money, post) end |
#capture(money, authorization, options = {}) ⇒ Object
45 46 47 48 49 |
# File 'lib/merb_merchant/billing/gateways/braintree.rb', line 45 def capture(money, , = {}) post ={} post[:transactionid] = commit('capture', money, post) end |
#delete(vault_id) ⇒ Object Also known as: unstore
71 72 73 74 75 76 |
# File 'lib/merb_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/merb_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 |
#store(payment_source, options = {}) ⇒ Object
To match the other stored-value gateways, like TrustCommerce, store and unstore need to be defined
80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/merb_merchant/billing/gateways/braintree.rb', line 80 def store(payment_source, = {}) billing_id = .delete(:billing_id).to_s || true post = {} post[:customer_vault] = 'add_customer' if billing_id post[:customer_vault_id] = billing_id end add_payment_source(post, payment_source, ) add_address(post, payment_source, ) add_customer_data(post, ) commit(nil,nil, 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/merb_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/merb_merchant/billing/gateways/braintree.rb', line 51 def void(, = {}) post ={} post[:transactionid] = commit('void', nil, post) end |