Class: ActiveMerchant::Billing::PayArcGateway

Inherits:
Gateway
  • Object
show all
Defined in:
lib/active_merchant/billing/gateways/pay_arc.rb

Constant Summary collapse

STANDARD_ERROR_CODE_MAPPING =
{}
STANDARD_ACTIONS =
{
  token:
    { end_point: 'tokens',
      allowed_fields: %i[card_source card_number exp_month exp_year cvv card_holder_name
                         address_line1 address_line2 city state zip country] },
  capture:
    { end_point: 'charges',
      allowed_fields: %i[amount statement_description card_id currency customer_id token_id card_source tip_amount
                         card_level sales_tax purchase_order supplier_reference_number customer_ref_id ship_to_zip
                         amex_descriptor customer_vat_number summary_commodity_code shipping_charges duty_charges
                         ship_from_zip destination_country_code vat_invoice order_date tax_category tax_type
                         tax_amount tax_rate address_line1 zip terminal_id surcharge description email receipt_phone statement_descriptor ] },
  void:
    { end_point: 'charges/{{chargeID}}/void',
      allowed_fields: %i[reason void_description] },
  refund:
    { end_point: 'charges/{{charge_id}}/refunds',
      allowed_fields: %i[amount reason description] },
  credit:
    { end_point: 'refunds/wo_reference',
      allowed_fields: %i[amount charge_description statement_description terminal_id card_source card_number
                         exp_month exp_year cvv card_holder_name address_line1 address_line2 city state zip
                         country currency reason receipt_phone receipt_email  ] }
}
SUCCESS_STATUS =
%w[
  submitted_for_settlement authorized partially_submitted_for_settlement
  credit partial_refund void refunded settled
]
FAILURE_STATUS =
%w[not_processed failed_by_gateway invalid_track_data authorization_expired]

Constants inherited from Gateway

Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::RECURRING_DEPRECATION_MESSAGE, Gateway::STANDARD_ERROR_CODE

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

Methods inherited from Gateway

#add_field_to_post_if_present, #add_fields_to_post_if_present, #card_brand, card_brand, #generate_unique_id, inherited, #supported_countries, supported_countries, supported_countries=, supports?, #supports_network_tokenization?, #test?

Methods included from CreditCardFormatting

#expdate, #format

Methods included from PostsData

included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request

Constructor Details

#initialize(options = {}) ⇒ PayArcGateway

The gateway must be configured with Bearer token.

:api_key PAYARC’s Bearer token must be passsed to initialise the gateway.



51
52
53
54
# File 'lib/active_merchant/billing/gateways/pay_arc.rb', line 51

def initialize(options = {})
  requires!(options, :api_key)
  super
end

Instance Method Details

#authorize(money, creditcard, options = {}) ⇒ Object

Authorize the payment API through PAYARC.

:money A positive integer in cents representing how much to charge. The minimum amount is 50c USD.

:creditcard CreditCard object with card details.

:options Other information like address, card source etc can be passed in options

Options

  • :card_source – Source of payment (REQUIRED) ( INTERNET, SWIPE, PHONE, MAIL, MANUAL )

  • :currency – Three-letter ISO currency code, in lowercase (REQUIRED)

  • :card_holder_name –Name of the Card Holder (OPTIONAL)

  • :address_line1 – Set in payment method’s billing address (OPTIONAL)

  • :address_line2 – Set in payment method’s billing address (OPTIONAL)

  • :state – State (OPTIONAL)

  • :country – Country (OPTIONAL)

  • :statement_description – An arbitrary string to be displayed on your costomer’s credit card statement. This may be up to 22 characters. (OPTIONAL)

  • :card_level – Commercial card level - “LEVEL2” OR “LEVEL3” (OPTIONAL)

  • :sales_tax – A positive integer in cents representing sales tax. (OPTIONAL)

  • :terminal_id – Optional terminal id. (OPTIONAL)

  • :tip_amount – A positive integer in cents representing tip amount. (OPTIONAL)

  • :sales_tax – Applicable for LEVEL2 or LEVEL3 Charge. A positive integer in cents representing sales tax. (REQUIRED for LEVEL2 0r LEVEL3)

  • :purchase_order – Applicable for Level2 or Level3 Charge. The value used by the customer to identify an order. Issued by the buyer to the seller. (REQUIRED for LEVEL2 0r LEVEL3)

  • :order_date – Applicable for Level2 Charge for AMEX card only or Level3 Charge. The date the order was processed. Format: Alphanumeric and Special Character |Min Length=0 Max Length=10|Allowed format: MM/DD/YYYY For example: 12/01/2016

  • :customer_ref_id – Applicable for Level2 Charge for AMEX card only or Level3 Charge. The reference identifier supplied by the Commercial Card cardholder. Format: Alphanumeric and Special Character |Min Length=0 Max Length=17| a-z A-Z 0-9 Space <>

  • :ship_to_zip – Applicable for Level2 Charge for AMEX card only or Level3 Charge. The postal code for the address to which the goods are being shipped. Format: Alphanumeric |Min Length=2 Max Length=10

  • :amex_descriptor – Applicable for Level2 Charge for AMEX card only. The value of the Transaction Advice Addendum field, displays descriptive information about a transactions on a customer’s AMEX card statement. Format: Alphanumeric and Special Character |Min Length=0 Max Length=40|a-z A-Z 0-9 Space <>

  • :supplier_reference_number – Applicable for Level2 Charge for AMEX card only or Level3 charge. The value used by the customer to identify an order. Issued by the buyer to the seller.

  • :tax_amount – Applicable for Level3 Charge. The tax amount. Format: Numeric|Max Length=12|Allowed characters: 0-9 .(dot) Note: If a decimal point is included, the amount reflects a dollar value. If a decimal point is not included, the amount reflects a cent value.

  • :tax_category – Applicable for Level3 Charge. The type of tax. Formerly established through TaxCategory messages. Allowed values: SERVICE, DUTY, VAT, ALTERNATE, NATIONAL, TAX_EXEMPT

  • :customer_vat_number – Applicable for Level3 Charge. Indicates the customer’s government assigned tax identification number or the identification number assigned to their purchasing company by the tax authorities. Format: Alphanumeric and Special Character|Min Length=0 Max Length=13| a-z A-Z 0-9 Space <>

  • :summary_commodity_code – Applicable for Level3 Charge. The international description code of the overall goods or services being supplied. Format: Alphanumeric and Special Character |Min Length=0 Max Length=4|Allowed character: a-z A-Z 0-9 Space <>

  • :shipping_charges – Applicable for Level3 Charge. The dollar amount for shipping or freight charges applied to a product or transaction. Format: Numeric |Max Length=12|Allowed characters: 0-9 .(dot) Note: If a decimal point is included, the amount reflects a dollar value. If a decimal point is not included, the amount reflects a cent value.

  • :duty_charges – Applicable for Level3 Charge. Indicates the total charges for any import or export duties included in the order. Format: Numeric |Max Length=12|Allowed characters: 0-9 . (dot) Note: If a decimal point is included, the amount reflects a dollar value. If a decimal point is not included, the amount reflects a cent value.

  • :ship_from_zip – Applicable for Level3 Charge. The postal code for the address to which the goods are being shipped. Format: Alphanumeric |Min Length=2 Max Length=10

  • :destination_country_code – Applicable for Level3 Charge. The destination country code indicator. Format: Alphanumeric.

  • :tax_type – Applicable for Level3 Charge. The type of tax. For example, VAT, NATIONAL, Service Tax. Format: Alphanumeric and Special Character

  • :vat_invoice – Applicable for Level3 Charge. The Value Added Tax (VAT) invoice number associated with the transaction. Format: Alphanumeric and Special Character |Min Length=0 Max Length=15|Allowed character: a-z A-Z 0-9 Space <>

  • :tax_rate – Applicable for Level3 Charge. The type of tax rate. This field is used if taxCategory is not used. Default sale tax rate in percentage Must be between 0.1% - 22% ,Applicable only Level 2 AutoFill. Format: Decimal Number |Max Length=4|Allowed characters: 0-9 .(dot) Allowed range: 0.01 - 100

  • :email – Customer’s email address.



150
151
152
153
154
155
156
# File 'lib/active_merchant/billing/gateways/pay_arc.rb', line 150

def authorize(money, creditcard, options = {})
  options[:capture] = '0'
  MultiResponse.run do |r|
    r.process { token(creditcard, options) }
    r.process { charge(money, r.authorization, options) }
  end
end

#capture(money, tx_reference, options = {}) ⇒ Object

Capture the payment of an existing, uncaptured, charge. This is the second half of the two-step payment flow, where first you created / authorized a charge with the capture option set to false.

:money A positive integer in cents representing how much to charge. The minimum amount is 50c USD.

:tx_reference charge_id from previously created / authorized a charge

:options Other information like address, card source etc can be passed in options



169
170
171
172
173
174
175
# File 'lib/active_merchant/billing/gateways/pay_arc.rb', line 169

def capture(money, tx_reference, options = {})
  post = {}
  add_money(post, money, options)
  action = "#{STANDARD_ACTIONS[:capture][:end_point]}/#{tx_reference}/capture"
  post = filter_gateway_fields(post, options, STANDARD_ACTIONS[:capture][:allowed_fields])
  commit(action, post)
end

#credit(money, creditcard, options = {}) ⇒ Object



213
214
215
216
217
218
219
220
221
222
223
# File 'lib/active_merchant/billing/gateways/pay_arc.rb', line 213

def credit(money, creditcard, options = {})
  post = {}
  add_money(post, money, options)
  add_creditcard(post, creditcard, options)
  add_address(post, options)
  add_phone(post, options)
  post['receipt_email'] = options[:email] if options[:email]
  action = STANDARD_ACTIONS[:credit][:end_point]
  post = filter_gateway_fields(post, options, STANDARD_ACTIONS[:credit][:allowed_fields])
  commit(action, post)
end

#purchase(money, creditcard, options = {}) ⇒ Object

Purchase API through PAYARC.

:money A positive integer in cents representing how much to charge. The minimum amount is 50c USD.

:creditcard CreditCard object with card details.

:options Other information like address, card source etc can be passed in options

Options

  • :card_source – Source of payment (REQUIRED) ( INTERNET, SWIPE, PHONE, MAIL, MANUAL )

  • :currency – Three-letter ISO currency code, in lowercase (REQUIRED)

  • :card_holder_name –Name of the Card Holder (OPTIONAL)

  • :address_line1 – Set in payment method’s billing address (OPTIONAL)

  • :address_line2 – Set in payment method’s billing address (OPTIONAL)

  • :state – State (OPTIONAL)

  • :country – Country (OPTIONAL)

  • :statement_description – An arbitrary string to be displayed on your costomer’s credit card statement. This may be up to 22 characters. (OPTIONAL)

  • :card_level – Commercial card level - “LEVEL2” OR “LEVEL3” (OPTIONAL)

  • :sales_tax – A positive integer in cents representing sales tax. (OPTIONAL)

  • :terminal_id – Optional terminal id. (OPTIONAL)

  • :tip_amount – A positive integer in cents representing tip amount. (OPTIONAL)

  • :sales_tax – Applicable for LEVEL2 or LEVEL3 Charge. A positive integer in cents representing sales tax. (REQUIRED for LEVEL2 0r LEVEL3)

  • :purchase_order – Applicable for Level2 or Level3 Charge. The value used by the customer to identify an order. Issued by the buyer to the seller. (REQUIRED for LEVEL2 0r LEVEL3)

  • :order_date – Applicable for Level2 Charge for AMEX card only or Level3 Charge. The date the order was processed. Format: Alphanumeric and Special Character |Min Length=0 Max Length=10|Allowed format: MM/DD/YYYY For example: 12/01/2016

  • :customer_ref_id – Applicable for Level2 Charge for AMEX card only or Level3 Charge. The reference identifier supplied by the Commercial Card cardholder. Format: Alphanumeric and Special Character |Min Length=0 Max Length=17| a-z A-Z 0-9 Space <>

  • :ship_to_zip – Applicable for Level2 Charge for AMEX card only or Level3 Charge. The postal code for the address to which the goods are being shipped. Format: Alphanumeric |Min Length=2 Max Length=10

  • :amex_descriptor – Applicable for Level2 Charge for AMEX card only. The value of the Transaction Advice Addendum field, displays descriptive information about a transactions on a customer’s AMEX card statement. Format: Alphanumeric and Special Character |Min Length=0 Max Length=40|a-z A-Z 0-9 Space <>

  • :supplier_reference_number – Applicable for Level2 Charge for AMEX card only or Level3 charge. The value used by the customer to identify an order. Issued by the buyer to the seller.

  • :tax_amount – Applicable for Level3 Charge. The tax amount. Format: Numeric|Max Length=12|Allowed characters: 0-9 .(dot) Note: If a decimal point is included, the amount reflects a dollar value. If a decimal point is not included, the amount reflects a cent value.

  • :tax_category – Applicable for Level3 Charge. The type of tax. Formerly established through TaxCategory messages. Allowed values: SERVICE, DUTY, VAT, ALTERNATE, NATIONAL, TAX_EXEMPT

  • :customer_vat_number – Applicable for Level3 Charge. Indicates the customer’s government assigned tax identification number or the identification number assigned to their purchasing company by the tax authorities. Format: Alphanumeric and Special Character|Min Length=0 Max Length=13| a-z A-Z 0-9 Space <>

  • :summary_commodity_code – Applicable for Level3 Charge. The international description code of the overall goods or services being supplied. Format: Alphanumeric and Special Character |Min Length=0 Max Length=4|Allowed character: a-z A-Z 0-9 Space <>

  • :shipping_charges – Applicable for Level3 Charge. The dollar amount for shipping or freight charges applied to a product or transaction. Format: Numeric |Max Length=12|Allowed characters: 0-9 .(dot) Note: If a decimal point is included, the amount reflects a dollar value. If a decimal point is not included, the amount reflects a cent value.

  • :duty_charges – Applicable for Level3 Charge. Indicates the total charges for any import or export duties included in the order. Format: Numeric |Max Length=12|Allowed characters: 0-9 . (dot) Note: If a decimal point is included, the amount reflects a dollar value. If a decimal point is not included, the amount reflects a cent value.

  • :ship_from_zip – Applicable for Level3 Charge. The postal code for the address to which the goods are being shipped. Format: Alphanumeric |Min Length=2 Max Length=10

  • :destination_country_code – Applicable for Level3 Charge. The destination country code indicator. Format: Alphanumeric.

  • :tax_type – Applicable for Level3 Charge. The type of tax. For example, VAT, NATIONAL, Service Tax. Format: Alphanumeric and Special Character

  • :vat_invoice – Applicable for Level3 Charge. The Value Added Tax (VAT) invoice number associated with the transaction. Format: Alphanumeric and Special Character |Min Length=0 Max Length=15|Allowed character: a-z A-Z 0-9 Space <>

  • :tax_rate – Applicable for Level3 Charge. The type of tax rate. This field is used if taxCategory is not used. Default sale tax rate in percentage Must be between 0.1% - 22% ,Applicable only Level 2 AutoFill. Format: Decimal Number |Max Length=4|Allowed characters: 0-9 .(dot) Allowed range: 0.01 - 100

  • :email – Customer’s email address sent with payment method.



99
100
101
102
103
104
105
# File 'lib/active_merchant/billing/gateways/pay_arc.rb', line 99

def purchase(money, creditcard, options = {})
  options[:capture] = 1
  MultiResponse.run do |r|
    r.process { token(creditcard, options) }
    r.process { charge(money, r.authorization, options) }
  end
end

#refund(money, tx_reference, options = {}) ⇒ Object

Refund full / partial payment of an successful charge / capture / purchase.

:money A positive integer in cents representing how much to charge. The minimum amount is 50c USD.

:tx_reference charge_id from previously created / authorized a charge

:options Other information like address, card source etc can be passed in options



205
206
207
208
209
210
211
# File 'lib/active_merchant/billing/gateways/pay_arc.rb', line 205

def refund(money, tx_reference, options = {})
  post = {}
  add_money(post, money, options)
  action = STANDARD_ACTIONS[:refund][:end_point].gsub(/{{charge_id}}/, tx_reference)
  post = filter_gateway_fields(post, options, STANDARD_ACTIONS[:refund][:allowed_fields])
  commit(action, post)
end

#scrub(transcript) ⇒ Object



260
261
262
263
264
265
266
# File 'lib/active_merchant/billing/gateways/pay_arc.rb', line 260

def scrub(transcript)
  #:nodoc:
  transcript.
    gsub(%r((Authorization: Bearer )[^\s]+\s)i, '\1[FILTERED]\2').
    gsub(%r((&?card_number=)[^&]*)i, '\1[FILTERED]').
    gsub(%r((&?cvv=)[^&]*)i, '\1[BLANK]')
end

#supports_scrubbing?Boolean

:nodoc:

Returns:

  • (Boolean)


256
257
258
# File 'lib/active_merchant/billing/gateways/pay_arc.rb', line 256

def supports_scrubbing? #:nodoc:
  true
end

#token(creditcard, options = {}) ⇒ Object

:nodoc:



246
247
248
249
250
251
252
253
254
# File 'lib/active_merchant/billing/gateways/pay_arc.rb', line 246

def token(creditcard, options = {})
  post = {}
  post['authorize_card'] = 1
  post['card_source'] = options[:card_source]
  add_creditcard(post, creditcard, options)
  add_address(post, options)
  post = filter_gateway_fields(post, options, STANDARD_ACTIONS[:token][:allowed_fields])
  commit(STANDARD_ACTIONS[:token][:end_point], post)
end

#verify(creditcard, options = {}) ⇒ Object

Verify the creditcard API through PAYARC.

:creditcard CreditCard object with card details.

:options Other information like address, card source etc can be passed in options

Options

  • :card_source – Source of payment (REQUIRED) ( INTERNET, SWIPE, PHONE, MAIL, MANUAL )

  • :card_holder_name –Name of the Card Holder (OPTIONAL)

  • :address_line1 – Set in payment method’s billing address (OPTIONAL)

  • :address_line2 – Set in payment method’s billing address (OPTIONAL)

  • :state – State (OPTIONAL)

  • :country – Country (OPTIONAL)



241
242
243
# File 'lib/active_merchant/billing/gateways/pay_arc.rb', line 241

def verify(creditcard, options = {})
  token(creditcard, options)
end

#void(tx_reference, options = {}) ⇒ Object

Voids the transaction / charge.

:tx_reference charge_id from previously created charge

:options Other information like address, card source etc can be passed in options

Options

  • :reason – Reason for voiding transaction (REQUIRED) ( requested_by_customer, duplicate, fraudulent, other )



188
189
190
191
192
193
194
# File 'lib/active_merchant/billing/gateways/pay_arc.rb', line 188

def void(tx_reference, options = {})
  post = {}
  post['reason'] = options[:reason]
  action = STANDARD_ACTIONS[:void][:end_point].gsub(/{{chargeID}}/, tx_reference)
  post = filter_gateway_fields(post, options, STANDARD_ACTIONS[:void][:allowed_fields])
  commit(action, post)
end