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)
- FIELD_MAP =
{ 'TRANS_ID' => :transaction_id, 'STATUS' => :response_code, 'AVS' => :avs_result_code, 'CVV2'=> :card_code, 'AUTH_CODE' => :authorization, 'MESSAGE' => :message, 'REBID' => :rebid, 'TRANS_TYPE' => :trans_type, 'PAYMENT_ACCOUNT_MASK' => :acct_mask, 'CARD_TYPE' => :card_type, }
- REBILL_FIELD_MAP =
{ 'REBILL_ID' => :rebill_id, 'ACCOUNT_ID'=> :account_id, 'USER_ID' => :user_id, 'TEMPLATE_ID' => :template_id, 'STATUS' => :status, 'CREATION_DATE' => :creation_date, 'NEXT_DATE' => :next_date, 'LAST_DATE' => :last_date, 'SCHED_EXPR' => :schedule, 'CYCLES_REMAIN' => :cycles_remain, 'REB_AMOUNT' => :rebill_amount, 'NEXT_AMOUNT' => :next_amount, 'USUAL_DATE' => :undoc_usual_date, # Not found in the bp20rebadmin API doc. }
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, payment_object, 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, identification, 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
62 63 64 65 |
# File 'lib/active_merchant/billing/gateways/blue_pay.rb', line 62 def initialize( = {}) requires!(, :login, :password) 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.
78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/active_merchant/billing/gateways/blue_pay.rb', line 78 def (money, payment_object, = {}) post = {} add_payment_method(post, payment_object) add_invoice(post, ) add_address(post, ) add_customer_data(post, ) add_rebill(post, ) if [:rebill] add_duplicate_override(post, ) 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)
284 285 286 287 288 289 290 291 |
# File 'lib/active_merchant/billing/gateways/blue_pay.rb', line 284 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.
120 121 122 123 124 125 126 127 |
# File 'lib/active_merchant/billing/gateways/blue_pay.rb', line 120 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, payment_object, options = {}) ⇒ Object
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/active_merchant/billing/gateways/blue_pay.rb', line 175 def credit(money, payment_object, = {}) if(payment_object && payment_object.kind_of?(String)) deprecated "credit should only be used to credit a payment method" return refund(money, payment_object, ) end post = {} post[:PAYMENT_ACCOUNT] = '' add_payment_method(post, payment_object) post[:TRANS_TYPE] = 'CREDIT' post[:NAME1] = ([:first_name] ? [:first_name] : "") 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 |
#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.,
101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/active_merchant/billing/gateways/blue_pay.rb', line 101 def purchase(money, payment_object, = {}) post = {} add_payment_method(post, payment_object) add_invoice(post, ) add_address(post, ) add_customer_data(post, ) add_rebill(post, ) if [:rebill] add_duplicate_override(post, ) 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.
226 227 228 229 230 231 232 233 234 |
# File 'lib/active_merchant/billing/gateways/blue_pay.rb', line 226 def recurring(money, payment_object, = {}) requires!(, :rebill_start_date, :rebill_expression) [:rebill] = true if money purchase(money, payment_object, ) else (money, payment_object, ) end end |
#refund(money, identification, 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.
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/active_merchant/billing/gateways/blue_pay.rb', line 156 def refund(money, identification, = {}) if(identification && !identification.kind_of?(String)) deprecated "refund should only be used to refund a referenced transaction" return credit(money, identification, ) end post = {} post[:PAYMENT_ACCOUNT] = '' post[:MASTER_ID] = identification post[:TRANS_TYPE] = 'REFUND' post[:NAME1] = ([:first_name] ? [:first_name] : "") 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)
243 244 245 246 247 248 249 |
# File 'lib/active_merchant/billing/gateways/blue_pay.rb', line 243 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.
264 265 266 267 268 269 270 271 272 273 274 275 |
# File 'lib/active_merchant/billing/gateways/blue_pay.rb', line 264 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] post[:NEXT_DATE] = [:rebill_next_date] post[:REB_EXPR] = [:rebill_expression] post[:REB_CYCLES] = [:rebill_cycles] post[:NEXT_AMOUNT] = [:rebill_next_amount] 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.
135 136 137 138 139 140 |
# File 'lib/active_merchant/billing/gateways/blue_pay.rb', line 135 def void(identification, = {}) post = {} post[:MASTER_ID] = identification post[:TRANS_TYPE] = 'VOID' commit('VOID', nil, post) end |