Class: ActiveMerchant::Billing::BeanstreamGateway
- Includes:
- BeanstreamCore
- Defined in:
- lib/active_merchant/billing/gateways/beanstream.rb
Overview
This class implements the Canadian Beanstream payment gateway. It is also named TD Canada Trust Online Mart payment gateway. To learn more about the specification of Beanstream gateway, please read the OM_Direct_Interface_API.pdf, which you can get from your Beanstream account or get from me by email.
Supported transaction types by Beanstream:
-
P
- Purchase -
PA
- Pre Authorization -
PAC
- Pre Authorization Completion
Secure Payment Profiles:
BeanStream supports payment profiles (vaults). This allows you to store cc information with BeanStream and process subsequent transactions with a customer id. Secure Payment Profiles must be enabled on your account (must be done over the phone). Your API Access Passcode must be set in Administration => account settings => order settings. To learn more about storing credit cards with the Beanstream gateway, please read the BEAN_Payment_Profiles.pdf (I had to phone BeanStream to request it.)
Notes
-
Adding of order products information is not implemented.
-
Ensure that country and province data is provided as a code such as “CA”, “US”, “QC”.
-
login is the Beanstream merchant ID, username and password should be enabled in your Beanstream account and passed in using the
:user
and:password
options. -
Test your app with your true merchant id and test credit card information provided in the api pdf document.
-
Beanstream does not allow Payment Profiles to be deleted with their API. The accounts are ‘closed’, but have to be deleted manually.
Example authorization (Beanstream PA transaction type):
twenty = 2000
gateway = BeanstreamGateway.new(
:login => '100200000',
:user => 'xiaobozz',
:password => 'password'
)
credit_card = CreditCard.new(
:number => '4030000010001234',
:month => 8,
:year => 2011,
:first_name => 'xiaobo',
:last_name => 'zzz',
:verification_value => 137
)
response = gateway.authorize(twenty, credit_card,
:order_id => '1234',
:billing_address => {
:name => 'xiaobo zzz',
:phone => '555-555-5555',
:address1 => '1234 Levesque St.',
:address2 => 'Apt B',
:city => 'Montreal',
:state => 'QC',
:country => 'CA',
:zip => 'H2C1X8'
},
:email => '[email protected]',
:subtotal => 800,
:shipping => 100,
:tax1 => 100,
:tax2 => 100,
:custom => 'reference one'
)
Constant Summary
Constants included from BeanstreamCore
ActiveMerchant::Billing::BeanstreamCore::AVS_CODES, ActiveMerchant::Billing::BeanstreamCore::CVD_CODES, ActiveMerchant::Billing::BeanstreamCore::PERIODICITIES, ActiveMerchant::Billing::BeanstreamCore::PERIODS, ActiveMerchant::Billing::BeanstreamCore::PROFILE_OPERATIONS, ActiveMerchant::Billing::BeanstreamCore::RECURRING_OPERATION, ActiveMerchant::Billing::BeanstreamCore::RECURRING_URL, ActiveMerchant::Billing::BeanstreamCore::SECURE_PROFILE_URL, ActiveMerchant::Billing::BeanstreamCore::SP_SERVICE_VERSION, ActiveMerchant::Billing::BeanstreamCore::TRANSACTIONS, ActiveMerchant::Billing::BeanstreamCore::URL
Constants inherited from Gateway
Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::CURRENCIES_WITHOUT_FRACTIONS, Gateway::DEBIT_CARDS
Instance Attribute Summary
Attributes inherited from Gateway
Instance Method Summary collapse
- #authorize(money, source, options = {}) ⇒ Object
- #cancel_recurring(options = {}) ⇒ Object
-
#delete(vault_id) ⇒ Object
(also: #unstore)
can’t actually delete a secure profile with the supplicaed API.
- #interac ⇒ Object
- #purchase(money, source, options = {}) ⇒ Object
- #recurring(money, source, options = {}) ⇒ Object
-
#store(credit_card, options = {}) ⇒ Object
To match the other stored-value gateways, like TrustCommerce, store and unstore need to be defined.
-
#update(vault_id, credit_card, options = {}) ⇒ Object
Update the values (such as CC expiration) stored at the gateway.
- #update_recurring(amount, source, options = {}) ⇒ Object
- #void(authorization, options = {}) ⇒ Object
Methods included from BeanstreamCore
#capture, #credit, included, #initialize, #refund
Methods inherited from Gateway
#card_brand, card_brand, inherited, #initialize, supports?, #test?
Methods included from CreditCardFormatting
Instance Method Details
#authorize(money, source, options = {}) ⇒ Object
67 68 69 70 71 72 73 74 75 |
# File 'lib/active_merchant/billing/gateways/beanstream.rb', line 67 def (money, source, = {}) post = {} add_amount(post, money) add_invoice(post, ) add_source(post, source) add_address(post, ) add_transaction_type(post, :authorization) commit(post) end |
#cancel_recurring(options = {}) ⇒ Object
119 120 121 122 123 124 |
# File 'lib/active_merchant/billing/gateways/beanstream.rb', line 119 def cancel_recurring( = {}) post = {} add_recurring_operation_type(post, :cancel) add_recurring_service(post, ) recurring_commit(post) end |
#delete(vault_id) ⇒ Object Also known as: unstore
can’t actually delete a secure profile with the supplicaed API. This function sets the status of the profile to closed ©. Closed profiles will have to removed manually.
142 143 144 |
# File 'lib/active_merchant/billing/gateways/beanstream.rb', line 142 def delete(vault_id) update(vault_id, false, {:status => "C"}) end |
#interac ⇒ Object
126 127 128 |
# File 'lib/active_merchant/billing/gateways/beanstream.rb', line 126 def interac @interac ||= BeanstreamInteracGateway.new(@options) end |
#purchase(money, source, options = {}) ⇒ Object
77 78 79 80 81 82 83 84 85 |
# File 'lib/active_merchant/billing/gateways/beanstream.rb', line 77 def purchase(money, source, = {}) post = {} add_amount(post, money) add_invoice(post, ) add_source(post, source) add_address(post, ) add_transaction_type(post, purchase_action(source)) commit(post) end |
#recurring(money, source, options = {}) ⇒ Object
97 98 99 100 101 102 103 104 105 106 |
# File 'lib/active_merchant/billing/gateways/beanstream.rb', line 97 def recurring(money, source, = {}) post = {} add_amount(post, money) add_invoice(post, ) add_credit_card(post, source) add_address(post, ) add_transaction_type(post, purchase_action(source)) add_recurring_type(post, ) commit(post) end |
#store(credit_card, options = {}) ⇒ Object
To match the other stored-value gateways, like TrustCommerce, store and unstore need to be defined
132 133 134 135 136 137 138 |
# File 'lib/active_merchant/billing/gateways/beanstream.rb', line 132 def store(credit_card, = {}) post = {} add_address(post, ) add_credit_card(post, credit_card) add_secure_profile_variables(post,) commit(post, true) end |
#update(vault_id, credit_card, options = {}) ⇒ Object
Update the values (such as CC expiration) stored at the gateway. The CC number must be supplied in the CreditCard object.
151 152 153 154 155 156 157 158 |
# File 'lib/active_merchant/billing/gateways/beanstream.rb', line 151 def update(vault_id, credit_card, = {}) post = {} add_address(post, ) add_credit_card(post, credit_card) .merge!({:vault_id => vault_id, :operation => secure_profile_action(:modify)}) add_secure_profile_variables(post,) commit(post, true) end |
#update_recurring(amount, source, options = {}) ⇒ Object
108 109 110 111 112 113 114 115 116 117 |
# File 'lib/active_merchant/billing/gateways/beanstream.rb', line 108 def update_recurring(amount, source, = {}) post = {} add_recurring_amount(post, amount) add_recurring_invoice(post, ) add_credit_card(post, source) add_address(post, ) add_recurring_operation_type(post, :update) add_recurring_service(post, ) recurring_commit(post) end |
#void(authorization, options = {}) ⇒ Object
87 88 89 90 91 92 93 94 95 |
# File 'lib/active_merchant/billing/gateways/beanstream.rb', line 87 def void(, = {}) reference, amount, type = split_auth() post = {} add_reference(post, reference) add_original_amount(post, amount) add_transaction_type(post, void_action(type)) commit(post) end |