Class: SagePay::Server::Registration
- Defined in:
- lib/sage_pay/server/registration.rb
Instance Attribute Summary collapse
-
#account_type ⇒ Object
Returns the value of attribute account_type.
-
#allow_gift_aid ⇒ Object
Returns the value of attribute allow_gift_aid.
-
#apply_3d_secure ⇒ Object
Returns the value of attribute apply_3d_secure.
-
#apply_avs_cv2 ⇒ Object
Returns the value of attribute apply_avs_cv2.
-
#basket ⇒ Object
Returns the value of attribute basket.
-
#billing_address ⇒ Object
Returns the value of attribute billing_address.
-
#billing_agreement ⇒ Object
Returns the value of attribute billing_agreement.
-
#currency ⇒ Object
Returns the value of attribute currency.
-
#customer_email ⇒ Object
Returns the value of attribute customer_email.
-
#delivery_address ⇒ Object
Returns the value of attribute delivery_address.
-
#description ⇒ Object
Returns the value of attribute description.
-
#notification_url ⇒ Object
Returns the value of attribute notification_url.
-
#profile ⇒ Object
Returns the value of attribute profile.
Attributes inherited from Command
#mode, #vendor, #vendor_tx_code
Instance Method Summary collapse
- #live_service ⇒ Object
- #post_params ⇒ Object
- #response_from_response_body(response_body) ⇒ Object
- #run! ⇒ Object
- #signature_verification_details ⇒ Object
- #simulator_service ⇒ Object
Methods inherited from Command
decimal_accessor, #initialize, #url
Constructor Details
This class inherits a constructor from SagePay::Server::Command
Instance Attribute Details
#account_type ⇒ Object
Returns the value of attribute account_type.
4 5 6 |
# File 'lib/sage_pay/server/registration.rb', line 4 def account_type @account_type end |
#allow_gift_aid ⇒ Object
Returns the value of attribute allow_gift_aid.
4 5 6 |
# File 'lib/sage_pay/server/registration.rb', line 4 def allow_gift_aid @allow_gift_aid end |
#apply_3d_secure ⇒ Object
Returns the value of attribute apply_3d_secure.
4 5 6 |
# File 'lib/sage_pay/server/registration.rb', line 4 def apply_3d_secure @apply_3d_secure end |
#apply_avs_cv2 ⇒ Object
Returns the value of attribute apply_avs_cv2.
4 5 6 |
# File 'lib/sage_pay/server/registration.rb', line 4 def apply_avs_cv2 @apply_avs_cv2 end |
#basket ⇒ Object
Returns the value of attribute basket.
4 5 6 |
# File 'lib/sage_pay/server/registration.rb', line 4 def basket @basket end |
#billing_address ⇒ Object
Returns the value of attribute billing_address.
4 5 6 |
# File 'lib/sage_pay/server/registration.rb', line 4 def billing_address @billing_address end |
#billing_agreement ⇒ Object
Returns the value of attribute billing_agreement.
4 5 6 |
# File 'lib/sage_pay/server/registration.rb', line 4 def billing_agreement @billing_agreement end |
#currency ⇒ Object
Returns the value of attribute currency.
4 5 6 |
# File 'lib/sage_pay/server/registration.rb', line 4 def currency @currency end |
#customer_email ⇒ Object
Returns the value of attribute customer_email.
4 5 6 |
# File 'lib/sage_pay/server/registration.rb', line 4 def customer_email @customer_email end |
#delivery_address ⇒ Object
Returns the value of attribute delivery_address.
4 5 6 |
# File 'lib/sage_pay/server/registration.rb', line 4 def delivery_address @delivery_address end |
#description ⇒ Object
Returns the value of attribute description.
4 5 6 |
# File 'lib/sage_pay/server/registration.rb', line 4 def description @description end |
#notification_url ⇒ Object
Returns the value of attribute notification_url.
4 5 6 |
# File 'lib/sage_pay/server/registration.rb', line 4 def notification_url @notification_url end |
#profile ⇒ Object
Returns the value of attribute profile.
4 5 6 |
# File 'lib/sage_pay/server/registration.rb', line 4 def profile @profile end |
Instance Method Details
#live_service ⇒ Object
49 50 51 |
# File 'lib/sage_pay/server/registration.rb', line 49 def live_service "vspserver-register" end |
#post_params ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/sage_pay/server/registration.rb', line 57 def post_params params = super.merge({ "Amount" => ("%.2f" % amount), "Currency" => currency.upcase, "Description" => description, "NotificationURL" => notification_url, "BillingSurname" => billing_address.surname, "BillingFirstnames" => billing_address.first_names, "BillingAddress1" => billing_address.address_1, "BillingCity" => billing_address.city, "BillingPostCode" => billing_address.post_code, "BillingCountry" => billing_address.country, "DeliverySurname" => delivery_address.surname, "DeliveryFirstnames" => delivery_address.first_names, "DeliveryAddress1" => delivery_address.address_1, "DeliveryCity" => delivery_address.city, "DeliveryPostCode" => delivery_address.post_code, "DeliveryCountry" => delivery_address.country, }) # Optional parameters that are only inserted if they are present params['BillingAddress2'] = billing_address.address_2 if billing_address.address_2.present? params['BillingState'] = billing_address.state if billing_address.state.present? params['BillingPhone'] = billing_address.phone if billing_address.phone.present? params['DeliveryAddress2'] = delivery_address.address_2 if delivery_address.address_2.present? params['DeliveryState'] = delivery_address.state if delivery_address.state.present? params['DeliveryPhone'] = delivery_address.phone if delivery_address.phone.present? params['CustomerEmail'] = customer_email if customer_email.present? params['Basket'] = basket if basket.present? params['AllowGiftAid'] = allow_gift_aid ? "1" : "0" if allow_gift_aid.present? || allow_gift_aid == false params['ApplyAVSCV2'] = apply_avs_cv2.to_s if apply_avs_cv2.present? params['Apply3DSecure'] = apply_3d_secure.to_s if apply_3d_secure.present? params['Profile'] = profile.to_s.upcase if profile.present? params['BillingAgreement'] = billing_agreement ? "1" : "0" if billing_agreement.present? || billing_agreement == false params['AccountType'] = account_type_param if account_type.present? # And return the completed hash params end |
#response_from_response_body(response_body) ⇒ Object
97 98 99 |
# File 'lib/sage_pay/server/registration.rb', line 97 def response_from_response_body(response_body) RegistrationResponse.from_response_body(response_body) end |
#run! ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/sage_pay/server/registration.rb', line 30 def run! if @response.nil? || (@vendor_tx_code_sent != vendor_tx_code) @vendor_tx_code_sent = vendor_tx_code @response = handle_response(post) else raise RuntimeError, "This vendor transaction code has already been registered" end end |
#signature_verification_details ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/sage_pay/server/registration.rb', line 39 def signature_verification_details if @response.nil? raise RuntimeError, "Not yet registered" elsif @response.failed? raise RuntimeError, "Registration failed" else @signature_verification_details ||= SignatureVerificationDetails.new(vendor, @response.security_key) end end |
#simulator_service ⇒ Object
53 54 55 |
# File 'lib/sage_pay/server/registration.rb', line 53 def simulator_service "VendorRegisterTx" end |