Class: ActiveMerchant::Billing::PayJunctionGateway
- Defined in:
- lib/active_merchant/billing/gateways/pay_junction.rb
Overview
PayJunction Gateway
This gateway accepts the following arguments:
:login => your PayJunction username
:password => your PayJunction pass
Example use:
gateway = ActiveMerchant::Billing::Base.gateway(:pay_junction).new(
:login => "my_account",
:password => "my_pass"
)
# set up credit card obj as in main ActiveMerchant example
creditcard = ActiveMerchant::Billing::CreditCard.new(
:type => 'visa',
:number => '4242424242424242',
:month => 8,
:year => 2009,
:first_name => 'Bob',
:last_name => 'Bobsen'
)
# optionally specify address if using AVS
address = { :address1 => '101 Test Ave', :city => 'Test', :state => 'TS',
:zip => '10101', :country => 'US' }
# run request
response = gateway.purchase(1000, creditcard, :address => address) # charge 10 dollars
1) Check whether the transaction was successful
response.success?
2) Retrieve the message returned by PayJunction
response.
3) Retrieve the unique transaction ID returned by PayJunction
response.
This gateway supports “instant” transactions. These transactions allow you to execute an operation on a previously run card without card information provided you have the transaction id from a previous transaction with the same card. All functions that take a credit card object for this gateway can take a transaction id string instead.
Test Transactions
See the source for initialize() for test account information. Note that PayJunction does not allow test transactions on your account, so if the gateway is running in :test mode your transaction will be run against PayJunction’s global test account and will not show up in your account.
Transactions ran on this account go through a test processor, so there is no need to void or otherwise cancel transactions. However, for further safety, please use the special card numbers 4433221111223344 or 4444333322221111 and keep transaction amounts below $4.00 when testing.
Also note, transactions ran for an amount between $0.00 and $1.99 will likely result in denial. To demonstrate approvals, use amounts between $2.00 and $4.00.
Test transactions can be checked by logging into PayJunction Web Login with username ‘pj-cm-01’ and password ‘pj-cm-01p’
Usage Details
Below is a map of values accepted by PayJunction and how you should submit each to ActiveMerchant
PayJunction Field ActiveMerchant Use
dc_logon provide as :login value to gateway instantiation dc_password provide as :password value to gateway instantiation
dc_name will be retrieved from credit_card.name dc_first_name :first_name on CreditCard object instantiation dc_last_name :last_name on CreditCard object instantiation dc_number :number on CreditCard object instantiation dc_expiration_month :month on CreditCard object instantiation dc_expiration_year :year on CreditCard object instantiation dc_verification_number :verification_value on CC object instantiation
dc_transaction_amount include as argument to method for your transaction type dc_transaction_type do nothing, set by your transaction type dc_version do nothing, always “1.2”
dc_transaction_id submit as a string in place of CreditCard obj for
"instant" transactions.
dc_invoice :order_id in options for transaction method dc_notes :description in options for transaction method
See example use above for address AVS fields See #recurring for periodic transaction fields
Constant Summary collapse
- API_VERSION =
'1.2'
- TEST_LOGIN =
'pj-ql-01'
- TEST_PASSWORD =
'pj-ql-01p'
- SUCCESS_CODES =
%w[00 85]
- SUCCESS_MESSAGE =
'The transaction was approved.'
- FAILURE_MESSAGE =
'The transaction was declined.'
- DECLINE_CODES =
{ 'AE' => 'Address verification failed because address did not match.', 'ZE' => 'Address verification failed because zip did not match.', 'XE' => 'Address verification failed because zip and address did not match.', 'YE' => 'Address verification failed because zip and address did not match.', 'OE' => 'Address verification failed because address or zip did not match.', 'UE' => 'Address verification failed because cardholder address unavailable.', 'RE' => 'Address verification failed because address verification system is not working.', 'SE' => 'Address verification failed because address verification system is unavailable.', 'EE' => 'Address verification failed because transaction is not a mail or phone order.', 'GE' => 'Address verification failed because international support is unavailable.', 'CE' => 'Declined because CVV2/CVC2 code did not match.', '04' => 'Declined. Pick up card.', '07' => 'Declined. Pick up card (Special Condition).', '41' => 'Declined. Pick up card (Lost).', '43' => 'Declined. Pick up card (Stolen).', '13' => 'Declined because of the amount is invalid.', '14' => 'Declined because the card number is invalid.', '80' => 'Declined because of an invalid date.', '05' => 'Declined. Do not honor.', '51' => 'Declined because of insufficient funds.', 'N4' => 'Declined because the amount exceeds issuer withdrawal limit.', '61' => 'Declined because the amount exceeds withdrawal limit.', '62' => 'Declined because of an invalid service code (restricted).', '65' => 'Declined because the card activity limit exceeded.', '93' => 'Declined because there a violation (the transaction could not be completed).', '06' => 'Declined because address verification failed.', '54' => 'Declined because the card has expired.', '15' => 'Declined because there is no such issuer.', '96' => 'Declined because of a system error.', 'N7' => 'Declined because of a CVV2/CVC2 mismatch.', 'M4' => 'Declined.', 'FE' => 'There was a format error with your Trinity Gateway Service (API) request.', 'LE' => 'Could not log you in (problem with dc_logon and/or dc_password).', 'NL' => 'Aborted because of a system error, please try again later. ', 'AB' => 'Aborted because of an upstream system error, please try again later.' }
Constants inherited from Gateway
Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::RECURRING_DEPRECATION_MESSAGE, Gateway::STANDARD_ERROR_CODE
Instance Attribute Summary
Attributes inherited from Gateway
Instance Method Summary collapse
-
#authorize(money, payment_source, options = {}) ⇒ Object
The first half of the preauth(authorize)/postauth(capture) model.
-
#capture(money, authorization, options = {}) ⇒ Object
The second half of the preauth(authorize)/postauth(capture) model.
- #credit(money, authorization, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ PayJunctionGateway
constructor
A new instance of PayJunctionGateway.
-
#purchase(money, payment_source, options = {}) ⇒ Object
A simple sale, capturing funds immediately.
-
#recurring(money, payment_source, options = {}) ⇒ Object
Set up a sale that will be made on a regular basis for the same amount (ex. $20 a month for 12 months).
-
#refund(money, authorization, options = {}) ⇒ Object
Return money to a card that was previously billed.
- #test? ⇒ Boolean
-
#void(authorization, options = {}) ⇒ Object
Cancel a transaction that has been charged but has not yet made it through the batch process.
Methods inherited from Gateway
#add_field_to_post_if_present, #add_fields_to_post_if_present, card_brand, #card_brand, #generate_unique_id, inherited, #scrub, supported_countries, #supported_countries, supported_countries=, supports?, #supports_network_tokenization?, #supports_scrubbing?
Methods included from CreditCardFormatting
Methods included from PostsData
included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request
Constructor Details
#initialize(options = {}) ⇒ PayJunctionGateway
Returns a new instance of PayJunctionGateway.
158 159 160 161 |
# File 'lib/active_merchant/billing/gateways/pay_junction.rb', line 158 def initialize( = {}) requires!(, :login, :password) super end |
Instance Method Details
#authorize(money, payment_source, options = {}) ⇒ Object
The first half of the preauth(authorize)/postauth(capture) model. Checks to make sure funds are available for a transaction, and returns a transaction_id that can be used later to postauthorize (capture) the funds.
166 167 168 169 170 171 172 173 174 175 |
# File 'lib/active_merchant/billing/gateways/pay_junction.rb', line 166 def (money, payment_source, = {}) parameters = { transaction_amount: amount(money) } add_payment_source(parameters, payment_source) add_address(parameters, ) add_optional_fields(parameters, ) commit('AUTHORIZATION', parameters) end |
#capture(money, authorization, options = {}) ⇒ Object
The second half of the preauth(authorize)/postauth(capture) model. Retrieve funds that have been previously authorized with authorization
192 193 194 195 196 197 198 199 200 |
# File 'lib/active_merchant/billing/gateways/pay_junction.rb', line 192 def capture(money, , = {}) parameters = { transaction_id: , posture: 'capture' } add_optional_fields(parameters, ) commit('update', parameters) end |
#credit(money, authorization, options = {}) ⇒ Object
213 214 215 216 |
# File 'lib/active_merchant/billing/gateways/pay_junction.rb', line 213 def credit(money, , = {}) ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE refund(money, , ) end |
#purchase(money, payment_source, options = {}) ⇒ Object
A simple sale, capturing funds immediately. Execute authorization and capture in a single step.
179 180 181 182 183 184 185 186 187 188 |
# File 'lib/active_merchant/billing/gateways/pay_junction.rb', line 179 def purchase(money, payment_source, = {}) parameters = { transaction_amount: amount(money) } add_payment_source(parameters, payment_source) add_address(parameters, ) add_optional_fields(parameters, ) commit('AUTHORIZATION_CAPTURE', parameters) end |
#recurring(money, payment_source, options = {}) ⇒ Object
Set up a sale that will be made on a regular basis for the same amount (ex. $20 a month for 12 months)
The parameter :periodicity should be specified as either :monthly, :weekly, or :daily The parameter :payments should be the number of payments to be made
gateway.recurring('2000', creditcard, :periodicity => :monthly, :payments => 12)
The optional parameter :starting_at takes a date or time argument or a string in YYYYMMDD format and can be used to specify when the first charge will be made. If omitted the first charge will be immediate.
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 |
# File 'lib/active_merchant/billing/gateways/pay_junction.rb', line 241 def recurring(money, payment_source, = {}) ActiveMerchant.deprecated RECURRING_DEPRECATION_MESSAGE requires!(, %i[periodicity monthly weekly daily], :payments) periodic_type = case [:periodicity] when :monthly 'month' when :weekly 'week' when :daily 'day' end if [:starting_at].nil? start_date = Time.now.strftime('%Y-%m-%d') elsif [:starting_at].is_a?(String) sa = [:starting_at] start_date = "#{sa[0..3]}-#{sa[4..5]}-#{sa[6..7]}" else start_date = [:starting_at].strftime('%Y-%m-%d') end parameters = { transaction_amount: amount(money), schedule_periodic_type: periodic_type, schedule_create: 'true', schedule_limit: [:payments].to_i > 1 ? [:payments] : 1, schedule_periodic_number: 1, schedule_start: start_date } add_payment_source(parameters, payment_source) add_optional_fields(parameters, ) add_address(parameters, ) commit('AUTHORIZATION_CAPTURE', parameters) end |
#refund(money, authorization, options = {}) ⇒ Object
Return money to a card that was previously billed. authorization should be the transaction id of the transaction we are returning.
204 205 206 207 208 209 210 211 |
# File 'lib/active_merchant/billing/gateways/pay_junction.rb', line 204 def refund(money, , = {}) parameters = { transaction_amount: amount(money), transaction_id: } commit('CREDIT', parameters) end |
#test? ⇒ Boolean
280 281 282 |
# File 'lib/active_merchant/billing/gateways/pay_junction.rb', line 280 def test? (test_login? || super) end |
#void(authorization, options = {}) ⇒ Object
Cancel a transaction that has been charged but has not yet made it through the batch process.
220 221 222 223 224 225 226 227 228 |
# File 'lib/active_merchant/billing/gateways/pay_junction.rb', line 220 def void(, = {}) parameters = { transaction_id: , posture: 'void' } add_optional_fields(parameters, ) commit('update', parameters) end |