Class: SaferpayRuby::PaymentGatewayApi
- Inherits:
-
Object
- Object
- SaferpayRuby::PaymentGatewayApi
- Defined in:
- lib/saferpay_ruby.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ PaymentGatewayApi
constructor
A new instance of PaymentGatewayApi.
- #initialize_payment_api(options = {}) ⇒ Object
- #initialize_payment_assert_api(options = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ PaymentGatewayApi
Returns a new instance of PaymentGatewayApi.
11 12 13 14 15 16 17 18 19 |
# File 'lib/saferpay_ruby.rb', line 11 def initialize( = {}) .delete(:endpoint) .delete_if { |k, v| v.nil? } @options = SaferpayRuby..merge() @options.each_pair do |key, val| send "#{key}=", val end end |
Instance Method Details
#initialize_payment_api(options = {}) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/saferpay_ruby.rb', line 21 def initialize_payment_api( = {}) http = Net::HTTP.new(endpoint.host, endpoint.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE request = Net::HTTP::Post.new(endpoint) request["content-type"] = 'application/json; charset=utf-8' request["accept"] = 'application/json' request["authorization"] = authentication request.body = { "RequestHeader": { "SpecVersion": "1.7", "CustomerId": customer_id, "RequestId": [:request_id], "RetryIndicator": 0 }, "TerminalId": terminal_id, "Payment": { "Amount": { "Value": [:amount], "CurrencyCode": [:currency] }, "OrderId": [:order_id], "Description": [:description] }, "PaymentMethods": [:payment_methods], "ReturnUrls": { "Success": success_url, "Fail": failure_url } }.to_json http.request(request) end |
#initialize_payment_assert_api(options = {}) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/saferpay_ruby.rb', line 56 def initialize_payment_assert_api( = {}) http = Net::HTTP.new(assert_endpoint.host, assert_endpoint.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE request = Net::HTTP::Post.new(assert_endpoint) request["content-type"] = 'application/json; charset=utf-8' request["accept"] = 'application/json' request["authorization"] = authentication request.body = { "RequestHeader": { "SpecVersion": "1.15", "CustomerId": customer_id, "RequestId": [:request_id], "RetryIndicator": 0 }, "Token": [:token] }.to_json http.request(request) end |