Class: SolonGateway
- Inherits:
-
Object
- Object
- SolonGateway
- Includes:
- Solon::SagepayServices
- Defined in:
- lib/solon/solon_gateway.rb
Constant Summary collapse
- APPROVED =
'OK'
- INVALID =
'INVALID'
- NOTAUTHED =
'NOTAUTHED'
- ABORT =
'ABORT'
- REJECTED =
'REJECTED'
- ERROR =
'ERROR'
- ABORT_REPEATED =
'ABORT REPEATED'
- FAILURES =
[:NOTAUTHED, :ABORT, :REJECTED, :ABORT_REPEATED]
- ERRORS =
[:INVALID, :ERROR]
- VPS_PROTOCOL =
"2.23"
- TRANSACTIONS =
{ :payment => 'PAYMENT', :authenticate => 'AUTHENTICATE', :authorise => 'AUTHORISE', :deferred => 'DEFERRED', :refund => 'REFUND', :release => 'RELEASE', :repeat => 'REPEAT', :void => 'VOID', :cancel => 'CANCEL', :abort => 'ABORT' }
- AVS_CVV_CODE =
{ "NOTPROVIDED" => nil, "NOTCHECKED" => 'X', "MATCHED" => 'Y', "NOTMATCHED" => 'N' }
Constants included from Solon::SagepayServices
Solon::SagepayServices::BASE_URL, Solon::SagepayServices::SERVICE
Class Method Summary collapse
- .parse_callback(params) ⇒ Object
- .parse_notification(params) ⇒ Object
- .response(status, redirect_url, status_detail) ⇒ Object
Instance Method Summary collapse
-
#abort(options) ⇒ Object
Aborts (cancels) a DEFERRED payment.
-
#authenticate(money, options) ⇒ Object
Registers a payment so that the user can enter their details.
-
#authorise(money, options) ⇒ Object
Authorises a previously authenticated transaction.
-
#cancel(options) ⇒ Object
Cancels a previously authenticated transaction.
- #debug=(value) ⇒ Object
- #debug? ⇒ Boolean
-
#deferred(money, options) ⇒ Object
Registers a payment so that the user can enter their details.
-
#initialize(mode = Solon::Config.gateway_mode) ⇒ SolonGateway
constructor
A new instance of SolonGateway.
-
#payment(money, options) ⇒ Object
Registers a payment so that the user can enter their details.
-
#refund(money, options) ⇒ Object
Refunds a previously settled transaction.
-
#release(money, options) ⇒ Object
Releases (processes for payment/settlement) a DEFERRED or REPEATDEFERRED payment.
-
#repeat(money, options) ⇒ Object
Submits a repeat transaction.
-
#void(options) ⇒ Object
Voids a previously authorised payment (only possible after receiving the NotificationURL response).
Constructor Details
#initialize(mode = Solon::Config.gateway_mode) ⇒ SolonGateway
Returns a new instance of SolonGateway.
38 39 40 |
# File 'lib/solon/solon_gateway.rb', line 38 def initialize(mode=Solon::Config.gateway_mode) @mode = mode end |
Class Method Details
.parse_callback(params) ⇒ Object
285 286 287 |
# File 'lib/solon/solon_gateway.rb', line 285 def self.parse_callback(params) Solon::SagepayCallback.new(params).verify! end |
.parse_notification(params) ⇒ Object
281 282 283 |
# File 'lib/solon/solon_gateway.rb', line 281 def self.parse_notification(params) Solon::SagepayResponse.new(params).verify! end |
.response(status, redirect_url, status_detail) ⇒ Object
289 290 291 292 293 |
# File 'lib/solon/solon_gateway.rb', line 289 def self.response(status, redirect_url, status_detail) "Status=#{status}\r\n" + "RedirectURL=#{redirect_url}\r\n" + "StatusDetail=#{status_detail}" end |
Instance Method Details
#abort(options) ⇒ Object
Aborts (cancels) a DEFERRED payment. Options:
> transaction_reference (required, String(40))
> vps_transaction_id (required, String(38))
> security_key (required, String(10))
> transaction_authorisation_number (required, Long Integer)
Response:
> status
> status_detail
249 250 251 252 253 254 255 256 |
# File 'lib/solon/solon_gateway.rb', line 249 def abort() log "abort", add_common(TRANSACTIONS[:abort]) add_post_processing() commit! :abort end |
#authenticate(money, options) ⇒ Object
Registers a payment so that the user can enter their details. Returns a URL that the user must be forwarded to to make the payment. If the process following this request is followed (i.e. redirect to next_url, user fills in their details, Sagepay notifies server, and server responds with OK) the settlement will NOT go out the next day. Further “Authorise” requests are required before the user will be charged. Options:
> transaction_reference (required, String(40))
> description (required, String(100))
> notification_url (required, String)
> billing_data (optional, BillingData)
> basket (optional, Basket)
Response:
> status
> status_detail
> vps_transaction_id
> security_key
> next_url
94 95 96 97 98 99 100 101 102 103 |
# File 'lib/solon/solon_gateway.rb', line 94 def authenticate(money, ) log "authenticate", add_common(TRANSACTIONS[:authenticate]) add_registration(money, ) add_customer() add_basket() commit! :payment end |
#authorise(money, options) ⇒ Object
Authorises a previously authenticated transaction. This can be done multiple times, for amounts adding up to a maximum of 115% of the authenticated amount.
> transaction_reference (required, String(40))
> description (required, String(100))
> related_transaction_reference (required, String(40))
> related_vps_transaction_id (required, String(38))
> related_security_key (required, String(10))
Response:
> status
> status_detail
> vps_transaction_id
> transaction_authorisation_number
> security_key
> avs_cv2_result
> address_result
> post_code_result
> cv2_result
175 176 177 178 179 180 181 182 183 |
# File 'lib/solon/solon_gateway.rb', line 175 def (money, ) log "authorise", add_common TRANSACTIONS[:authorise] () add_registration(money, ) commit! :authorise end |
#cancel(options) ⇒ Object
Cancels a previously authenticated transaction. Options:
> transaction_reference (required, String(40))
> vps_transaction_id (required, String(38))
> security_key (required, String(10))
Response:
> status
> status_detail
193 194 195 196 197 198 199 200 |
# File 'lib/solon/solon_gateway.rb', line 193 def cancel() log "cancel", add_common TRANSACTIONS[:cancel] add_post_processing() commit! :cancel end |
#debug=(value) ⇒ Object
42 43 44 |
# File 'lib/solon/solon_gateway.rb', line 42 def debug=(value) @no_debug = !value end |
#debug? ⇒ Boolean
46 47 48 |
# File 'lib/solon/solon_gateway.rb', line 46 def debug? @mode == :simulator && !@no_debug end |
#deferred(money, options) ⇒ Object
Registers a payment so that the user can enter their details. Returns a URL that the user must be forwarded to to make the payment. If the process following this request is followed (i.e. redirect to next_url, user fills in their details, Sagepay notifies server, and server responds with OK) the settlement will NOT go out the next day, but a “shadow” will be placed on the account until the deferred payment is “Released” or “Aborted”. Deferred payments are only supposed to be used to add a delay of up to 7 days, to allow cahrging at the point when the order is shipped. Options:
> transaction_reference (required, String(40))
> description (required, String(100))
> notification_url (required, String)
> billing_data (optional, BillingData)
> basket (optional, Basket)
Response:
> status
> status_detail
> vps_transaction_id
> security_key
> next_url
123 124 125 126 127 128 129 130 131 132 |
# File 'lib/solon/solon_gateway.rb', line 123 def deferred(money, ) log "deferred", add_common TRANSACTIONS[:deferred] add_registration(money, ) add_customer() add_basket() commit! :deferred end |
#payment(money, options) ⇒ Object
Registers a payment so that the user can enter their details. Returns a URL that the user must be forwarded to to make the payment. If the process following this request is followed (i.e. redirect to next_url, user fills in their details, Sagepay notifies server, and server responds with OK) the settlement will go out the next day, automatically, for the full amount. Options:
> transaction_reference (required, String(40))
> description (required, String(100))
> notification_url (required, String)
> billing_data (optional, BillingData)
> basket (optional, Basket)
Response:
> status
> status_detail
> vps_transaction_id
> security_key
> next_url
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/solon/solon_gateway.rb', line 66 def payment(money, ) log "payment", add_common TRANSACTIONS[:payment] add_registration(money, ) add_customer() add_basket() commit! :payment end |
#refund(money, options) ⇒ Object
Refunds a previously settled transaction. Options:
> transaction_reference (required, String(40))
> description (required, String(100))
> related_transaction_reference (required, String(40))
> related_vps_transaction_id (required, String(38))
> related_security_key (required, String(10))
> related_transaction_authorisation_number (required, Long Integer)
Response:
> status
> status_detail
> vps_transaction_id
> transaction_authorisation_number
271 272 273 274 275 276 277 278 279 |
# File 'lib/solon/solon_gateway.rb', line 271 def refund(money, ) log "refund", add_common(TRANSACTIONS[:refund]) () add_registration(money, ) commit! :refund end |
#release(money, options) ⇒ Object
Releases (processes for payment/settlement) a DEFERRED or REPEATDEFERRED payment. Options:
> transaction_reference (required, String(40))
> vps_transaction_id (required, String(38))
> security_key (required, String(10))
> transaction_authorisation_number (required, Long Integer)
Response:
> status
> status_detail
211 212 213 214 215 216 217 218 219 |
# File 'lib/solon/solon_gateway.rb', line 211 def release(money, ) log "release", add_common TRANSACTIONS[:release] add_post_processing() @post["ReleaseAmount"] = "%.2f" % money.amount commit! :release end |
#repeat(money, options) ⇒ Object
Submits a repeat transaction. Options:
> transaction_reference (required, String(40))
> description (required, String(100))
> related_transaction_reference (required, String(40))
> related_vps_transaction_id (required, String(38))
> related_security_key (required, String(10))
> related_transaction_authorisation_number (required, Long Integer)
Response:
> status
> status_detail
> vps_transaction_id
> transaction_authorisation_number
> security_key
148 149 150 151 152 153 154 155 156 |
# File 'lib/solon/solon_gateway.rb', line 148 def repeat(money, ) log "repeat", add_common(TRANSACTIONS[:repeat]) () add_registration(money, ) commit! :repeat end |
#void(options) ⇒ Object
Voids a previously authorised payment (only possible after receiving the NotificationURL response). Options:
> transaction_reference (required, String(40))
> vps_transaction_id (required, String(38))
> security_key (required, String(10))
> transaction_authorisation_number (required, Long Integer)
Response:
> status
> status_detail
230 231 232 233 234 235 236 237 |
# File 'lib/solon/solon_gateway.rb', line 230 def void() log "void", add_common(TRANSACTIONS[:void]) add_post_processing() commit! :void end |