Class: ActiveMerchant::Billing::PinGateway
- Defined in:
- lib/active_merchant/billing/gateways/pin.rb
Constant Summary
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, creditcard, options = {}) ⇒ Object
Authorize an amount on a credit card.
-
#capture(money, token, options = {}) ⇒ Object
Captures a previously authorized charge.
-
#initialize(options = {}) ⇒ PinGateway
constructor
A new instance of PinGateway.
-
#purchase(money, creditcard, options = {}) ⇒ Object
Create a charge using a credit card, card token or customer token.
-
#refund(money, token, options = {}) ⇒ Object
Refund a transaction.
- #scrub(transcript) ⇒ Object
-
#store(creditcard, options = {}) ⇒ Object
Create a customer and associated credit card.
- #supports_scrubbing ⇒ Object
-
#unstore(token) ⇒ Object
Unstore a customer and associated credit card.
-
#update(token, creditcard, options = {}) ⇒ Object
Updates the credit card for the customer.
-
#verify_3ds(session_token, options = {}) ⇒ Object
Verify a previously authorized charge.
-
#void(token, options = {}) ⇒ Object
Voids a previously authorized charge.
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?, #supports_scrubbing?, #test?
Methods included from CreditCardFormatting
#expdate, #format, #strftime_yyyymm
Methods included from PostsData
included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request
Constructor Details
#initialize(options = {}) ⇒ PinGateway
Returns a new instance of PinGateway.
14 15 16 17 |
# File 'lib/active_merchant/billing/gateways/pin.rb', line 14 def initialize( = {}) requires!(, :api_key) super end |
Instance Method Details
#authorize(money, creditcard, options = {}) ⇒ Object
Authorize an amount on a credit card. Once authorized, you can later capture this charge using the charge token that is returned.
68 69 70 71 72 |
# File 'lib/active_merchant/billing/gateways/pin.rb', line 68 def (money, creditcard, = {}) [:capture] = false purchase(money, creditcard, ) end |
#capture(money, token, options = {}) ⇒ Object
Captures a previously authorized charge. Capturing only part of the original authorization is currently not supported.
76 77 78 |
# File 'lib/active_merchant/billing/gateways/pin.rb', line 76 def capture(money, token, = {}) commit(:put, "charges/#{CGI.escape(token)}/capture", { amount: amount(money) }, ) end |
#purchase(money, creditcard, options = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/active_merchant/billing/gateways/pin.rb', line 23 def purchase(money, creditcard, = {}) post = {} add_amount(post, money, ) add_customer_data(post, ) add_invoice(post, ) add_creditcard(post, creditcard) add_address(post, creditcard, ) add_capture(post, ) (post, ) add_3ds(post, ) add_platform_adjustment(post, ) commit(:post, 'charges', post, ) end |
#refund(money, token, options = {}) ⇒ Object
Refund a transaction
62 63 64 |
# File 'lib/active_merchant/billing/gateways/pin.rb', line 62 def refund(money, token, = {}) commit(:post, "charges/#{CGI.escape(token)}/refunds", { amount: amount(money) }, ) end |
#scrub(transcript) ⇒ Object
105 106 107 108 109 110 |
# File 'lib/active_merchant/billing/gateways/pin.rb', line 105 def scrub(transcript) transcript. gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]'). gsub(/(number\\?":\\?")(\d*)/, '\1[FILTERED]'). gsub(/(cvc\\?":\\?")(\d*)/, '\1[FILTERED]') end |
#store(creditcard, options = {}) ⇒ Object
Create a customer and associated credit card. The token that is returned can be used instead of a credit card parameter in the purchase method
41 42 43 44 45 46 47 48 |
# File 'lib/active_merchant/billing/gateways/pin.rb', line 41 def store(creditcard, = {}) post = {} add_creditcard(post, creditcard) add_customer_data(post, ) add_address(post, creditcard, ) commit(:post, 'customers', post, ) end |
#supports_scrubbing ⇒ Object
101 102 103 |
# File 'lib/active_merchant/billing/gateways/pin.rb', line 101 def supports_scrubbing true end |
#unstore(token) ⇒ Object
Unstore a customer and associated credit card.
51 52 53 54 55 56 57 58 59 |
# File 'lib/active_merchant/billing/gateways/pin.rb', line 51 def unstore(token) customer_token = if /cus_/.match?(token) get_customer_token(token) else token end commit(:delete, "customers/#{CGI.escape(customer_token)}", {}, {}) end |
#update(token, creditcard, options = {}) ⇒ Object
Updates the credit card for the customer.
91 92 93 94 95 96 97 98 99 |
# File 'lib/active_merchant/billing/gateways/pin.rb', line 91 def update(token, creditcard, = {}) post = {} token = get_customer_token(token) add_creditcard(post, creditcard) add_customer_data(post, ) add_address(post, creditcard, ) commit(:put, "customers/#{CGI.escape(token)}", post, ) end |
#verify_3ds(session_token, options = {}) ⇒ Object
Verify a previously authorized charge.
86 87 88 |
# File 'lib/active_merchant/billing/gateways/pin.rb', line 86 def verify_3ds(session_token, = {}) commit(:get, "/charges/verify?session_token=#{session_token}", nil, ) end |
#void(token, options = {}) ⇒ Object
Voids a previously authorized charge.
81 82 83 |
# File 'lib/active_merchant/billing/gateways/pin.rb', line 81 def void(token, = {}) commit(:put, "charges/#{CGI.escape(token)}/void", {}, ) end |