Class: ActiveMerchant::Billing::BluePayGateway
- Defined in:
- lib/active_merchant/billing/gateways/blue_pay.rb
Constant Summary collapse
- CARD_CODE_ERRORS =
%w( N S )
- AVS_ERRORS =
%w( A E N R W Z )
- AVS_REASON_CODES =
%w(27 45)
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, payment_object, options = {}) ⇒ Object
Performs an authorization, which reserves the funds on the customer’s credit card.
-
#cancel_recurring(rebill_id) ⇒ Object
Cancel a recurring payment.
-
#capture(money, identification, options = {}) ⇒ Object
Captures the funds from an authorize transaction.
- #credit(money, identification, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ BluePayGateway
constructor
Creates a new BluepayGateway.
-
#purchase(money, payment_object, options = {}) ⇒ Object
Perform a purchase, which is essentially an authorization and capture in a single operation.
-
#recurring(money, payment_object, options = {}) ⇒ Object
Options.
-
#refund(money, payment_object, options = {}) ⇒ Object
Performs a credit.
-
#status_recurring(rebill_id) ⇒ Object
View a recurring payment.
-
#update_recurring(options = {}) ⇒ Object
Update a recurring payment’s details.
-
#void(identification, options = {}) ⇒ Object
Void a previous transaction This is referred to a VOID transaction in BluePay.
Methods inherited from Gateway
#card_brand, card_brand, inherited, supports?, #test?
Methods included from CreditCardFormatting
Constructor Details
#initialize(options = {}) ⇒ BluePayGateway
Creates a new BluepayGateway
The gateway requires that a valid Account ID and Secret Key be passed in the options
hash.
Options
-
:account_id
– The BluePay gateway Account ID (REQUIRED) -
:secret_key
– The BluePay gateway Secret Key (REQUIRED) -
:test
– set to true for TEST mode or false for LIVE mode
39 40 41 42 43 |
# File 'lib/active_merchant/billing/gateways/blue_pay.rb', line 39 def initialize( = {}) requires!(, :login, :password) @options = super end |
Instance Method Details
#authorize(money, payment_object, options = {}) ⇒ Object
Performs an authorization, which reserves the funds on the customer’s credit card. This does not actually take funds from the customer This is referred to an AUTH transaction in BluePay
Parameters
-
money
– The amount to be authorized as an Integer value in cents. -
payment_object
– This can either be one of three things: A CreditCard object, A Check object, or a token. The token is called the Master ID. This is a unique transaction ID returned from a previous transaction. This token associates all the stored information for a previous transaction. -
options
– A hash of optional parameters.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/active_merchant/billing/gateways/blue_pay.rb', line 56 def (money, payment_object, = {}) post = {} post[:MASTER_ID] = '' if payment_object != nil && payment_object.class() != String payment_object.class() == ActiveMerchant::Billing::Check ? add_check(post, payment_object) : add_creditcard(post, payment_object) else post[:MASTER_ID] = payment_object end add_invoice(post, ) add_address(post, ) add_customer_data(post, ) if [:rebill] != nil post[:DO_REBILL] = '1' post[:REB_AMOUNT] = amount([:rebill_amount]) post[:REB_FIRST_DATE] = [:rebill_start_date] post[:REB_EXPR] = [:rebill_expression] post[:REB_CYCLES] = [:rebill_cycles] end post[:TRANS_TYPE] = 'AUTH' commit('AUTH_ONLY', money, post) end |
#cancel_recurring(rebill_id) ⇒ Object
Cancel a recurring payment.
This transaction cancels an existing recurring billing.
Parameters
-
rebill_id
– A string containing the rebill_id of the recurring billing that you wish to cancel/stop (REQUIRED)
271 272 273 274 275 276 277 278 |
# File 'lib/active_merchant/billing/gateways/blue_pay.rb', line 271 def cancel_recurring(rebill_id) post = {} requires!(rebill_id) post[:REBILL_ID] = rebill_id post[:TRANS_TYPE] = 'SET' post[:STATUS] = 'stopped' commit('rebill', 'nil', post) end |
#capture(money, identification, options = {}) ⇒ Object
Captures the funds from an authorize transaction. This is referred to a CAPTURE transaction in BluePay
Parameters
-
money
– The amount to be captured as an Integer value in cents. -
identification
– The Master ID, or token, returned from the previous authorize transaction.
122 123 124 125 126 127 128 129 |
# File 'lib/active_merchant/billing/gateways/blue_pay.rb', line 122 def capture(money, identification, = {}) post = {} add_address(post, ) add_customer_data(post, ) post[:MASTER_ID] = identification post[:TRANS_TYPE] = 'CAPTURE' commit('PRIOR_AUTH_CAPTURE', money, post) end |
#credit(money, identification, options = {}) ⇒ Object
180 181 182 183 |
# File 'lib/active_merchant/billing/gateways/blue_pay.rb', line 180 def credit(money, identification, = {}) deprecated CREDIT_DEPRECATION_MESSAGE refund(money, identification, ) end |
#purchase(money, payment_object, options = {}) ⇒ Object
Perform a purchase, which is essentially an authorization and capture in a single operation. This is referred to a SALE transaction in BluePay
Parameters
-
money
– The amount to be purchased as an Integer value in cents. -
payment_object
– This can either be one of three things: A CreditCard object, A Check object, or a token. The token is called the Master ID. This is a unique transaction ID returned from a previous transaction. This token associates all the stored information for a previous transaction. -
options
– A hash of optional parameters.,
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/active_merchant/billing/gateways/blue_pay.rb', line 91 def purchase(money, payment_object, = {}) post = {} post[:MASTER_ID] = '' if payment_object != nil && payment_object.class() != String payment_object.class() == ActiveMerchant::Billing::Check ? add_check(post, payment_object) : add_creditcard(post, payment_object) else post[:MASTER_ID] = payment_object end add_invoice(post, ) add_address(post, ) add_customer_data(post, ) if [:rebill] != nil post[:DO_REBILL] = '1' post[:REB_AMOUNT] = amount([:rebill_amount]) post[:REB_FIRST_DATE] = [:rebill_start_date] post[:REB_EXPR] = [:rebill_expression] post[:REB_CYCLES] = [:rebill_cycles] end post[:TRANS_TYPE] = 'SALE' commit('AUTH_CAPTURE', money, post) end |
#recurring(money, payment_object, options = {}) ⇒ Object
Options
-
:rebill_start_date
is a string that tells the gateway when to start the rebill. (REQUIRED) Has two valid formats: “YYYY-MM-DD HH:MM:SS” Hours, minutes, and seconds are optional. “XX UNITS” Relative date as explained below. Marked from the time of the transaction (i.e.: 10 DAYS, 1 MONTH, 1 YEAR) -
:rebill_expression
is the period of time in-between rebillings. (REQUIRED) It uses the same “XX UNITS” format as rebill_start_date, explained above. Optional parameters include: -
rebill_cycles
: Number of times to rebill. Don’t send or set to nil for infinite rebillings (or until canceled). -
rebill_amount
: Amount to rebill. Defaults to amount of transaction for rebillings.For example, to charge the customer $19.95 now and then charge $39.95 in 60 days every 3 months for 5 times, the options hash would be as follows: :rebill_start_date => ‘60 DAYS’, :rebill_expression => ‘3 MONTHS’, :rebill_cycles => ‘5’, :rebill_amount => ‘39.95’ A money object of 1995 cents would be passed into the ‘money’ parameter.
216 217 218 219 220 221 |
# File 'lib/active_merchant/billing/gateways/blue_pay.rb', line 216 def recurring(money, payment_object, = {}) requires!(, :rebill_start_date, :rebill_expression) [:rebill] = '1' money == nil ? (money, payment_object, ) : purchase(money, payment_object, ) end |
#refund(money, payment_object, options = {}) ⇒ Object
Performs a credit.
This transaction indicates that money should flow from the merchant to the customer.
Parameters
-
money
– The amount to be credited to the customer as an Integer value in cents. -
payment_object
– This can either be one of three things: A CreditCard object, A Check object, or a token. The token is called the Master ID. This is a unique transaction ID returned from a previous transaction. This token associates all the stored information for a previous transaction. If the payment_object is a token, then the transaction type will reverse a previous capture or purchase transaction, returning the funds to the customer. If the amount is nil, a full credit will be processed. This is referred to a REFUND transaction in BluePay. If the payment_object is either a CreditCard or Check object, then the transaction type will be an unmatched credit placing funds in the specified account. This is referred to a CREDIT transaction in BluePay. -
options
– A hash of parameters.
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/active_merchant/billing/gateways/blue_pay.rb', line 158 def refund(money, payment_object, = {}) post = {} post[:PAYMENT_ACCOUNT] = '' if payment_object != nil && payment_object.class() != String payment_object.class() == ActiveMerchant::Billing::Check ? add_check(post, payment_object) : add_creditcard(post, payment_object) post[:TRANS_TYPE] = 'CREDIT' else post[:MASTER_ID] = payment_object post[:TRANS_TYPE] = 'REFUND' end [:first_name] ? post[:NAME1] = [:first_name] : post[:NAME1] = '' post[:NAME2] = [:last_name] if [:last_name] post[:ZIP] = [:zip] if [:zip] add_invoice(post, ) add_address(post, ) add_customer_data(post, ) commit('CREDIT', money, post) end |
#status_recurring(rebill_id) ⇒ Object
View a recurring payment
This will pull data associated with a current recurring billing
Parameters
-
rebill_id
– A string containing the rebill_id of the recurring billing that is already active (REQUIRED)
230 231 232 233 234 235 236 |
# File 'lib/active_merchant/billing/gateways/blue_pay.rb', line 230 def status_recurring(rebill_id) post = {} requires!(rebill_id) post[:REBILL_ID] = rebill_id post[:TRANS_TYPE] = 'GET' commit('rebill', 'nil', post) end |
#update_recurring(options = {}) ⇒ Object
Update a recurring payment’s details.
This transaction updates an existing recurring billing
Options
-
:rebill_id
– The 12 digit rebill ID used to update a particular rebilling cycle. (REQUIRED) -
:rebill_amount
– A string containing the new rebilling amount. -
:rebill_next_date
– A string containing the new rebilling next date. -
:rebill_expression
– A string containing the new rebilling expression. -
:rebill_cycles
– A string containing the new rebilling cycles. -
:rebill_next_amount
– A string containing the next rebilling amount to charge the customer. This ONLY affects the next scheduled charge; all other rebillings will continue at the regular (rebill_amount) amount. Take a look above at the recurring_payment method for similar examples on how to use.
251 252 253 254 255 256 257 258 259 260 261 262 |
# File 'lib/active_merchant/billing/gateways/blue_pay.rb', line 251 def update_recurring( = {}) post = {} requires!(, :rebill_id) post[:REBILL_ID] = [:rebill_id] post[:TRANS_TYPE] = 'SET' post[:REB_AMOUNT] = amount([:rebill_amount]) if ![:rebill_amount].nil? post[:NEXT_DATE] = [:rebill_next_date] if ![:rebill_next_date].nil? post[:REB_EXPR] = [:rebill_expression] if ![:rebill_expression].nil? post[:REB_CYCLES] = [:rebill_cycles] if ![:rebill_cycles].nil? post[:NEXT_AMOUNT] = [:rebill_next_amount] if ![:rebill_next_amount].nil? commit('rebill', 'nil', post) end |
#void(identification, options = {}) ⇒ Object
Void a previous transaction This is referred to a VOID transaction in BluePay
Parameters
-
identification
- The Master ID, or token, returned from a previous authorize transaction.
137 138 139 140 141 142 |
# File 'lib/active_merchant/billing/gateways/blue_pay.rb', line 137 def void(identification, = {}) post = {} post[:MASTER_ID] = identification post[:TRANS_TYPE] = 'VOID' commit('VOID', nil, post) end |