Class: ActiveMerchant::Billing::SagePayGateway
- Defined in:
- lib/active_merchant/billing/gateways/sage_pay.rb
Constant Summary collapse
- APPROVED =
'OK'
- TRANSACTIONS =
{ :purchase => 'PAYMENT', :credit => 'REFUND', :authorization => 'DEFERRED', :capture => 'RELEASE', :void => 'VOID', :abort => 'ABORT', :store => 'TOKEN', :unstore => 'REMOVETOKEN' }
- CREDIT_CARDS =
{ :visa => "VISA", :master => "MC", :delta => "DELTA", :solo => "SOLO", :switch => "MAESTRO", :maestro => "MAESTRO", :american_express => "AMEX", :electron => "UKE", :diners_club => "DC", :jcb => "JCB" }
- ELECTRON =
/^(424519|42496[23]|450875|48440[6-8]|4844[1-5][1-5]|4917[3-5][0-9]|491880)\d{10}(\d{3})?$/
- AVS_CVV_CODE =
{ "NOTPROVIDED" => nil, "NOTCHECKED" => 'X', "MATCHED" => 'Y', "NOTMATCHED" => 'N' }
Constants inherited from Gateway
Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::CURRENCIES_WITHOUT_FRACTIONS, Gateway::DEBIT_CARDS, Gateway::RECURRING_DEPRECATION_MESSAGE, Gateway::STANDARD_ERROR_CODE
Instance Attribute Summary
Attributes inherited from Gateway
Instance Method Summary collapse
- #authorize(money, payment_method, options = {}) ⇒ Object
-
#capture(money, identification, options = {}) ⇒ Object
You can only capture a transaction once, even if you didn’t capture the full amount the first time.
- #credit(money, identification, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ SagePayGateway
constructor
A new instance of SagePayGateway.
- #purchase(money, payment_method, options = {}) ⇒ Object
-
#refund(money, identification, options = {}) ⇒ Object
Refunding requires a new order_id to passed in, as well as a description.
- #store(credit_card, options = {}) ⇒ Object
- #unstore(token, options = {}) ⇒ Object
- #void(identification, options = {}) ⇒ Object
Methods inherited from Gateway
#card_brand, card_brand, #generate_unique_id, inherited, non_fractional_currency?, #scrub, supported_countries, #supported_countries, supported_countries=, supports?, #supports_scrubbing?, #test?
Methods included from CreditCardFormatting
Methods included from PostsData
included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request
Constructor Details
#initialize(options = {}) ⇒ SagePayGateway
Returns a new instance of SagePayGateway.
55 56 57 58 |
# File 'lib/active_merchant/billing/gateways/sage_pay.rb', line 55 def initialize( = {}) requires!(, :login) super end |
Instance Method Details
#authorize(money, payment_method, options = {}) ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/active_merchant/billing/gateways/sage_pay.rb', line 75 def (money, payment_method, = {}) requires!(, :order_id) post = {} add_amount(post, money, ) add_invoice(post, ) add_payment_method(post, payment_method, ) add_address(post, ) add_customer_data(post, ) add_optional_data(post, ) commit(:authorization, post) end |
#capture(money, identification, options = {}) ⇒ Object
You can only capture a transaction once, even if you didn’t capture the full amount the first time.
91 92 93 94 95 96 97 98 |
# File 'lib/active_merchant/billing/gateways/sage_pay.rb', line 91 def capture(money, identification, = {}) post = {} add_reference(post, identification) add_release_amount(post, money, ) commit(:capture, post) end |
#credit(money, identification, options = {}) ⇒ Object
122 123 124 125 |
# File 'lib/active_merchant/billing/gateways/sage_pay.rb', line 122 def credit(money, identification, = {}) ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE refund(money, identification, ) end |
#purchase(money, payment_method, options = {}) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/active_merchant/billing/gateways/sage_pay.rb', line 60 def purchase(money, payment_method, = {}) requires!(, :order_id) post = {} add_amount(post, money, ) add_invoice(post, ) add_payment_method(post, payment_method, ) add_address(post, ) add_customer_data(post, ) add_optional_data(post, ) commit(:purchase, post) end |
#refund(money, identification, options = {}) ⇒ Object
Refunding requires a new order_id to passed in, as well as a description
110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/active_merchant/billing/gateways/sage_pay.rb', line 110 def refund(money, identification, = {}) requires!(, :order_id, :description) post = {} add_credit_reference(post, identification) add_amount(post, money, ) add_invoice(post, ) commit(:credit, post) end |
#store(credit_card, options = {}) ⇒ Object
127 128 129 130 131 132 133 |
# File 'lib/active_merchant/billing/gateways/sage_pay.rb', line 127 def store(credit_card, = {}) post = {} add_credit_card(post, credit_card) add_currency(post, 0, ) commit(:store, post) end |
#unstore(token, options = {}) ⇒ Object
135 136 137 138 139 |
# File 'lib/active_merchant/billing/gateways/sage_pay.rb', line 135 def unstore(token, = {}) post = {} add_token(post, token) commit(:unstore, post) end |
#void(identification, options = {}) ⇒ Object
100 101 102 103 104 105 106 107 |
# File 'lib/active_merchant/billing/gateways/sage_pay.rb', line 100 def void(identification, = {}) post = {} add_reference(post, identification) action = abort_or_void_from(identification) commit(action, post) end |