Class: ActiveMerchant::Billing::SagePayGateway
- Defined in:
- lib/active_merchant/billing/gateways/sage_pay.rb
Constant Summary collapse
- TEST_URL =
'https://test.sagepay.com/gateway/service'- LIVE_URL =
'https://live.sagepay.com/gateway/service'- SIMULATOR_URL =
'https://test.sagepay.com/Simulator'- APPROVED =
'OK'- REGISTERED =
'REGISTERED'- AUTHENTICATED =
'AUTHENTICATED'- TRANSACTIONS =
{ :purchase => 'PAYMENT', :credit => 'REFUND', :authorization => 'DEFERRED', :capture => 'RELEASE', :void => 'VOID', :abort => 'ABORT', :repeat => 'REPEAT', :authenticate => 'AUTHENTICATE', :authorise => 'AUTHORISE' }
- 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
Instance Attribute Summary
Attributes inherited from Gateway
Instance Method Summary collapse
- #authenticate(money, credit_card, options = {}) ⇒ Object
- #authorize(money, credit_card, 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
Crediting requires a new order_id to passed in, as well as a description.
-
#initialize(options = {}) ⇒ SagePayGateway
constructor
A new instance of SagePayGateway.
- #purchase(money, credit_card, options = {}) ⇒ Object
-
#repeat(money, identification, options = {}) ⇒ Object
Identification is authorization for original payment or authorization.
- #test? ⇒ Boolean
-
#three_d_complete(pa_res, md) ⇒ Object
Completes a 3D Secure transaction.
- #three_d_secure_enabled? ⇒ Boolean
- #void(identification, options = {}) ⇒ Object
Methods inherited from Gateway
#card_brand, card_brand, inherited, supports?
Methods included from Utils
Methods included from CreditCardFormatting
Methods included from RequiresParameters
Methods included from PostsData
Constructor Details
#initialize(options = {}) ⇒ SagePayGateway
Returns a new instance of SagePayGateway.
57 58 59 60 61 |
# File 'lib/active_merchant/billing/gateways/sage_pay.rb', line 57 def initialize( = {}) requires!(, :login) = super end |
Instance Method Details
#authenticate(money, credit_card, options = {}) ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/active_merchant/billing/gateways/sage_pay.rb', line 99 def authenticate(money, credit_card, = {}) requires!(, :order_id) post = {} add_credit_card(post, credit_card) add_address(post, ) add_customer_data(post, ) add_invoice(post, ) add_amount(post, money, ) commit(:authenticate, post) end |
#authorize(money, credit_card, options = {}) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/active_merchant/billing/gateways/sage_pay.rb', line 85 def (money, credit_card, = {}) requires!(, :order_id) post = {} add_amount(post, money, ) add_invoice(post, ) add_credit_card(post, credit_card) add_address(post, ) add_customer_data(post, ) add_three_d_secure_flag(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.
132 133 134 135 136 137 138 139 |
# File 'lib/active_merchant/billing/gateways/sage_pay.rb', line 132 def capture(money, identification, = {}) post = {} add_reference(post, identification) add_release_amount(post, money, ) commit(:capture, post) end |
#credit(money, identification, options = {}) ⇒ Object
Crediting requires a new order_id to passed in, as well as a description
151 152 153 154 155 156 157 158 159 160 161 |
# File 'lib/active_merchant/billing/gateways/sage_pay.rb', line 151 def credit(money, identification, = {}) requires!(, :order_id, :description) post = {} add_credit_reference(post, identification) add_amount(post, money, ) add_invoice(post, ) commit(:credit, post) end |
#purchase(money, credit_card, options = {}) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/active_merchant/billing/gateways/sage_pay.rb', line 71 def purchase(money, credit_card, = {}) requires!(, :order_id) post = {} add_amount(post, money, ) add_invoice(post, ) add_credit_card(post, credit_card) add_address(post, ) add_customer_data(post, ) add_three_d_secure_flag(post, ) commit(:purchase, post) end |
#repeat(money, identification, options = {}) ⇒ Object
Identification is authorization for original payment or authorization. Supply an :order_id option that is a unique id for this repeat payment (don’t just supply the original order id).
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/active_merchant/billing/gateways/sage_pay.rb', line 114 def repeat(money, identification, = {}) requires!(, :order_id) post = {} add_invoice(post, ) (post, identification) add_amount(post, money, ) # If we're making the first payment, we AUTHORISE, otherwise we're REPEATING # a PAYMENT or an existing AUTHORISE if identification.split(';').last == 'authenticate' commit(:authorise, post) else commit(:repeat, post) end end |
#test? ⇒ Boolean
63 64 65 |
# File 'lib/active_merchant/billing/gateways/sage_pay.rb', line 63 def test? [:test] || super end |
#three_d_complete(pa_res, md) ⇒ Object
Completes a 3D Secure transaction
164 165 166 |
# File 'lib/active_merchant/billing/gateways/sage_pay.rb', line 164 def three_d_complete(pa_res, md) commit(:three_d_complete, 'PARes' => pa_res, 'MD' => md) end |
#three_d_secure_enabled? ⇒ Boolean
67 68 69 |
# File 'lib/active_merchant/billing/gateways/sage_pay.rb', line 67 def three_d_secure_enabled? [:enable_3d_secure] end |
#void(identification, options = {}) ⇒ Object
141 142 143 144 145 146 147 148 |
# File 'lib/active_merchant/billing/gateways/sage_pay.rb', line 141 def void(identification, = {}) post = {} add_reference(post, identification) action = abort_or_void_from(identification) commit(action, post) end |