From 1f11b3ba894f4b2ac15197fb6af825fe4e11ba2d Mon Sep 17 00:00:00 2001 From: David Hrachovy Date: Sat, 19 Oct 2019 11:22:00 +0200 Subject: [PATCH] Version 0.4.0. Support multiple Gopay accounts Add Client & Gateway to handle multiple Gopay accounts Replace old unirest with rest-client Drop ruby support for versions <2.4 Update cassettes Add more Ruby versions to Travis --- .coveralls.yml | 1 + .gitignore | 3 +- .travis.yml | 7 +- Gemfile | 3 + README.md | 112 +++++++-- gopay.gemspec | 5 +- lib/gopay.rb | 56 +---- lib/gopay/client.rb | 67 ++++++ lib/gopay/gateway.rb | 25 ++ lib/gopay/payment.rb | 3 - lib/gopay/version.rb | 2 +- .../GoPay_Gateway/allows_to_switch_goid.yml | 225 ++++++++++++++++++ ...existing_payment_for_recurrent_payment.yml | 113 +++++++++ ..._existing_payment_for_standard_payment.yml | 113 +++++++++ .../refund/returns_existing_payment.yml | 111 +++++++++ ...rns_gopay_error_when_payment_not_found.yml | 110 +++++++++ .../retrieve/returns_existing_payment.yml | 115 +++++++++ ...rns_gopay_error_when_payment_not_found.yml | 110 +++++++++ .../returns_existing_payment.yml | 111 +++++++++ ...rns_gopay_error_when_payment_not_found.yml | 110 +++++++++ ...existing_payment_for_recurrent_payment.yml | 86 +++---- ..._existing_payment_for_standard_payment.yml | 83 +++---- .../refund/returns_existing_payment.yml | 75 +++--- ...rns_gopay_error_when_payment_not_found.yml | 72 +++--- .../retrieve/returns_existing_payment.yml | 91 +++---- ...rns_gopay_error_when_payment_not_found.yml | 76 +++--- .../returns_existing_payment.yml | 73 +++--- ...rns_gopay_error_when_payment_not_found.yml | 70 +++--- spec/gateway_spec.rb | 117 +++++++++ spec/{gopay_spec.rb => payment_spec.rb} | 28 ++- spec/spec_helper.rb | 20 +- 31 files changed, 1726 insertions(+), 467 deletions(-) create mode 100644 .coveralls.yml create mode 100644 lib/gopay/client.rb create mode 100644 lib/gopay/gateway.rb create mode 100644 spec/cassettes/GoPay_Gateway/allows_to_switch_goid.yml create mode 100644 spec/cassettes/GoPay_Gateway/create/returns_existing_payment_for_recurrent_payment.yml create mode 100644 spec/cassettes/GoPay_Gateway/create/returns_existing_payment_for_standard_payment.yml create mode 100644 spec/cassettes/GoPay_Gateway/refund/returns_existing_payment.yml create mode 100644 spec/cassettes/GoPay_Gateway/refund/returns_gopay_error_when_payment_not_found.yml create mode 100644 spec/cassettes/GoPay_Gateway/retrieve/returns_existing_payment.yml create mode 100644 spec/cassettes/GoPay_Gateway/retrieve/returns_gopay_error_when_payment_not_found.yml create mode 100644 spec/cassettes/GoPay_Gateway/void_recurrence/returns_existing_payment.yml create mode 100644 spec/cassettes/GoPay_Gateway/void_recurrence/returns_gopay_error_when_payment_not_found.yml create mode 100644 spec/gateway_spec.rb rename spec/{gopay_spec.rb => payment_spec.rb} (73%) diff --git a/.coveralls.yml b/.coveralls.yml new file mode 100644 index 0000000..6e64999 --- /dev/null +++ b/.coveralls.yml @@ -0,0 +1 @@ +service_name: travis-ci \ No newline at end of file diff --git a/.gitignore b/.gitignore index f813c9f..50ef2fd 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,5 @@ *.DS_Store .DS_Store *.gem -*.rbc \ No newline at end of file +*.rbc +.env \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 7b0e099..263fb25 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,11 +3,10 @@ cache: bundler language: ruby rvm: - - 2.0.0 - - 2.1 - - 2.2 - - 2.3 - 2.4 + - 2.5 + - 2.6 + - ruby-head sudo: false diff --git a/Gemfile b/Gemfile index e8b8f69..6b289c9 100644 --- a/Gemfile +++ b/Gemfile @@ -5,6 +5,9 @@ gem 'rspec' gem 'vcr' gem 'webmock' gem 'addressable' +gem 'dotenv' +gem "coveralls", require: false +gem "simplecov" # Specify your gem's dependencies in gopay-ruby.gemspec gemspec diff --git a/README.md b/README.md index f6b8a33..f8f07de 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,13 @@ [![Gem Version](https://badge.fury.io/rb/gopay-ruby.png)](http://badge.fury.io/rb/gopay-ruby) [![Build Status](https://travis-ci.org/PrimeHammer/gopay-ruby.png?branch=master)](https://travis-ci.org/PrimeHammer/gopay-ruby) -[![Dependency Status](https://gemnasium.com/PrimeHammer/gopay-ruby.png)](https://gemnasium.com/PrimeHammer/gopay-ruby) [![Code Climate](https://codeclimate.com/github/PrimeHammer/gopay-ruby.png)](https://codeclimate.com/github/PrimeHammer/gopay-ruby) +[![Coverage Status](https://coveralls.io/repos/github/PrimeHammer/gopay-ruby/badge.svg?branch=master)](https://coveralls.io/github/PrimeHammer/gopay-ruby?branch=master) The GoPay Ruby allows Ruby applications to access to the GoPay REST API. ## Benefits -It does OAuth authorization under the hood automatically. Easy configuration through initializer. +It does authorization under the hood automatically, supports multiple accounts. Easy configuration. ## Installation @@ -27,33 +27,30 @@ Or install it yourself as: $ gem install gopay-ruby -## Configure -The Gem is framework agnostic. However, if you use Rails, put the initializer in Rails config dir: -```ruby -config/initializers/gopay.rb -``` + + +## Usage + +### Gateway + +Before creating a payment, use Gateway object to configure your access to GoPay: ```ruby -GoPay.configure do |config| - config.goid = GOPAY_ID - config.client_id = GOPAY_CLIENT_ID - config.client_secret = GOPAY_SECRET - config.return_host = RETURN_HOST_URL - config.notification_host = NOTIFICATION_HOST_URL - config.gate = GATE_URL -end +gateway = GoPay::Gateway.new(gate: 'https://testgw.gopay.cz', goid: 123, client_id: 456, client_secret: 'xxx') ``` -## Usage +The values above are just examples. Note that you can use multiple Gateway objects to connect to different accounts. With one Gateway, you can do multiple requests. + ### Create a Payment -Before charging a user, we need to create a new payment. This will return a hash including a URL which you can use to popup payment modal or redirect the user to the GoPay payment page. + +Before charging a user, we need to create a new payment using our `gateway` object. The method will return a hash including a URL which you can use to popup payment modal or redirect the user to the GoPay payment page. ```ruby -GoPay::Payment.create payment_data +gateway.create payment_data ``` -### payment_data example +#### payment_data example ```ruby { @@ -77,7 +74,7 @@ GoPay::Payment.create payment_data } ``` -### Create a Payment response example +#### Response example This is a basic example of response hash, for more complex examples visit [GoPay API docs](https://doc.gopay.com). ```ruby { @@ -106,7 +103,7 @@ This is a basic example of response hash, for more complex examples visit [GoPay If you want to return a payment object from GoPay REST API. ```ruby -GoPay::Payment.retrieve gopay_id +gateway.retrieve gopay_id ``` ### Refund of the payment @@ -114,14 +111,14 @@ This functionality allows you to refund payment paid by a customer. You can use the refund in two ways. First option is a full refund payment and the other one is a partial refund. Both based on `amount` parameter. ```ruby -GoPay::Payment.refund gopay_id, amount +gateway.refund gopay_id, amount ``` ### Cancellation of the recurring payment The functionality allows you to cancel recurrence of a previously created recurring payment. ```ruby -GoPay::Payment.void_recurrence gopay_id +gateway.void_recurrence gopay_id ``` ## Dealing with errors @@ -130,13 +127,78 @@ You can easily catch errors in your models as shown below. ```ruby begin - response = GoPay::Payment.refund(gopay_id, gopay_amount) + response = gateway.refund(gopay_id, gopay_amount) rescue GoPay::Error => exception log_gopay_error exception end ``` -## Documentation + +## Testing + +Use these env variables in `.env` file: + +``` +GOPAY_GATE='https://testgw.gopay.cz' + +GOPAY_1_GOID=1111111111 +GOPAY_1_CLIENT_ID=1 +GOPAY_1_CLIENT_SECRET=x + +GOPAY_2_GOID=2222222222 +GOPAY_2_CLIENT_ID=2 +GOPAY_2_CLIENT_SECRET=x +``` + +Then run: + +```ruby +bundle exec rspec +``` + + +### Upgrading + +#### 0.4.0 + +In short, using `GoPay` class and `GoPay::Payment` was deprecated. + +Using `GoPay.configure` and `GoPay.request` is discouraged in favor of `Gateway` object. Instead of this: + +```ruby +GoPay.configure do |config| + config.goid = GOPAY_ID + config.client_id = GOPAY_CLIENT_ID + config.client_secret = GOPAY_SECRET + config.return_host = RETURN_HOST_URL + config.notification_host = NOTIFICATION_HOST_URL + config.gate = GATE_URL +end +``` + +please use `Gateway` object: + +```ruby +gateway = GoPay::Gateway.new(gate: GATE_URL, goid: GOPAY_ID, client_id: GOPAY_CLIENT_ID, client_secret: GOPAY_SECRET) +``` + +`return_host` and `notification_host` will be deprecated as well. + +Also `GoPay::Payment` will be deprecated. Instead of this: + +```ruby +GoPay::Payment.retrieve gopay_id +``` + +use `Gateway` for creating payments, retrieval, refunds: + +```ruby +gateway.retrieve gopay_id +``` + + + +## Full Documentation Parameters for all GoPay methods follow the official documentation. For further explanation please visit [GoPay API docs](https://doc.gopay.com). ## Contributing diff --git a/gopay.gemspec b/gopay.gemspec index 8d81cae..d774879 100644 --- a/gopay.gemspec +++ b/gopay.gemspec @@ -8,16 +8,15 @@ Gem::Specification.new do |spec| spec.version = GoPay::Version spec.authors = ["David Hrachovy & Ondrej Zadnik"] spec.email = ["david.hrachovy@gmail.com"] - spec.summary = %q{Unofficial wrapper for GoPay REST API} spec.description = %q{Unofficial wrapper for GoPay REST API} spec.homepage = "https://github.com/PrimeHammer/gopay-ruby" - spec.required_ruby_version = '>= 2.0' + spec.required_ruby_version = '>= 2.4' spec.license = "MIT" spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } spec.bindir = "exe" spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] spec.add_development_dependency "bundler" - spec.add_dependency 'unirest', '~> 1.1' + spec.add_dependency 'rest-client', '~> 2.1.0' end diff --git a/lib/gopay.rb b/lib/gopay.rb index 8529f3d..c14bd4b 100644 --- a/lib/gopay.rb +++ b/lib/gopay.rb @@ -1,4 +1,7 @@ +require 'gopay/client' require 'gopay/payment' +require 'gopay/gateway' +require 'gopay/error' module GoPay class << self @@ -10,56 +13,7 @@ def self.configure end def self.request(method, path, body_parameters: {}) - token = token get_token_scope(method, path) - content_type = get_content_type(path) - - body_parameters = content_type == 'application/json' ? body_parameters.to_json : from_hash_to_query(body_parameters) - - response = Unirest.send(method, GoPay.gate+path, headers: { "Accept" => "application/json", "Content-Type" => content_type, "Authorization" => "Bearer #{token}" }, parameters: body_parameters) - - unless response.code == 200 - raise GoPay::Error.handle_gopay_error(response) - end - - response.body - end - - class << self - private - - def get_token_scope(method, path) - if method == :post && path == '/api/payments/payment' - 'payment-create' - else - 'payment-all' - end - end - - def get_content_type(path) - if (path == '/api/payments/payment') || (path =~ /create-recurrence/) - 'application/json' - else - 'application/x-www-form-urlencoded' - end - end - - # payment-create - for new payment - # payment-all - for testing state etc - def token(scope = 'payment-create') - response = Unirest.post( - "#{gate}/api/oauth2/token", - headers: { - "Accept" => "application/json", - "Content-Type" => "application/x-www-form-urlencoded", - "Authorization" => "Basic #{Base64.encode64(client_id + ':' + client_secret)}" - }, - parameters: "grant_type=client_credentials&scope=#{scope}") - response.body["access_token"] - end - - def from_hash_to_query(hash) - hash = hash == "{}" ? "{}" : URI.escape(hash.collect { |key,val| "#{CGI.escape(key.to_s)}=#{CGI.escape(val.to_s)}" }.join('&')) - return hash - end + client = GoPay::Client.new({gate: gate, client_id: client_id, goid: goid, client_secret: client_secret}) + client.request(method, path, body_parameters: body_parameters) end end \ No newline at end of file diff --git a/lib/gopay/client.rb b/lib/gopay/client.rb new file mode 100644 index 0000000..0fe94e7 --- /dev/null +++ b/lib/gopay/client.rb @@ -0,0 +1,67 @@ +require 'rest-client' + +module GoPay + class Client + def initialize(config) + @config = config + end + + def request(method, path, body_parameters: {}) + token = token get_token_scope(method, path) + content_type = get_content_type(path) + + body_parameters = content_type == 'application/json' ? body_parameters.to_json : from_hash_to_query(body_parameters) + + begin + response = RestClient::Request.execute(method: method, url: @config[:gate]+path, payload: body_parameters, headers: { "Accept" => "application/json", "Content-Type" => content_type, "Authorization" => "Bearer #{token}" }) + rescue RestClient::ExceptionWithResponse => e + raise Error.handle_gopay_error(e.response) + end + + unless response.code == 200 + raise Error.handle_gopay_error(response) + end + + JSON.parse response.body + end + + private + + def get_token_scope(method, path) + if method == :post && path == '/api/payments/payment' + 'payment-create' + else + 'payment-all' + end + end + + def get_content_type(path) + if (path == '/api/payments/payment') || (path =~ /create-recurrence/) + 'application/json' + else + 'application/x-www-form-urlencoded' + end + end + + # payment-create - for new payment + # payment-all - for testing state etc + def token(scope = 'payment-create') + response = RestClient.post( + "#{@config[:gate]}/api/oauth2/token", + { grant_type: 'client_credentials', + scope: scope, + }, + { + "Accept" => "application/json", + "Content-Type" => "application/x-www-form-urlencoded", + "Authorization" => "Basic #{Base64.encode64(@config[:client_id] + ':' + @config[:client_secret])}" + }) + JSON.parse(response.body)["access_token"] + end + + def from_hash_to_query(hash) + hash = hash == "{}" ? "{}" : URI.escape(hash.collect { |key,val| "#{CGI.escape(key.to_s)}=#{CGI.escape(val.to_s)}" }.join('&')) + return hash + end + end +end \ No newline at end of file diff --git a/lib/gopay/gateway.rb b/lib/gopay/gateway.rb new file mode 100644 index 0000000..daf9594 --- /dev/null +++ b/lib/gopay/gateway.rb @@ -0,0 +1,25 @@ +module GoPay + class Gateway + def initialize(config) + @client = Client.new(config) + @goid = config[:goid] + end + + def create(payment_data) + target = { target: { type: "ACCOUNT", goid: @goid } } + @client.request :post, "/api/payments/payment", body_parameters: payment_data.merge(target) + end + + def retrieve(id) + @client.request :get, "/api/payments/payment/#{id}" + end + + def refund(id, amount) + @client.request :post, "/api/payments/payment/#{id}/refund", body_parameters: { amount: amount } + end + + def void_recurrence(id) + @client.request :post, "/api/payments/payment/#{id}/void-recurrence" + end + end +end \ No newline at end of file diff --git a/lib/gopay/payment.rb b/lib/gopay/payment.rb index fe2f8cc..e2df5b6 100644 --- a/lib/gopay/payment.rb +++ b/lib/gopay/payment.rb @@ -1,6 +1,3 @@ -require 'unirest' -require 'gopay/error' - module GoPay class Payment diff --git a/lib/gopay/version.rb b/lib/gopay/version.rb index 26aed04..79a8f61 100644 --- a/lib/gopay/version.rb +++ b/lib/gopay/version.rb @@ -1,7 +1,7 @@ module GoPay class Version MAJOR = 0 - MINOR = 3 + MINOR = 4 PATCH = 0 class << self diff --git a/spec/cassettes/GoPay_Gateway/allows_to_switch_goid.yml b/spec/cassettes/GoPay_Gateway/allows_to_switch_goid.yml new file mode 100644 index 0000000..ebaae1c --- /dev/null +++ b/spec/cassettes/GoPay_Gateway/allows_to_switch_goid.yml @@ -0,0 +1,225 @@ +--- +http_interactions: +- request: + method: post + uri: https://testgw.gopay.cz/api/oauth2/token + body: + encoding: UTF-8 + string: grant_type=client_credentials&scope=payment-all + headers: + Accept: + - application/json + User-Agent: + - rest-client/2.1.0 (darwin17.7.0 x86_64) ruby/2.5.3p105 + Content-Type: + - application/x-www-form-urlencoded + Authorization: + - "" + Content-Length: + - '47' + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Host: + - testgw.gopay.cz + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 19 Oct 2019 13:15:09 GMT + Server: + - Apache + Strict-Transport-Security: + - max-age=15552000; includeSubDomains; preload + Cache-Control: + - no-cache, no-store, must-revalidate, max-age=600 + X-Xss-Protection: + - 1; mode=block + X-Frame-Options: + - SAMEORIGIN + X-Content-Type-Options: + - nosniff + Content-Type: + - application/json + Set-Cookie: + - "" + Vary: + - Accept-Encoding + Expires: + - Sat, 19 Oct 2019 13:25:09 GMT + Content-Length: + - '272' + body: + encoding: ASCII-8BIT + string: '{"token_type":"bearer","access_token":"50zWjt02ZOYvq7XAT0WNKc1I8VRK0YDaeuI4RtWOvdHsga8YYL5H1gcICbqFSSIYDxmSB8o79zYUmaL59NJbf30u5G2MgzryNlng1UK5l1g=","expires_in":1800,"refresh_token":"qDJkFs5IuBeOb3Oen9uP9YP7wtpvDp3qx6kKBxW9USRkm9dyZZdG19/hN7p0tsyyYOhQ6P29vYNynTQsbrj3M2IhGrQcCQizyT3Swyq6p74="}' + http_version: + recorded_at: Sat, 19 Oct 2019 13:15:09 GMT +- request: + method: get + uri: https://testgw.gopay.cz/api/payments/payment/3090060402 + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - application/json + User-Agent: + - rest-client/2.1.0 (darwin17.7.0 x86_64) ruby/2.5.3p105 + Content-Type: + - application/x-www-form-urlencoded + Authorization: + - "" + Content-Length: + - '0' + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Host: + - testgw.gopay.cz + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 19 Oct 2019 13:15:10 GMT + Server: + - Apache + Strict-Transport-Security: + - max-age=15552000; includeSubDomains; preload + Cache-Control: + - no-cache, no-store, must-revalidate, max-age=600 + X-Xss-Protection: + - 1; mode=block + X-Frame-Options: + - SAMEORIGIN + X-Content-Type-Options: + - nosniff + Content-Type: + - application/json + Set-Cookie: + - "" + Vary: + - Accept-Encoding + Expires: + - Sat, 19 Oct 2019 13:25:10 GMT + Content-Length: + - '402' + body: + encoding: ASCII-8BIT + string: '{"id":3090060402,"order_number":"order-1","state":"REFUNDED","payment_instrument":"PAYMENT_CARD","amount":10000,"currency":"CZK","payer":{"allowed_payment_instruments":["PAYMENT_CARD"],"payment_card":{"card_number":"418803******0003","card_expiration":"2112","card_brand":"VISA + Electron","card_issuer_country":"CZE","card_issuer_bank":"KOMERCNI BANKA, + A.S."},"contact":{"first_name":"John","last_name":"Doe","email":"john@example.com","country_code":"CZE"}},"target":{"type":"ACCOUNT","goid":1111111111},"lang":"cs","gw_url":"https://gw.sandbox.gopay.com/gw/v3/95c24246256a19e1f4903d18a5cb9c31"}' + http_version: + recorded_at: Sat, 19 Oct 2019 13:15:10 GMT +- request: + method: post + uri: https://testgw.gopay.cz/api/oauth2/token + body: + encoding: UTF-8 + string: grant_type=client_credentials&scope=payment-all + headers: + Accept: + - application/json + User-Agent: + - rest-client/2.1.0 (darwin17.7.0 x86_64) ruby/2.5.3p105 + Content-Type: + - application/x-www-form-urlencoded + Authorization: + - "" + Content-Length: + - '47' + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Host: + - testgw.gopay.cz + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 19 Oct 2019 13:15:10 GMT + Server: + - Apache + Strict-Transport-Security: + - max-age=15552000; includeSubDomains; preload + Cache-Control: + - no-cache, no-store, must-revalidate, max-age=600 + X-Xss-Protection: + - 1; mode=block + X-Frame-Options: + - SAMEORIGIN + X-Content-Type-Options: + - nosniff + Content-Type: + - application/json + Set-Cookie: + - "" + Vary: + - Accept-Encoding + Expires: + - Sat, 19 Oct 2019 13:25:10 GMT + Content-Length: + - '273' + body: + encoding: ASCII-8BIT + string: '{"token_type":"bearer","access_token":"9LUrP9kksluCuCt44hvxEaya6ESYT7sdnhSf3dtvcsFu6rsTYwnP2PbN2vbtnWRwsoKNcwwKd3+H7m/ZzBPRgduF8N2vDqWaaJOpbCZKH/E=","expires_in":1800,"refresh_token":"0DoZRHAIHG/krvd/7ZqU0cX3TYMV2GvhanYoAjVHjHRTm17O0qTHeSUzh7OofKP0Jrk1y8biGC/eqvRKZ3E+MZRVH810MPRUfzwYZ1Yx930="}' + http_version: + recorded_at: Sat, 19 Oct 2019 13:15:10 GMT +- request: + method: get + uri: https://testgw.gopay.cz/api/payments/payment/3088999875 + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - application/json + User-Agent: + - rest-client/2.1.0 (darwin17.7.0 x86_64) ruby/2.5.3p105 + Content-Type: + - application/x-www-form-urlencoded + Authorization: + - "" + Content-Length: + - '0' + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Host: + - testgw.gopay.cz + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 19 Oct 2019 13:15:10 GMT + Server: + - Apache + Strict-Transport-Security: + - max-age=15552000; includeSubDomains; preload + Cache-Control: + - no-cache, no-store, must-revalidate, max-age=600 + X-Xss-Protection: + - 1; mode=block + X-Frame-Options: + - SAMEORIGIN + X-Content-Type-Options: + - nosniff + Content-Type: + - application/json + Set-Cookie: + - "" + Vary: + - Accept-Encoding + Expires: + - Sat, 19 Oct 2019 13:25:10 GMT + Content-Length: + - '667' + body: + encoding: ASCII-8BIT + string: '{"id":3088999875,"parent_id":3083563977,"order_number":"order-37831","state":"PAID","payment_instrument":"PAYMENT_CARD","amount":1900,"currency":"EUR","payer":{"contact":{"first_name":"Test","last_name":"gopay","email":"david@example.com","country_code":"SVK"}},"target":{"type":"ACCOUNT","goid":2222222222},"lang":"sk","gw_url":"https://gw.sandbox.gopay.com/gw/v3/5a0319fc8ad0886026c65d5a69864933","eet_code":{"fik":"26145fe2-ff99-4651-a635-46bcf8efebed-ff","bkp":"C6D90A9B-2319EE46-A97DE7FF-6FAA02D5-BEE0BFB5","pkp":"OQ6W8W4TGEu0dv396OU7GMcz3v+WVueUaSK93SDZHiW6c0AieqtqumXG3QxHxWRUZ2u3iVnrUoQ3zmHFzBgfCHQAfCq9COmOWhRZSljaWWmkPZ1ZWl2xOb3x3lNt3Mx3++wX4L7+Yvzmpb+fZo/4LUnIJ/zkFqC7GzvFUjCifdIdXl4RqFoukwVXHKYgUu9JCPJskGLjNgnftGZnWZsFlUjnkUSLL5m51A35wR1EGQop+x+X55Q1ptwNfbBvyO+hOl+6qj9ofy+ziT04FCEfmyAzvYxIRiD18qeJtAzV+R/e2ojSMte4WzwEOwDYlmDGPbp08DCPMi956tHqr3IJ8g=="}}' + http_version: + recorded_at: Sat, 19 Oct 2019 13:15:10 GMT +recorded_with: VCR 5.0.0 diff --git a/spec/cassettes/GoPay_Gateway/create/returns_existing_payment_for_recurrent_payment.yml b/spec/cassettes/GoPay_Gateway/create/returns_existing_payment_for_recurrent_payment.yml new file mode 100644 index 0000000..f9291f6 --- /dev/null +++ b/spec/cassettes/GoPay_Gateway/create/returns_existing_payment_for_recurrent_payment.yml @@ -0,0 +1,113 @@ +--- +http_interactions: +- request: + method: post + uri: https://testgw.gopay.cz/api/oauth2/token + body: + encoding: UTF-8 + string: grant_type=client_credentials&scope=payment-create + headers: + Accept: + - application/json + User-Agent: + - rest-client/2.1.0 (darwin17.7.0 x86_64) ruby/2.5.3p105 + Content-Type: + - application/x-www-form-urlencoded + Authorization: + - "" + Content-Length: + - '50' + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Host: + - testgw.gopay.cz + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 19 Oct 2019 13:12:23 GMT + Server: + - Apache + Strict-Transport-Security: + - max-age=15552000; includeSubDomains; preload + Cache-Control: + - no-cache, no-store, must-revalidate, max-age=600 + X-Xss-Protection: + - 1; mode=block + X-Frame-Options: + - SAMEORIGIN + X-Content-Type-Options: + - nosniff + Content-Type: + - application/json + Set-Cookie: + - "" + Vary: + - Accept-Encoding + Expires: + - Sat, 19 Oct 2019 13:22:23 GMT + Content-Length: + - '272' + body: + encoding: ASCII-8BIT + string: '{"token_type":"bearer","access_token":"s+0cdiWpXXS2S/VQCh9xZNgBYQtLQceMVLOJlVtxYWcRvixTP/0cpKH3YdtgNQFrO4Fj2tdNFhjm4Hl5oS1Osmsga4025/yVG3CCktDjwec=","expires_in":1800,"refresh_token":"SxlCUpDjbtqBolwY0aK8L7goM3wUFzmbi2+yCxCaJWFXs54R4VVPiyzi+KjyDImCzJHVcHEJd09DrUJfzAkpZjUWRlvKcJ9cWPVO+e9mWTQ="}' + http_version: + recorded_at: Sat, 19 Oct 2019 13:12:23 GMT +- request: + method: post + uri: https://testgw.gopay.cz/api/payments/payment + body: + encoding: UTF-8 + string: '{"payer":{"allowed_payment_instruments":["PAYMENT_CARD"],"contact":{"first_name":"John","last_name":"Doe","email":"john@example.com"}},"amount":10000,"currency":"CZK","order_number":"order-1","order_description":"foo","lang":"CS","callback":{"return_url":"http://localhost","notification_url":"http://localhost/2"},"recurrence":{"recurrence_cycle":"WEEK","recurrence_period":10,"recurrence_date_to":"2050-01-01"},"target":{"type":"ACCOUNT","goid":"1111111111"}}' + headers: + Accept: + - application/json + User-Agent: + - rest-client/2.1.0 (darwin17.7.0 x86_64) ruby/2.5.3p105 + Content-Type: + - application/json + Authorization: + - "" + Content-Length: + - '461' + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Host: + - testgw.gopay.cz + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 19 Oct 2019 13:12:23 GMT + Server: + - Apache + Strict-Transport-Security: + - max-age=15552000; includeSubDomains; preload + Cache-Control: + - no-cache, no-store, must-revalidate, max-age=600 + X-Xss-Protection: + - 1; mode=block + X-Frame-Options: + - SAMEORIGIN + X-Content-Type-Options: + - nosniff + Content-Type: + - application/json + Set-Cookie: + - "" + Vary: + - Accept-Encoding + Expires: + - Sat, 19 Oct 2019 13:22:23 GMT + Content-Length: + - '348' + body: + encoding: ASCII-8BIT + string: '{"id":3090066941,"order_number":"order-1","state":"CREATED","amount":10000,"currency":"CZK","payer":{"allowed_payment_instruments":["PAYMENT_CARD"],"contact":{"first_name":"John","last_name":"Doe","email":"john@example.com"}},"target":{"type":"ACCOUNT","goid":1111111111},"recurrence":{"recurrence_cycle":"WEEK","recurrence_period":10,"recurrence_date_to":"2050-01-01","recurrence_state":"REQUESTED"},"lang":"cs","gw_url":"https://gw.sandbox.gopay.com/gw/v3/0bd5bc9c9ab85f347564f9eb8fb0b2a3"}' + http_version: + recorded_at: Sat, 19 Oct 2019 13:12:23 GMT +recorded_with: VCR 5.0.0 diff --git a/spec/cassettes/GoPay_Gateway/create/returns_existing_payment_for_standard_payment.yml b/spec/cassettes/GoPay_Gateway/create/returns_existing_payment_for_standard_payment.yml new file mode 100644 index 0000000..c0ce6d4 --- /dev/null +++ b/spec/cassettes/GoPay_Gateway/create/returns_existing_payment_for_standard_payment.yml @@ -0,0 +1,113 @@ +--- +http_interactions: +- request: + method: post + uri: https://testgw.gopay.cz/api/oauth2/token + body: + encoding: UTF-8 + string: grant_type=client_credentials&scope=payment-create + headers: + Accept: + - application/json + User-Agent: + - rest-client/2.1.0 (darwin17.7.0 x86_64) ruby/2.5.3p105 + Content-Type: + - application/x-www-form-urlencoded + Authorization: + - "" + Content-Length: + - '50' + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Host: + - testgw.gopay.cz + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 19 Oct 2019 13:27:21 GMT + Server: + - Apache + Strict-Transport-Security: + - max-age=15552000; includeSubDomains; preload + Cache-Control: + - no-cache, no-store, must-revalidate, max-age=600 + X-Xss-Protection: + - 1; mode=block + X-Frame-Options: + - SAMEORIGIN + X-Content-Type-Options: + - nosniff + Content-Type: + - application/json + Set-Cookie: + - "" + Vary: + - Accept-Encoding + Expires: + - Sat, 19 Oct 2019 13:37:21 GMT + Content-Length: + - '271' + body: + encoding: ASCII-8BIT + string: '{"token_type":"bearer","access_token":"johO6hfbyH96q3xHZoaLaOaZ6fDeLZy2ovxUBppZJzu6A5Wpgb6Z4XXpvW57RvihisqyQnJf4C7QhXEZUT6LxI7Z/2Fiyr5wXwhfUhXlKNA=","expires_in":1800,"refresh_token":"BaeTjmEUR9eTSfejKvMmhXPiGVQQv90qcGTHmgyOmGWoB0LhN54ybcdk77r7b8gK3AEBawt00tOBe9YWRy4VXGXjl4pt/jpeZ0XTe4sprRY="}' + http_version: + recorded_at: Sat, 19 Oct 2019 13:27:21 GMT +- request: + method: post + uri: https://testgw.gopay.cz/api/payments/payment + body: + encoding: UTF-8 + string: '{"payer":{"allowed_payment_instruments":["PAYMENT_CARD"],"contact":{"first_name":"John","last_name":"Doe","email":"john@example.com"}},"amount":10000,"currency":"CZK","order_number":"order-1","order_description":"foo","lang":"CS","callback":{"return_url":"http://localhost","notification_url":"http://localhost/2"},"target":{"type":"ACCOUNT","goid":"1111111111"}}' + headers: + Accept: + - application/json + User-Agent: + - rest-client/2.1.0 (darwin17.7.0 x86_64) ruby/2.5.3p105 + Content-Type: + - application/json + Authorization: + - "" + Content-Length: + - '363' + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Host: + - testgw.gopay.cz + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 19 Oct 2019 13:27:21 GMT + Server: + - Apache + Strict-Transport-Security: + - max-age=15552000; includeSubDomains; preload + Cache-Control: + - no-cache, no-store, must-revalidate, max-age=600 + X-Xss-Protection: + - 1; mode=block + X-Frame-Options: + - SAMEORIGIN + X-Content-Type-Options: + - nosniff + Content-Type: + - application/json + Set-Cookie: + - "" + Vary: + - Accept-Encoding + Expires: + - Sat, 19 Oct 2019 13:37:21 GMT + Content-Length: + - '291' + body: + encoding: ASCII-8BIT + string: '{"id":3090066980,"order_number":"order-1","state":"CREATED","amount":10000,"currency":"CZK","payer":{"allowed_payment_instruments":["PAYMENT_CARD"],"contact":{"first_name":"John","last_name":"Doe","email":"john@example.com"}},"target":{"type":"ACCOUNT","goid":1111111111},"lang":"cs","gw_url":"https://gw.sandbox.gopay.com/gw/v3/583d98f8dfadbd7289fb49ab6da95d43"}' + http_version: + recorded_at: Sat, 19 Oct 2019 13:27:22 GMT +recorded_with: VCR 5.0.0 diff --git a/spec/cassettes/GoPay_Gateway/refund/returns_existing_payment.yml b/spec/cassettes/GoPay_Gateway/refund/returns_existing_payment.yml new file mode 100644 index 0000000..393f9be --- /dev/null +++ b/spec/cassettes/GoPay_Gateway/refund/returns_existing_payment.yml @@ -0,0 +1,111 @@ +--- +http_interactions: +- request: + method: post + uri: https://testgw.gopay.cz/api/oauth2/token + body: + encoding: UTF-8 + string: grant_type=client_credentials&scope=payment-all + headers: + Accept: + - application/json + User-Agent: + - rest-client/2.1.0 (darwin17.7.0 x86_64) ruby/2.5.3p105 + Content-Type: + - application/x-www-form-urlencoded + Authorization: + - "" + Content-Length: + - '47' + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Host: + - testgw.gopay.cz + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 19 Oct 2019 13:31:08 GMT + Server: + - Apache + Strict-Transport-Security: + - max-age=15552000; includeSubDomains; preload + Cache-Control: + - no-cache, no-store, must-revalidate, max-age=600 + X-Xss-Protection: + - 1; mode=block + X-Frame-Options: + - SAMEORIGIN + X-Content-Type-Options: + - nosniff + Content-Type: + - application/json + Set-Cookie: + - "" + Vary: + - Accept-Encoding + Expires: + - Sat, 19 Oct 2019 13:41:08 GMT + Content-Length: + - '273' + body: + encoding: ASCII-8BIT + string: '{"token_type":"bearer","access_token":"+OU0d15ZEsrxSzoGtQ6eEi2sRfmlgQCvJi1oRuyhR/b3dK5wjBiVcmNHpQ9f/LCuPlOGSSTAfzU/HPRl7H75SdsPzU6/JcuIL7l5Vv0EBPk=","expires_in":1800,"refresh_token":"OrFGe5gJW4subUP9pMT3dBSPdIVjdfeu4zghj2+O2buhCjkFVCk1Ly5PD83S5GDjO+Hy653N62NqWZCh3Id415092pWIgYM7rYoSNmuNZP0="}' + http_version: + recorded_at: Sat, 19 Oct 2019 13:31:08 GMT +- request: + method: post + uri: https://testgw.gopay.cz/api/payments/payment/3090066980/refund + body: + encoding: US-ASCII + string: amount=10000 + headers: + Accept: + - application/json + User-Agent: + - rest-client/2.1.0 (darwin17.7.0 x86_64) ruby/2.5.3p105 + Content-Type: + - application/x-www-form-urlencoded + Authorization: + - "" + Content-Length: + - '12' + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Host: + - testgw.gopay.cz + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 19 Oct 2019 13:31:35 GMT + Server: + - Apache + Strict-Transport-Security: + - max-age=15552000; includeSubDomains; preload + Cache-Control: + - no-cache, no-store, must-revalidate, max-age=600 + X-Xss-Protection: + - 1; mode=block + X-Frame-Options: + - SAMEORIGIN + X-Content-Type-Options: + - nosniff + Content-Type: + - application/json + Content-Length: + - '37' + Set-Cookie: + - "" + Expires: + - Sat, 19 Oct 2019 13:41:08 GMT + body: + encoding: UTF-8 + string: '{"id":3090066980,"result":"FINISHED"}' + http_version: + recorded_at: Sat, 19 Oct 2019 13:31:35 GMT +recorded_with: VCR 5.0.0 diff --git a/spec/cassettes/GoPay_Gateway/refund/returns_gopay_error_when_payment_not_found.yml b/spec/cassettes/GoPay_Gateway/refund/returns_gopay_error_when_payment_not_found.yml new file mode 100644 index 0000000..23efa31 --- /dev/null +++ b/spec/cassettes/GoPay_Gateway/refund/returns_gopay_error_when_payment_not_found.yml @@ -0,0 +1,110 @@ +--- +http_interactions: +- request: + method: post + uri: https://testgw.gopay.cz/api/oauth2/token + body: + encoding: UTF-8 + string: grant_type=client_credentials&scope=payment-all + headers: + Accept: + - application/json + User-Agent: + - rest-client/2.1.0 (darwin17.7.0 x86_64) ruby/2.5.3p105 + Content-Type: + - application/x-www-form-urlencoded + Authorization: + - "" + Content-Length: + - '47' + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Host: + - testgw.gopay.cz + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 19 Oct 2019 13:27:03 GMT + Server: + - Apache + Strict-Transport-Security: + - max-age=15552000; includeSubDomains; preload + Cache-Control: + - no-cache, no-store, must-revalidate, max-age=600 + X-Xss-Protection: + - 1; mode=block + X-Frame-Options: + - SAMEORIGIN + X-Content-Type-Options: + - nosniff + Content-Type: + - application/json + Set-Cookie: + - "" + Vary: + - Accept-Encoding + Expires: + - Sat, 19 Oct 2019 13:37:02 GMT + Content-Length: + - '272' + body: + encoding: ASCII-8BIT + string: '{"token_type":"bearer","access_token":"i17vPYovs35pICatxguD00dz0tLsqJIGI5psTNGR0y3Rh0EqMmPtnXGTI6sgSzkwTgYyUsWyBV5RnFm63mwP5Z0kMaBh/tPIdf75WYe4LdU=","expires_in":1800,"refresh_token":"gt2/XaSzQo7e3KfKqRwVIHwRhdBQmGMH2jplN0RU7crp4uDq04PR/RDqcrmlLFC4U+KRDefg4FYg3rVrt/yxIEHunCUXj7OKIcNxU4ynBFA="}' + http_version: + recorded_at: Sat, 19 Oct 2019 13:27:03 GMT +- request: + method: post + uri: https://testgw.gopay.cz/api/payments/payment/100/refund + body: + encoding: US-ASCII + string: amount=100 + headers: + Accept: + - application/json + User-Agent: + - rest-client/2.1.0 (darwin17.7.0 x86_64) ruby/2.5.3p105 + Content-Type: + - application/x-www-form-urlencoded + Authorization: + - "" + Content-Length: + - '10' + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Host: + - testgw.gopay.cz + response: + status: + code: 409 + message: Conflict + headers: + Date: + - Sat, 19 Oct 2019 13:27:03 GMT + Server: + - Apache + Strict-Transport-Security: + - max-age=15552000; includeSubDomains; preload + Cache-Control: + - no-cache, no-store, must-revalidate + X-Xss-Protection: + - 1; mode=block + X-Frame-Options: + - SAMEORIGIN + X-Content-Type-Options: + - nosniff + Content-Type: + - application/json + Content-Length: + - '149' + Set-Cookie: + - "" + body: + encoding: UTF-8 + string: '{"date_issued":"2019-10-19T15:27:03.132+0200","errors":[{"scope":"F","field":"id","error_code":111,"error_name":"INVALID","message":"Wrong + value."}]}' + http_version: + recorded_at: Sat, 19 Oct 2019 13:27:03 GMT +recorded_with: VCR 5.0.0 diff --git a/spec/cassettes/GoPay_Gateway/retrieve/returns_existing_payment.yml b/spec/cassettes/GoPay_Gateway/retrieve/returns_existing_payment.yml new file mode 100644 index 0000000..3232943 --- /dev/null +++ b/spec/cassettes/GoPay_Gateway/retrieve/returns_existing_payment.yml @@ -0,0 +1,115 @@ +--- +http_interactions: +- request: + method: post + uri: https://testgw.gopay.cz/api/oauth2/token + body: + encoding: UTF-8 + string: grant_type=client_credentials&scope=payment-all + headers: + Accept: + - application/json + User-Agent: + - rest-client/2.1.0 (darwin17.7.0 x86_64) ruby/2.5.3p105 + Content-Type: + - application/x-www-form-urlencoded + Authorization: + - "" + Content-Length: + - '47' + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Host: + - testgw.gopay.cz + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 19 Oct 2019 13:12:33 GMT + Server: + - Apache + Strict-Transport-Security: + - max-age=15552000; includeSubDomains; preload + Cache-Control: + - no-cache, no-store, must-revalidate, max-age=600 + X-Xss-Protection: + - 1; mode=block + X-Frame-Options: + - SAMEORIGIN + X-Content-Type-Options: + - nosniff + Content-Type: + - application/json + Set-Cookie: + - "" + Vary: + - Accept-Encoding + Expires: + - Sat, 19 Oct 2019 13:22:33 GMT + Content-Length: + - '272' + body: + encoding: ASCII-8BIT + string: '{"token_type":"bearer","access_token":"TXrkmyOJvZ8CQeoru8eIbuvwmrJ4TYGVNVq5JcLYCa47HhODPqk6tPkggCXIbqqkn8RrNz5lkRNZhDaZYfPKbuRXmAZBlgRlx4xvUaw/q68=","expires_in":1800,"refresh_token":"Fv9uD0bAyNjMEhI1gZer0SYwO3+dkURtInF4D07pyNljBmr0VwCtU0uDD5+3+Is/IuF9zOe0r59CWSmUzoAIi8BRAxyC7FTOC7YePiYgULc="}' + http_version: + recorded_at: Sat, 19 Oct 2019 13:12:33 GMT +- request: + method: get + uri: https://testgw.gopay.cz/api/payments/payment/3090060402 + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - application/json + User-Agent: + - rest-client/2.1.0 (darwin17.7.0 x86_64) ruby/2.5.3p105 + Content-Type: + - application/x-www-form-urlencoded + Authorization: + - "" + Content-Length: + - '0' + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Host: + - testgw.gopay.cz + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 19 Oct 2019 13:12:33 GMT + Server: + - Apache + Strict-Transport-Security: + - max-age=15552000; includeSubDomains; preload + Cache-Control: + - no-cache, no-store, must-revalidate, max-age=600 + X-Xss-Protection: + - 1; mode=block + X-Frame-Options: + - SAMEORIGIN + X-Content-Type-Options: + - nosniff + Content-Type: + - application/json + Set-Cookie: + - "" + Vary: + - Accept-Encoding + Expires: + - Sat, 19 Oct 2019 13:22:33 GMT + Content-Length: + - '402' + body: + encoding: ASCII-8BIT + string: '{"id":3090060402,"order_number":"order-1","state":"REFUNDED","payment_instrument":"PAYMENT_CARD","amount":10000,"currency":"CZK","payer":{"allowed_payment_instruments":["PAYMENT_CARD"],"payment_card":{"card_number":"418803******0003","card_expiration":"2112","card_brand":"VISA + Electron","card_issuer_country":"CZE","card_issuer_bank":"KOMERCNI BANKA, + A.S."},"contact":{"first_name":"John","last_name":"Doe","email":"john@example.com","country_code":"CZE"}},"target":{"type":"ACCOUNT","goid":1111111111},"lang":"cs","gw_url":"https://gw.sandbox.gopay.com/gw/v3/95c24246256a19e1f4903d18a5cb9c31"}' + http_version: + recorded_at: Sat, 19 Oct 2019 13:12:33 GMT +recorded_with: VCR 5.0.0 diff --git a/spec/cassettes/GoPay_Gateway/retrieve/returns_gopay_error_when_payment_not_found.yml b/spec/cassettes/GoPay_Gateway/retrieve/returns_gopay_error_when_payment_not_found.yml new file mode 100644 index 0000000..6dafb4d --- /dev/null +++ b/spec/cassettes/GoPay_Gateway/retrieve/returns_gopay_error_when_payment_not_found.yml @@ -0,0 +1,110 @@ +--- +http_interactions: +- request: + method: post + uri: https://testgw.gopay.cz/api/oauth2/token + body: + encoding: UTF-8 + string: grant_type=client_credentials&scope=payment-all + headers: + Accept: + - application/json + User-Agent: + - rest-client/2.1.0 (darwin17.7.0 x86_64) ruby/2.5.3p105 + Content-Type: + - application/x-www-form-urlencoded + Authorization: + - "" + Content-Length: + - '47' + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Host: + - testgw.gopay.cz + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 19 Oct 2019 13:12:33 GMT + Server: + - Apache + Strict-Transport-Security: + - max-age=15552000; includeSubDomains; preload + Cache-Control: + - no-cache, no-store, must-revalidate, max-age=600 + X-Xss-Protection: + - 1; mode=block + X-Frame-Options: + - SAMEORIGIN + X-Content-Type-Options: + - nosniff + Content-Type: + - application/json + Set-Cookie: + - "" + Vary: + - Accept-Encoding + Expires: + - Sat, 19 Oct 2019 13:22:33 GMT + Content-Length: + - '272' + body: + encoding: ASCII-8BIT + string: '{"token_type":"bearer","access_token":"l6NUrVG9CP83bbjFf4LqQwDW19DvoHykQhfAybajSKWlKQljm1igHUgdZc9oMYIkjphTqV9ULBYbBko8/FDin0AeGRE6KK1cN8a1GNMe2Gg=","expires_in":1800,"refresh_token":"jIb58aRnwkYR4E131G37kJon/E6fV2JmURb8gXA2oypEp9GhTRfV+9QszbOD1xJodrCDQzWFM51rOxT5Fr11vh/CEHN5Tnz6kiOpg3eP57g="}' + http_version: + recorded_at: Sat, 19 Oct 2019 13:12:34 GMT +- request: + method: get + uri: https://testgw.gopay.cz/api/payments/payment/100 + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - application/json + User-Agent: + - rest-client/2.1.0 (darwin17.7.0 x86_64) ruby/2.5.3p105 + Content-Type: + - application/x-www-form-urlencoded + Authorization: + - "" + Content-Length: + - '0' + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Host: + - testgw.gopay.cz + response: + status: + code: 404 + message: Not Found + headers: + Date: + - Sat, 19 Oct 2019 13:12:34 GMT + Server: + - Apache + Strict-Transport-Security: + - max-age=15552000; includeSubDomains; preload + Cache-Control: + - no-cache, no-store, must-revalidate + X-Xss-Protection: + - 1; mode=block + X-Frame-Options: + - SAMEORIGIN + X-Content-Type-Options: + - nosniff + Content-Type: + - application/json + Content-Length: + - '152' + Set-Cookie: + - "" + body: + encoding: UTF-8 + string: '{"date_issued":"2019-10-19T15:12:34.174+0200","errors":[{"scope":"G","error_code":304,"error_name":"PAYMENT_NOT_FOUND","message":"Payment + not found."}]}' + http_version: + recorded_at: Sat, 19 Oct 2019 13:12:34 GMT +recorded_with: VCR 5.0.0 diff --git a/spec/cassettes/GoPay_Gateway/void_recurrence/returns_existing_payment.yml b/spec/cassettes/GoPay_Gateway/void_recurrence/returns_existing_payment.yml new file mode 100644 index 0000000..3d755aa --- /dev/null +++ b/spec/cassettes/GoPay_Gateway/void_recurrence/returns_existing_payment.yml @@ -0,0 +1,111 @@ +--- +http_interactions: +- request: + method: post + uri: https://testgw.gopay.cz/api/oauth2/token + body: + encoding: UTF-8 + string: grant_type=client_credentials&scope=payment-all + headers: + Accept: + - application/json + User-Agent: + - rest-client/2.1.0 (darwin17.7.0 x86_64) ruby/2.5.3p105 + Content-Type: + - application/x-www-form-urlencoded + Authorization: + - "" + Content-Length: + - '47' + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Host: + - testgw.gopay.cz + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 19 Oct 2019 13:27:03 GMT + Server: + - Apache + Strict-Transport-Security: + - max-age=15552000; includeSubDomains; preload + Cache-Control: + - no-cache, no-store, must-revalidate, max-age=600 + X-Xss-Protection: + - 1; mode=block + X-Frame-Options: + - SAMEORIGIN + X-Content-Type-Options: + - nosniff + Content-Type: + - application/json + Set-Cookie: + - "" + Vary: + - Accept-Encoding + Expires: + - Sat, 19 Oct 2019 13:37:03 GMT + Content-Length: + - '272' + body: + encoding: ASCII-8BIT + string: '{"token_type":"bearer","access_token":"CnCyepDbxO5Hbasp4N2doMfqhYpedXPqtZVwZ5DG0dYGh020BvXmpCSsUPpizlRW6hGjlJ4EnFI+BNEPzLfuMzS5iX+6c4AEko2B+bUR3qk=","expires_in":1800,"refresh_token":"XSRU53IkzBwiBQzl6NQdaTCqokP6A/F2WWCiYQltYa5IcgW4z+zvDWRyVBnNftnimFyd1dLDMp3LMCjSxv8iwe0xM27vsRLmnF9VPdopbiQ="}' + http_version: + recorded_at: Sat, 19 Oct 2019 13:27:03 GMT +- request: + method: post + uri: https://testgw.gopay.cz/api/payments/payment/3090066941/void-recurrence + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - application/json + User-Agent: + - rest-client/2.1.0 (darwin17.7.0 x86_64) ruby/2.5.3p105 + Content-Type: + - application/x-www-form-urlencoded + Authorization: + - "" + Content-Length: + - '0' + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Host: + - testgw.gopay.cz + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 19 Oct 2019 13:27:03 GMT + Server: + - Apache + Strict-Transport-Security: + - max-age=15552000; includeSubDomains; preload + Cache-Control: + - no-cache, no-store, must-revalidate, max-age=600 + X-Xss-Protection: + - 1; mode=block + X-Frame-Options: + - SAMEORIGIN + X-Content-Type-Options: + - nosniff + Content-Type: + - application/json + Content-Length: + - '37' + Set-Cookie: + - "" + Expires: + - Sat, 19 Oct 2019 13:37:03 GMT + body: + encoding: UTF-8 + string: '{"id":3090066941,"result":"FINISHED"}' + http_version: + recorded_at: Sat, 19 Oct 2019 13:27:03 GMT +recorded_with: VCR 5.0.0 diff --git a/spec/cassettes/GoPay_Gateway/void_recurrence/returns_gopay_error_when_payment_not_found.yml b/spec/cassettes/GoPay_Gateway/void_recurrence/returns_gopay_error_when_payment_not_found.yml new file mode 100644 index 0000000..6d0e6ca --- /dev/null +++ b/spec/cassettes/GoPay_Gateway/void_recurrence/returns_gopay_error_when_payment_not_found.yml @@ -0,0 +1,110 @@ +--- +http_interactions: +- request: + method: post + uri: https://testgw.gopay.cz/api/oauth2/token + body: + encoding: UTF-8 + string: grant_type=client_credentials&scope=payment-all + headers: + Accept: + - application/json + User-Agent: + - rest-client/2.1.0 (darwin17.7.0 x86_64) ruby/2.5.3p105 + Content-Type: + - application/x-www-form-urlencoded + Authorization: + - "" + Content-Length: + - '47' + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Host: + - testgw.gopay.cz + response: + status: + code: 200 + message: OK + headers: + Date: + - Sat, 19 Oct 2019 13:27:03 GMT + Server: + - Apache + Strict-Transport-Security: + - max-age=15552000; includeSubDomains; preload + Cache-Control: + - no-cache, no-store, must-revalidate, max-age=600 + X-Xss-Protection: + - 1; mode=block + X-Frame-Options: + - SAMEORIGIN + X-Content-Type-Options: + - nosniff + Content-Type: + - application/json + Set-Cookie: + - "" + Vary: + - Accept-Encoding + Expires: + - Sat, 19 Oct 2019 13:37:03 GMT + Content-Length: + - '273' + body: + encoding: ASCII-8BIT + string: '{"token_type":"bearer","access_token":"WY3CSu2mITqwXseDj/pazhNx4cEi6wLWPFbv12xBgRF84fzD7hubeJeiVTsKaxXXa9GhmDZBXACmutKRMXq8rPacR6CD/um+WfBPGR9Qg5A=","expires_in":1800,"refresh_token":"tZbsGqsk0O150Q0hWRglAq3tCt0wVqQFZFpE0tq1RXj6ZRYAvyhgXsfuVwCMQK6cisC+bfzjw3+MoM9fZKSpZbmeUHZeJ/aSfmSZO9VvjCk="}' + http_version: + recorded_at: Sat, 19 Oct 2019 13:27:03 GMT +- request: + method: post + uri: https://testgw.gopay.cz/api/payments/payment/100/void-recurrence + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - application/json + User-Agent: + - rest-client/2.1.0 (darwin17.7.0 x86_64) ruby/2.5.3p105 + Content-Type: + - application/x-www-form-urlencoded + Authorization: + - "" + Content-Length: + - '0' + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Host: + - testgw.gopay.cz + response: + status: + code: 409 + message: Conflict + headers: + Date: + - Sat, 19 Oct 2019 13:27:04 GMT + Server: + - Apache + Strict-Transport-Security: + - max-age=15552000; includeSubDomains; preload + Cache-Control: + - no-cache, no-store, must-revalidate + X-Xss-Protection: + - 1; mode=block + X-Frame-Options: + - SAMEORIGIN + X-Content-Type-Options: + - nosniff + Content-Type: + - application/json + Content-Length: + - '166' + Set-Cookie: + - "" + body: + encoding: UTF-8 + string: '{"date_issued":"2019-10-19T15:27:04.099+0200","errors":[{"scope":"G","error_code":340,"error_name":"PAYMENT_RECURRENCE_FAILED","message":"Recurring + payment failed"}]}' + http_version: + recorded_at: Sat, 19 Oct 2019 13:27:04 GMT +recorded_with: VCR 5.0.0 diff --git a/spec/cassettes/GoPay_Payment/create/returns_existing_payment_for_recurrent_payment.yml b/spec/cassettes/GoPay_Payment/create/returns_existing_payment_for_recurrent_payment.yml index 8517dcd..fc0b56f 100644 --- a/spec/cassettes/GoPay_Payment/create/returns_existing_payment_for_recurrent_payment.yml +++ b/spec/cassettes/GoPay_Payment/create/returns_existing_payment_for_recurrent_payment.yml @@ -2,34 +2,38 @@ http_interactions: - request: method: post - uri: https://client_id_filtered:client_secret_filtered@testgw.gopay.cz/api/oauth2/token + uri: https://testgw.gopay.cz/api/oauth2/token body: encoding: UTF-8 string: grant_type=client_credentials&scope=payment-create headers: Accept: - application/json - Accept-Encoding: - - gzip + User-Agent: + - rest-client/2.1.0 (darwin17.7.0 x86_64) ruby/2.5.3p105 Content-Type: - application/x-www-form-urlencoded - User-Agent: - - unirest-ruby/1.1 + Authorization: + - "" Content-Length: - '50' + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Host: + - testgw.gopay.cz response: status: code: 200 message: OK headers: Date: - - Thu, 03 Mar 2016 16:17:02 GMT + - Sat, 19 Oct 2019 13:34:28 GMT Server: - - GOPAY + - Apache Strict-Transport-Security: - max-age=15552000; includeSubDomains; preload - X-Powered-By: - - GOPAY + Cache-Control: + - no-cache, no-store, must-revalidate, max-age=600 X-Xss-Protection: - 1; mode=block X-Frame-Options: @@ -42,58 +46,49 @@ http_interactions: - "" Vary: - Accept-Encoding - Content-Encoding: - - gzip - Cache-Control: - - max-age=600 Expires: - - Thu, 03 Mar 2016 16:27:02 GMT + - Sat, 19 Oct 2019 13:44:28 GMT Content-Length: - - '272' + - '275' body: encoding: ASCII-8BIT - string: !binary |- - H4sIAAAAAAAAAz2OTW+CMABA/0uvmvAxBLbEQyV8CIopFgUvBlhZhVlJKUK3 - 7L+P7LDre4f3voF4tIRdhewIeAMlKTjhYAmKqiJ9f/2TM28i2bVHPW48U0no - aO4f+G5xSVqItFeMjR0fcKg0STIIXT9+llWLjei+gr3TnbdOuAgdo2ad/Djh - 3oVxepcvjYyZ46MjUtr9XhelZu20VX5w2/VcJ1N346S/3ua2ZqvqEnBSz4D+ - D5F0GLGJ8DOw415MuXLG2xFqxZT53HOpsMkTLkyO/UymKdskA8zKi3hmam0H - 0ZeKGFU4zSHaRIf8pFo1vXSpNxiuXVA4Qst7t5HLpiBnj3QNfn4BcfIz/iYB - AAA= + string: '{"token_type":"bearer","access_token":"6AWN1YtYKIfjMMIH9MUV7tKkDx/QaE1qLHpCbwESsOOopi7kRhSKiv/sOaYf96GuYGECu09rEuJuVjFHUN918OncSvTcLu8pr7oVyyrBibU=","expires_in":1800,"refresh_token":"hXYyD6Rh4vsRUaPYVBaFrv3+wrLxW/IVpigjucXGtyITz8K/nJz2g3uTiVUr4+IE1YSYQpa/J+WkhmWTVNAHb0kWIwuZJ7zvBdKzypee4WI="}' http_version: - recorded_at: Thu, 03 Mar 2016 16:17:01 GMT + recorded_at: Sat, 19 Oct 2019 13:34:28 GMT - request: method: post uri: https://testgw.gopay.cz/api/payments/payment body: encoding: UTF-8 - string: '{"payer":{"allowed_payment_instruments":["BANK_ACCOUNT"],"contact":{"first_name":"John","last_name":"Doe","email":"john@example.com"}},"amount":10000,"currency":"CZK","order_number":"order-1","order_description":"foo","lang":"CS","callback":{"return_url":"http://localhost","notification_url":"http://localhost/2"},"recurrence":{"recurrence_cycle":"WEEK","recurrence_period":10,"recurrence_date_to":"2018-01-01"},"target":{"type":"ACCOUNT","goid":"8431713532"}}' + string: '{"payer":{"allowed_payment_instruments":["PAYMENT_CARD"],"contact":{"first_name":"John","last_name":"Doe","email":"john@example.com"}},"amount":10000,"currency":"CZK","order_number":"order-1","order_description":"foo","lang":"CS","callback":{"return_url":"http://localhost","notification_url":"http://localhost/2"},"recurrence":{"recurrence_cycle":"WEEK","recurrence_period":10,"recurrence_date_to":"2050-01-01"},"target":{"type":"ACCOUNT","goid":"1111111111"}}' headers: Accept: - application/json - Accept-Encoding: - - gzip + User-Agent: + - rest-client/2.1.0 (darwin17.7.0 x86_64) ruby/2.5.3p105 Content-Type: - application/json Authorization: - "" - User-Agent: - - unirest-ruby/1.1 Content-Length: - '461' + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Host: + - testgw.gopay.cz response: status: code: 200 message: OK headers: Date: - - Thu, 03 Mar 2016 16:17:03 GMT + - Sat, 19 Oct 2019 13:34:28 GMT Server: - - GOPAY + - Apache Strict-Transport-Security: - max-age=15552000; includeSubDomains; preload - X-Powered-By: - - GOPAY + Cache-Control: + - no-cache, no-store, must-revalidate, max-age=600 X-Xss-Protection: - 1; mode=block X-Frame-Options: @@ -106,28 +101,13 @@ http_interactions: - "" Vary: - Accept-Encoding - Content-Encoding: - - gzip - Cache-Control: - - max-age=600 Expires: - - Thu, 03 Mar 2016 16:27:02 GMT + - Sat, 19 Oct 2019 13:44:28 GMT Content-Length: - - '483' + - '348' body: encoding: ASCII-8BIT - string: !binary |- - H4sIAAAAAAAAA61TTY+bMBD9Lz6zCR8JITk1zXLpSlt1u6tKrSprsAdCa2xk - TLN0lf9eOwTIfmhPRRw8zzPj5zfPT6TkZBP54SpeLJbh2iM1aJSGOli2QnhE - aY6ayrbKUJNNH14FxCONAYMW2d2l2/v02iFtRs9oX1tDV526ycbo1i2HHahU - 66LAt59HWKvtsaxz7b7fkFOlO+7pvRZCqANy+jqjIZsf5OP29oZud7vPD7f3 - 5OeU3hzK3GX0TTjm0ArzRpOXGae6ASzUJBBWUIrxxnslcVSrxzKQvykw1t+4 - x2xQK/lSJwaaTxnSADNOg7zUjaESKif3J7WXViABE3StkIw8yC+b8AEfoaoF - zpiqyNusWGm6YW3vjDhyq5UdoqBMcbygK43uLrDj0SMGdIEnhqarHZFB7kGg - ZBEFqyBaRuF/kWkwTR/1p58nadloPLsIHaMpoqxjwrH7lqbOWhc7NepScefC - ZzC3FqZG2ZLQD5IrP7D/88LB+3fpl4f0q3O/JVBrhNbslS7/gikvaHNeuthq - al8XVKP5BMjCNmGNE+xAW+3GtzembjbzeXGYNSB5ph5nhbIGcaO04PxPNA/X - yRKyOE7yLIvzZBHGywAitl7hyo/WISfHf3PV4fTYAwAA + string: '{"id":3090067123,"order_number":"order-1","state":"CREATED","amount":10000,"currency":"CZK","payer":{"allowed_payment_instruments":["PAYMENT_CARD"],"contact":{"first_name":"John","last_name":"Doe","email":"john@example.com"}},"target":{"type":"ACCOUNT","goid":1111111111},"recurrence":{"recurrence_cycle":"WEEK","recurrence_period":10,"recurrence_date_to":"2050-01-01","recurrence_state":"REQUESTED"},"lang":"cs","gw_url":"https://gw.sandbox.gopay.com/gw/v3/c38b72ec40571fe53b8a856d97b473b0"}' http_version: - recorded_at: Thu, 03 Mar 2016 16:17:01 GMT -recorded_with: VCR 3.0.1 + recorded_at: Sat, 19 Oct 2019 13:34:28 GMT +recorded_with: VCR 5.0.0 diff --git a/spec/cassettes/GoPay_Payment/create/returns_existing_payment_for_standard_payment.yml b/spec/cassettes/GoPay_Payment/create/returns_existing_payment_for_standard_payment.yml index 85262a4..d25139a 100644 --- a/spec/cassettes/GoPay_Payment/create/returns_existing_payment_for_standard_payment.yml +++ b/spec/cassettes/GoPay_Payment/create/returns_existing_payment_for_standard_payment.yml @@ -2,34 +2,38 @@ http_interactions: - request: method: post - uri: https://client_id_filtered:client_secret_filtered@testgw.gopay.cz/api/oauth2/token + uri: https://testgw.gopay.cz/api/oauth2/token body: encoding: UTF-8 string: grant_type=client_credentials&scope=payment-create headers: Accept: - application/json - Accept-Encoding: - - gzip + User-Agent: + - rest-client/2.1.0 (darwin17.7.0 x86_64) ruby/2.5.3p105 Content-Type: - application/x-www-form-urlencoded - User-Agent: - - unirest-ruby/1.1 + Authorization: + - "" Content-Length: - '50' + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Host: + - testgw.gopay.cz response: status: code: 200 message: OK headers: Date: - - Thu, 03 Mar 2016 16:17:02 GMT + - Sat, 19 Oct 2019 13:36:34 GMT Server: - - GOPAY + - Apache Strict-Transport-Security: - max-age=15552000; includeSubDomains; preload - X-Powered-By: - - GOPAY + Cache-Control: + - no-cache, no-store, must-revalidate, max-age=600 X-Xss-Protection: - 1; mode=block X-Frame-Options: @@ -42,58 +46,49 @@ http_interactions: - "" Vary: - Accept-Encoding - Content-Encoding: - - gzip - Cache-Control: - - max-age=600 Expires: - - Thu, 03 Mar 2016 16:27:02 GMT + - Sat, 19 Oct 2019 13:46:34 GMT Content-Length: - '271' body: encoding: ASCII-8BIT - string: !binary |- - H4sIAAAAAAAAAz2OwW6CMABA/6VXTKC4KCzxgHNrVQQRujkvpsMK1QmlFCqY - /fvIDru+d3jvAVR5ZcVRdYKBZ/DFqGQSjABNU1bXxz858G0Mlbe8re7oHeps - LHvuJEGkgzuNIHSf9nxR7DAUF7NE+6pv1oQUn4UMohLGpspwm/i2R0LBmfWa - CbM6aa5XRoI3ltjpfaWqpr2EHzrsJ4TMhjq7Cy5ZfeRDGzqWNQKSnQeQ/w9p - dy43Z8+oDc/BL87UmOhxL6yOmBoaSditES0aCrdpYpzcKJvfdm2+qnEz8XNG - kR8XOcJ8vKjlPIyVT6eHDi4tGr3JK0ZXhcWN2J5G9qH5Tmfg5xcifkKuJgEA - AA== + string: '{"token_type":"bearer","access_token":"dZssp3tYRRKoN5N0jHPWXHsPaFaOZkkSoKLp93pcdVDR+oJlqQVoPYEgE57WxpU2mc7ELITxC+AE0hNZTZICIoH6pmvTc6IRI/+S0SpjZ1U=","expires_in":1800,"refresh_token":"jnu2jFHJ5aUs/mE78ohZ8DStix7NMo16dl8+SyRFl/AIe1+EOo5Dly9ZrfNtIS2GCLtl1hTETzWGO2eDYMKdYYKiP0xFfizuUj7YWzBIGFU="}' http_version: - recorded_at: Thu, 03 Mar 2016 16:17:00 GMT + recorded_at: Sat, 19 Oct 2019 13:36:34 GMT - request: method: post uri: https://testgw.gopay.cz/api/payments/payment body: encoding: UTF-8 - string: '{"payer":{"allowed_payment_instruments":["BANK_ACCOUNT"],"contact":{"first_name":"John","last_name":"Doe","email":"john@example.com"}},"amount":10000,"currency":"CZK","order_number":"order-1","order_description":"foo","lang":"CS","callback":{"return_url":"http://localhost","notification_url":"http://localhost/2"},"target":{"type":"ACCOUNT","goid":"8431713532"}}' + string: '{"payer":{"allowed_payment_instruments":["PAYMENT_CARD"],"contact":{"first_name":"John","last_name":"Doe","email":"john@example.com"}},"amount":10000,"currency":"CZK","order_number":"order-1","order_description":"foo","lang":"CS","callback":{"return_url":"http://localhost","notification_url":"http://localhost/2"},"target":{"type":"ACCOUNT","goid":"1111111111"}}' headers: Accept: - application/json - Accept-Encoding: - - gzip + User-Agent: + - rest-client/2.1.0 (darwin17.7.0 x86_64) ruby/2.5.3p105 Content-Type: - application/json Authorization: - "" - User-Agent: - - unirest-ruby/1.1 Content-Length: - '363' + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Host: + - testgw.gopay.cz response: status: code: 200 message: OK headers: Date: - - Thu, 03 Mar 2016 16:17:02 GMT + - Sat, 19 Oct 2019 13:36:34 GMT Server: - - GOPAY + - Apache Strict-Transport-Security: - max-age=15552000; includeSubDomains; preload - X-Powered-By: - - GOPAY + Cache-Control: + - no-cache, no-store, must-revalidate, max-age=600 X-Xss-Protection: - 1; mode=block X-Frame-Options: @@ -106,27 +101,13 @@ http_interactions: - "" Vary: - Accept-Encoding - Content-Encoding: - - gzip - Cache-Control: - - max-age=600 Expires: - - Thu, 03 Mar 2016 16:27:02 GMT + - Sat, 19 Oct 2019 13:46:34 GMT Content-Length: - - '430' + - '291' body: encoding: ASCII-8BIT - string: !binary |- - H4sIAAAAAAAAA61STW/bMAz9Lzx7SfxRZ8lpWdrLCnTA0F02FAIt0Y43WTJk - aalX5L9PimM76Iqd5pP4TD4+PvIFagHbdJWs8yy7ifMIWjSkLAuwclJGoI0g - w5RrCjKwHcJ3MUTQWbTkkf2Xu93j3W1AXMEu6FDbYt+c2VRnjQvP8Q822oUo - XvkvAu6Mb8v7QPftHs6Vod3Lvyik1EcS7O+MDrbf4ePu4Z7t9vvPXx8e4WlO - 7451GTIGEkElOmnfIHmdca4bwUrPBlGDtZwmPmhFk1sDVqD6yZDzYeIB80Gr - 1WufOBoxZyiL3AYPytp0lilsgt2f9EF5gyTO0K0mmHTAD5/wgZ6xaSUtuG7g - bVW8tv349jMTTdpa7ZcoGdeCruQqa/or7HSKwKKp6KzQ9m0QMto9GvQ+S+N1 - nN6kyX+xaTyaIRq6Xzbp1Ri6XNF8fobQ2YM29W+09RWPEHWI/ZD+3LGZrkGi - qvwYvAsTHJkzwc+DtW23XS6r46JDJQr9vKi031jw1oPLX+kyx1zkK87XeZol - nGdlUsa0SZNNnKebFRZw+gO9/0sBaQMAAA== + string: '{"id":3090067162,"order_number":"order-1","state":"CREATED","amount":10000,"currency":"CZK","payer":{"allowed_payment_instruments":["PAYMENT_CARD"],"contact":{"first_name":"John","last_name":"Doe","email":"john@example.com"}},"target":{"type":"ACCOUNT","goid":1111111111},"lang":"cs","gw_url":"https://gw.sandbox.gopay.com/gw/v3/5fb682873581cc28c8dbb62f7cd1296d"}' http_version: - recorded_at: Thu, 03 Mar 2016 16:17:01 GMT -recorded_with: VCR 3.0.1 + recorded_at: Sat, 19 Oct 2019 13:36:34 GMT +recorded_with: VCR 5.0.0 diff --git a/spec/cassettes/GoPay_Payment/refund/returns_existing_payment.yml b/spec/cassettes/GoPay_Payment/refund/returns_existing_payment.yml index 5b74ba3..9b2240c 100644 --- a/spec/cassettes/GoPay_Payment/refund/returns_existing_payment.yml +++ b/spec/cassettes/GoPay_Payment/refund/returns_existing_payment.yml @@ -2,34 +2,38 @@ http_interactions: - request: method: post - uri: https://client_id_filtered:client_secret_filtered@testgw.gopay.cz/api/oauth2/token + uri: https://testgw.gopay.cz/api/oauth2/token body: encoding: UTF-8 string: grant_type=client_credentials&scope=payment-all headers: Accept: - application/json - Accept-Encoding: - - gzip + User-Agent: + - rest-client/2.1.0 (darwin17.7.0 x86_64) ruby/2.5.3p105 Content-Type: - application/x-www-form-urlencoded - User-Agent: - - unirest-ruby/1.1 + Authorization: + - "" Content-Length: - '47' + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Host: + - testgw.gopay.cz response: status: code: 200 message: OK headers: Date: - - Thu, 03 Mar 2016 14:21:58 GMT + - Sat, 19 Oct 2019 13:41:36 GMT Server: - - GOPAY + - Apache Strict-Transport-Security: - max-age=15552000; includeSubDomains; preload - X-Powered-By: - - GOPAY + Cache-Control: + - no-cache, no-store, must-revalidate, max-age=600 X-Xss-Protection: - 1; mode=block X-Frame-Options: @@ -42,58 +46,49 @@ http_interactions: - "" Vary: - Accept-Encoding - Content-Encoding: - - gzip - Cache-Control: - - max-age=600 Expires: - - Thu, 03 Mar 2016 14:31:58 GMT + - Sat, 19 Oct 2019 13:51:36 GMT Content-Length: - - '272' + - '273' body: encoding: ASCII-8BIT - string: !binary |- - H4sIAAAAAAAAAz2Oy06DQAAA/2WvbVKgPE16oMhTZKFViVzIAttCgV1YsAWM - /y7x4HXmMPMNRlpjko5zh8ETyDBimIEtQHmOhyH9kyu3M5FDRKX9Zn+Pcppb - hSpLXtJKuqILlaEa4l4UOHdakiRg5oDMNyUPm51RZGN7uVud5wu9wmaHREV8 - u50fMjpbk1fDh52j97jtlSiImg7yrv84rHU8dRXDQ1qtbV7luC1g+LKC8n/I - oSfX0/rkKGONyUJ5nPHLNO4KpxZ1a0pgH9RcaGjaOLy2aKMbz6GSka/FnCEs - dImPPxynqfmFJPJM6pn4nwul1yumJ9zEPFxOO7ukUQg9xxQP4OcXNt3lNiYB - AAA= + string: '{"token_type":"bearer","access_token":"cIzUQYybHGull7mXY/5Dm/1BrMS10F6iWHKzHC5S5suF0OFFd1Ql1GGQCvUmXgAerPRNNCFVavzAtJbog2mg3x+WQMpCe4P2f3a3earOQa0=","expires_in":1800,"refresh_token":"QBCGCfoBJGW2saYj442lbKCZoJfq0SQijooIOwT2eYiDOILLEm5lYMba2lYqm06f8Ai5UPv4OMFsGsCO86VYAAHCa9gQdPxsHmE+xZXECjY="}' http_version: - recorded_at: Thu, 03 Mar 2016 14:21:57 GMT + recorded_at: Sat, 19 Oct 2019 13:41:36 GMT - request: method: post - uri: https://testgw.gopay.cz/api/payments/payment/3027334050/refund + uri: https://testgw.gopay.cz/api/payments/payment/3090067162/refund body: encoding: US-ASCII - string: amount=46900 + string: amount=10000 headers: Accept: - application/json - Accept-Encoding: - - gzip + User-Agent: + - rest-client/2.1.0 (darwin17.7.0 x86_64) ruby/2.5.3p105 Content-Type: - application/x-www-form-urlencoded Authorization: - "" - User-Agent: - - unirest-ruby/1.1 Content-Length: - '12' + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Host: + - testgw.gopay.cz response: status: code: 200 message: OK headers: Date: - - Thu, 03 Mar 2016 14:21:59 GMT + - Sat, 19 Oct 2019 13:42:03 GMT Server: - - GOPAY + - Apache Strict-Transport-Security: - max-age=15552000; includeSubDomains; preload - X-Powered-By: - - GOPAY + Cache-Control: + - no-cache, no-store, must-revalidate, max-age=600 X-Xss-Protection: - 1; mode=block X-Frame-Options: @@ -103,16 +98,14 @@ http_interactions: Content-Type: - application/json Content-Length: - - '56' + - '37' Set-Cookie: - "" - Cache-Control: - - max-age=600 Expires: - - Thu, 03 Mar 2016 14:31:58 GMT + - Sat, 19 Oct 2019 13:51:36 GMT body: encoding: UTF-8 - string: '{"id":3027334050,"result":"FINISHED","description":null}' + string: '{"id":3090067162,"result":"FINISHED"}' http_version: - recorded_at: Thu, 03 Mar 2016 14:21:58 GMT -recorded_with: VCR 3.0.1 + recorded_at: Sat, 19 Oct 2019 13:42:03 GMT +recorded_with: VCR 5.0.0 diff --git a/spec/cassettes/GoPay_Payment/refund/returns_gopay_error_when_payment_not_found.yml b/spec/cassettes/GoPay_Payment/refund/returns_gopay_error_when_payment_not_found.yml index 954ede4..82e1cbe 100644 --- a/spec/cassettes/GoPay_Payment/refund/returns_gopay_error_when_payment_not_found.yml +++ b/spec/cassettes/GoPay_Payment/refund/returns_gopay_error_when_payment_not_found.yml @@ -2,34 +2,38 @@ http_interactions: - request: method: post - uri: https://client_id_filtered:client_secret_filtered@testgw.gopay.cz/api/oauth2/token + uri: https://testgw.gopay.cz/api/oauth2/token body: encoding: UTF-8 string: grant_type=client_credentials&scope=payment-all headers: Accept: - application/json - Accept-Encoding: - - gzip + User-Agent: + - rest-client/2.1.0 (darwin17.7.0 x86_64) ruby/2.5.3p105 Content-Type: - application/x-www-form-urlencoded - User-Agent: - - unirest-ruby/1.1 + Authorization: + - "" Content-Length: - '47' + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Host: + - testgw.gopay.cz response: status: code: 200 message: OK headers: Date: - - Thu, 03 Mar 2016 14:22:00 GMT + - Sat, 19 Oct 2019 13:42:03 GMT Server: - - GOPAY + - Apache Strict-Transport-Security: - max-age=15552000; includeSubDomains; preload - X-Powered-By: - - GOPAY + Cache-Control: + - no-cache, no-store, must-revalidate, max-age=600 X-Xss-Protection: - 1; mode=block X-Frame-Options: @@ -42,26 +46,15 @@ http_interactions: - "" Vary: - Accept-Encoding - Content-Encoding: - - gzip - Cache-Control: - - max-age=600 Expires: - - Thu, 03 Mar 2016 14:31:59 GMT + - Sat, 19 Oct 2019 13:52:03 GMT Content-Length: - '271' body: encoding: ASCII-8BIT - string: !binary |- - H4sIAAAAAAAAAz2OwW6CQBQA/2XPJixSrDTxAFLEKiBCULiQBZ+wYnHZRUBN - /72kh15nDjMv1N4qqNP2wQB9oAwIB44miOQ5CJH+yZErcckSu71Hh0KXFD8U - MKzavBz0Qwy2/s74Wyg2nSCneX/L6qVqXoPOCz1ZGHfZcPqovh4Nq5R7lxd+ - /iDE1HDzVfBLsCI3ibtSFh122xA7ShIvxjoMjHIQKR3b8hzjCeJwHkH5P3Sx - N5JF+09dZ5W6n1uVUnhh24hEE569u0/pM5gm/o6G/T4/4qfb+TM6uFvAmg8s - 0MiJt1ebqbPKyNa5CGQusE6c4lxTtdGy5XrLIHKlb2ESZ4F+fgEcAEhSJgEA - AA== + string: '{"token_type":"bearer","access_token":"cJUtqmBUHVvXhlpKt85kZgcg34HTUwh36XsBmD6ZnMspTeXV8AvzPbMYMRTEszdBmCP2Yx8sScl7zMoxPCD3h9zwmgr6lO0uvE96kBm3iJ0=","expires_in":1800,"refresh_token":"2lPGTyxOIxz12hrzv4lmBNukMLXIB6h/zhqL3JX97UdH/OzPD9h0tPR2b93Ksic6eUExX9s3PUZatjFpsmSYHVsPu04c1hHvCqaX+QBp3FA="}' http_version: - recorded_at: Thu, 03 Mar 2016 14:21:59 GMT + recorded_at: Sat, 19 Oct 2019 13:42:03 GMT - request: method: post uri: https://testgw.gopay.cz/api/payments/payment/100/refund @@ -71,29 +64,31 @@ http_interactions: headers: Accept: - application/json - Accept-Encoding: - - gzip + User-Agent: + - rest-client/2.1.0 (darwin17.7.0 x86_64) ruby/2.5.3p105 Content-Type: - application/x-www-form-urlencoded Authorization: - "" - User-Agent: - - unirest-ruby/1.1 Content-Length: - '10' + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Host: + - testgw.gopay.cz response: status: - code: 500 - message: Internal Server Error + code: 409 + message: Conflict headers: Date: - - Thu, 03 Mar 2016 14:22:00 GMT + - Sat, 19 Oct 2019 13:42:03 GMT Server: - - GOPAY + - Apache Strict-Transport-Security: - max-age=15552000; includeSubDomains; preload - X-Powered-By: - - GOPAY + Cache-Control: + - no-cache, no-store, must-revalidate X-Xss-Protection: - 1; mode=block X-Frame-Options: @@ -103,14 +98,13 @@ http_interactions: Content-Type: - application/json Content-Length: - - '153' + - '149' Set-Cookie: - "" - Connection: - - close body: encoding: UTF-8 - string: '{"date_issued":"2016-03-03T15:22:00.522+0100","errors":[{"scope":"G","field":null,"error_code":500,"error_name":null,"message":null,"description":null}]}' + string: '{"date_issued":"2019-10-19T15:42:03.905+0200","errors":[{"scope":"F","field":"id","error_code":111,"error_name":"INVALID","message":"Wrong + value."}]}' http_version: - recorded_at: Thu, 03 Mar 2016 14:21:59 GMT -recorded_with: VCR 3.0.1 + recorded_at: Sat, 19 Oct 2019 13:42:03 GMT +recorded_with: VCR 5.0.0 diff --git a/spec/cassettes/GoPay_Payment/retrieve/returns_existing_payment.yml b/spec/cassettes/GoPay_Payment/retrieve/returns_existing_payment.yml index 661a47e..d6f1a4c 100644 --- a/spec/cassettes/GoPay_Payment/retrieve/returns_existing_payment.yml +++ b/spec/cassettes/GoPay_Payment/retrieve/returns_existing_payment.yml @@ -2,34 +2,38 @@ http_interactions: - request: method: post - uri: https://client_id_filtered:client_secret_filtered@testgw.gopay.cz/api/oauth2/token + uri: https://testgw.gopay.cz/api/oauth2/token body: encoding: UTF-8 string: grant_type=client_credentials&scope=payment-all headers: Accept: - application/json - Accept-Encoding: - - gzip + User-Agent: + - rest-client/2.1.0 (darwin17.7.0 x86_64) ruby/2.5.3p105 Content-Type: - application/x-www-form-urlencoded - User-Agent: - - unirest-ruby/1.1 + Authorization: + - "" Content-Length: - '47' + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Host: + - testgw.gopay.cz response: status: code: 200 message: OK headers: Date: - - Thu, 03 Mar 2016 14:20:18 GMT + - Sat, 19 Oct 2019 13:34:26 GMT Server: - - GOPAY + - Apache Strict-Transport-Security: - max-age=15552000; includeSubDomains; preload - X-Powered-By: - - GOPAY + Cache-Control: + - no-cache, no-store, must-revalidate, max-age=600 X-Xss-Protection: - 1; mode=block X-Frame-Options: @@ -42,56 +46,49 @@ http_interactions: - "" Vary: - Accept-Encoding - Content-Encoding: - - gzip - Cache-Control: - - max-age=600 Expires: - - Thu, 03 Mar 2016 14:30:18 GMT + - Sat, 19 Oct 2019 13:44:26 GMT Content-Length: - - '273' + - '272' body: encoding: ASCII-8BIT - string: !binary |- - H4sIAAAAAAAAAz3Oy3KCMACF4XfJFmcSiBLaGRdSL4gWQYRaNg5CuGkRE4iG - Tt+9TBfdfmfxn2/Q3i60PrWyoeAVnGnMKAMjECcJ5fz0Nw6entv3SZGQXPdr - zzHvuTZ2BfQXh5tUug08mhX1D2vn2kpEVanlm84ly1xcQ15H894j/Ze2j3dO - 7uxW6CIjwrFk2Rt5Kiq/iGUwtlcTKVgUz2QyHer02ZSM8lM5tFUDoRFgNBug - +D+Eil7VjIeqhwk0qptY9HKNdXg0MrTNAh6yet8il31G2QZuudKTtIPWS7OA - EM9byy2wsH3yvJpCKbGlVXj5wR54hu/lPbYTT4o+tVJrEMcMpuDnF63YzW0m - AQAA + string: '{"token_type":"bearer","access_token":"WrervLzFAcoF8KFvhhVTy3TZmah4PrHr71talag44FOsqU/zmGQDWU9z974F0hmj2ukADIEQPDHtRB0WBdbXi7Oapufci7/Kzs8nQ3ywYmY=","expires_in":1800,"refresh_token":"WieSUCOHnYlNdQyM72TKVyOQoVPR4JLdzumEZRNm+5TbRwTGa5ECPZK9OBoKCYq2xB7mytg52sx2NwjaILwiACBFGaCbCEMQSsNHjMppC8Y="}' http_version: - recorded_at: Thu, 03 Mar 2016 14:20:17 GMT + recorded_at: Sat, 19 Oct 2019 13:34:26 GMT - request: method: get - uri: https://testgw.gopay.cz/api/payments/payment/3026370321 + uri: https://testgw.gopay.cz/api/payments/payment/3090060402 body: encoding: US-ASCII string: '' headers: Accept: - application/json - Accept-Encoding: - - gzip + User-Agent: + - rest-client/2.1.0 (darwin17.7.0 x86_64) ruby/2.5.3p105 Content-Type: - application/x-www-form-urlencoded Authorization: - "" - User-Agent: - - unirest-ruby/1.1 + Content-Length: + - '0' + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Host: + - testgw.gopay.cz response: status: code: 200 message: OK headers: Date: - - Thu, 03 Mar 2016 14:20:19 GMT + - Sat, 19 Oct 2019 13:34:27 GMT Server: - - GOPAY + - Apache Strict-Transport-Security: - max-age=15552000; includeSubDomains; preload - X-Powered-By: - - GOPAY + Cache-Control: + - no-cache, no-store, must-revalidate, max-age=600 X-Xss-Protection: - 1; mode=block X-Frame-Options: @@ -104,29 +101,15 @@ http_interactions: - "" Vary: - Accept-Encoding - Content-Encoding: - - gzip - Cache-Control: - - max-age=600 Expires: - - Thu, 03 Mar 2016 14:30:19 GMT + - Sat, 19 Oct 2019 13:44:26 GMT Content-Length: - - '509' + - '402' body: encoding: ASCII-8BIT - string: !binary |- - H4sIAAAAAAAAA61TTY/aMBD9Lz7zESfh81TEUlWqlq1Y9tBWlTXYJolw7Mhx - lmZX/PcdEwiw5dhDpMzzzJvnN+N3kgkyjYJwGI2CKKQdUoCV2jEP60qpDjFW - SMt0lW+kJdMm7NJgOKYxDYKYdEjpwEk8Wi2+viwfFg8eqjbsBDcsBdT5kVeX - zlb+Fwt+zH4+LpZrNp+tfBHkpvI40gZBh/DKohReY+L813dy5PAS3u+SNW1A - KbOXgv2bUZLp79uGfy7p5T7b+oyGRMgtVMrdIfmccaw7g4m5mCZzyFR799Ro - 2TrYYBvQOwacNzduMAwKoz87xsGKS4Z2wJ33YJvZ0jENuXf+GbSwgBYpuIBL - 8wo7/EgrhzjJ0y+pygTwXd3jb+S+OJ65+vyPV5eylVgYnKpi3Ah5pVo7W58w - HNWCHA4d4sAm8qjU1YU/mM3nTy/LNTkbNY4jOqLRIAr/i13n5WmipvtpoqjG - ytM2Sa/oEjFec+XVPT4t19/IdSIrpM0MCqU3qMClZs5gSRjQSTcIu3RyW3d+ - Ds/r2WqNrwHbF1ZC5VJjszdw2ZVoITIfo6X47iBvV1CBTpCCl96uPausn17q - XFFO+/1k3ytx4Bvzt5cYXJMeNzmC/deoD+MBqtpMQjkKKR/LWIpwMBlu4wGN - 4lHAyeED6FVyjfIDAAA= + string: '{"id":3090060402,"order_number":"order-1","state":"REFUNDED","payment_instrument":"PAYMENT_CARD","amount":10000,"currency":"CZK","payer":{"allowed_payment_instruments":["PAYMENT_CARD"],"payment_card":{"card_number":"418803******0003","card_expiration":"2112","card_brand":"VISA + Electron","card_issuer_country":"CZE","card_issuer_bank":"KOMERCNI BANKA, + A.S."},"contact":{"first_name":"John","last_name":"Doe","email":"john@example.com","country_code":"CZE"}},"target":{"type":"ACCOUNT","goid":1111111111},"lang":"cs","gw_url":"https://gw.sandbox.gopay.com/gw/v3/95c24246256a19e1f4903d18a5cb9c31"}' http_version: - recorded_at: Thu, 03 Mar 2016 14:20:17 GMT -recorded_with: VCR 3.0.1 + recorded_at: Sat, 19 Oct 2019 13:34:27 GMT +recorded_with: VCR 5.0.0 diff --git a/spec/cassettes/GoPay_Payment/retrieve/returns_gopay_error_when_payment_not_found.yml b/spec/cassettes/GoPay_Payment/retrieve/returns_gopay_error_when_payment_not_found.yml index ae31b35..01ea747 100644 --- a/spec/cassettes/GoPay_Payment/retrieve/returns_gopay_error_when_payment_not_found.yml +++ b/spec/cassettes/GoPay_Payment/retrieve/returns_gopay_error_when_payment_not_found.yml @@ -2,34 +2,38 @@ http_interactions: - request: method: post - uri: https://client_id_filtered:client_secret_filtered@testgw.gopay.cz/api/oauth2/token + uri: https://testgw.gopay.cz/api/oauth2/token body: encoding: UTF-8 string: grant_type=client_credentials&scope=payment-all headers: Accept: - application/json - Accept-Encoding: - - gzip + User-Agent: + - rest-client/2.1.0 (darwin17.7.0 x86_64) ruby/2.5.3p105 Content-Type: - application/x-www-form-urlencoded - User-Agent: - - unirest-ruby/1.1 + Authorization: + - "" Content-Length: - '47' + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Host: + - testgw.gopay.cz response: status: code: 200 message: OK headers: Date: - - Thu, 03 Mar 2016 14:20:19 GMT + - Sat, 19 Oct 2019 13:34:27 GMT Server: - - GOPAY + - Apache Strict-Transport-Security: - max-age=15552000; includeSubDomains; preload - X-Powered-By: - - GOPAY + Cache-Control: + - no-cache, no-store, must-revalidate, max-age=600 X-Xss-Protection: - 1; mode=block X-Frame-Options: @@ -42,26 +46,15 @@ http_interactions: - "" Vary: - Accept-Encoding - Content-Encoding: - - gzip - Cache-Control: - - max-age=600 Expires: - - Thu, 03 Mar 2016 14:30:19 GMT + - Sat, 19 Oct 2019 13:44:27 GMT Content-Length: - - '273' + - '274' body: encoding: ASCII-8BIT - string: !binary |- - H4sIAAAAAAAAAz2Oy26CQAAA/2WvmvAQijbxsIALqIDVFkovBGR5iLx2AReb - /ntJD73OHGa+Qd+UuA77qcXgFcQ4IpiAJYiuV0xp+CdnXnaRpflE1wedCRcb - K1lRSUZeDR9+As2vzl81LwFFnLcLLGeKDOtsKPoAMzd7v7uFk7JPhaciFtQO - NZyqddrq6KOFCJkMIeoPDzYdk0vLIc8ut3Mds7YgmIbF3BbWPL8EBKczyP+H - mg0+2XYKaSYOh3s+bKgmPcdx9I4ipdmgT7zZHpx6fTtJ516JeyKqtRwbAqld - tGAscJGZPHnUP24TdoQqFcdqp8MauuVbZQnBeb+Xk6yO8pvEb8HPL1JsFNAm - AQAA + string: '{"token_type":"bearer","access_token":"5Z06kRCPmdCKe7SsP3bvxocrLxBmq4jVX4I5YTUTPudYjcFP7uNbraE9DIsvkfuoWw8qCnJ4P8TjBMxy8t9WMh+r7QhbmN5W+KWjOK3VA68=","expires_in":1800,"refresh_token":"nyY8X3GO/DVp7AQFG1K07YFXjxOzozYLzha5tJ7QwMnvFm4gXJPThS2rYzXWvIQTj4Ku3O5WehPmp1RHtT9MN48F4pRoRfl/LmYVCIBYDO0="}' http_version: - recorded_at: Thu, 03 Mar 2016 14:20:18 GMT + recorded_at: Sat, 19 Oct 2019 13:34:27 GMT - request: method: get uri: https://testgw.gopay.cz/api/payments/payment/100 @@ -71,27 +64,31 @@ http_interactions: headers: Accept: - application/json - Accept-Encoding: - - gzip + User-Agent: + - rest-client/2.1.0 (darwin17.7.0 x86_64) ruby/2.5.3p105 Content-Type: - application/x-www-form-urlencoded Authorization: - "" - User-Agent: - - unirest-ruby/1.1 + Content-Length: + - '0' + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Host: + - testgw.gopay.cz response: status: - code: 500 - message: Internal Server Error + code: 404 + message: Not Found headers: Date: - - Thu, 03 Mar 2016 14:20:19 GMT + - Sat, 19 Oct 2019 13:34:27 GMT Server: - - GOPAY + - Apache Strict-Transport-Security: - max-age=15552000; includeSubDomains; preload - X-Powered-By: - - GOPAY + Cache-Control: + - no-cache, no-store, must-revalidate X-Xss-Protection: - 1; mode=block X-Frame-Options: @@ -101,14 +98,13 @@ http_interactions: Content-Type: - application/json Content-Length: - - '153' + - '152' Set-Cookie: - "" - Connection: - - close body: encoding: UTF-8 - string: '{"date_issued":"2016-03-03T15:20:19.536+0100","errors":[{"scope":"G","field":null,"error_code":500,"error_name":null,"message":null,"description":null}]}' + string: '{"date_issued":"2019-10-19T15:34:27.452+0200","errors":[{"scope":"G","error_code":304,"error_name":"PAYMENT_NOT_FOUND","message":"Payment + not found."}]}' http_version: - recorded_at: Thu, 03 Mar 2016 14:20:18 GMT -recorded_with: VCR 3.0.1 + recorded_at: Sat, 19 Oct 2019 13:34:27 GMT +recorded_with: VCR 5.0.0 diff --git a/spec/cassettes/GoPay_Payment/void_recurrence/returns_existing_payment.yml b/spec/cassettes/GoPay_Payment/void_recurrence/returns_existing_payment.yml index 108effb..859ea5f 100644 --- a/spec/cassettes/GoPay_Payment/void_recurrence/returns_existing_payment.yml +++ b/spec/cassettes/GoPay_Payment/void_recurrence/returns_existing_payment.yml @@ -2,34 +2,38 @@ http_interactions: - request: method: post - uri: https://client_id_filtered:client_secret_filtered@testgw.gopay.cz/api/oauth2/token + uri: https://testgw.gopay.cz/api/oauth2/token body: encoding: UTF-8 string: grant_type=client_credentials&scope=payment-all headers: Accept: - application/json - Accept-Encoding: - - gzip + User-Agent: + - rest-client/2.1.0 (darwin17.7.0 x86_64) ruby/2.5.3p105 Content-Type: - application/x-www-form-urlencoded - User-Agent: - - unirest-ruby/1.1 + Authorization: + - "" Content-Length: - '47' + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Host: + - testgw.gopay.cz response: status: code: 200 message: OK headers: Date: - - Thu, 03 Mar 2016 14:22:37 GMT + - Sat, 19 Oct 2019 13:42:10 GMT Server: - - GOPAY + - Apache Strict-Transport-Security: - max-age=15552000; includeSubDomains; preload - X-Powered-By: - - GOPAY + Cache-Control: + - no-cache, no-store, must-revalidate, max-age=600 X-Xss-Protection: - 1; mode=block X-Frame-Options: @@ -42,58 +46,49 @@ http_interactions: - "" Vary: - Accept-Encoding - Content-Encoding: - - gzip - Cache-Control: - - max-age=600 Expires: - - Thu, 03 Mar 2016 14:32:37 GMT + - Sat, 19 Oct 2019 13:52:10 GMT Content-Length: - '272' body: encoding: ASCII-8BIT - string: !binary |- - H4sIAAAAAAAAAz2OwW6CMABA/6VXTACdMpZ4oIKAExRBgV5IhcJQVkiLSLfs - 30d22PW9w3vfoG/vhGa96Ah4A1eCGWFgBnCeE86zPzlxw/N1h6nSHp9vFyeX - V8y/npUBGfcmGN7taqPau8CK3eWD+WqAjnLpyIXaNHtqUYFsgyvHaoQCu1R8 - peSQhpBvF3F0oLm3M8tVMkJVZve5IKRdT3UydjUjPKuntvqqKDPASDmBj/8h - XdOQ2ccJlulckvRIEV5LIb84FU9g8AiSeHhaSCzn1ellC6s6b5/sPIRl3mn8 - ZpnbQjltcFLY2DFvRi2k4REtodS2CxThRWhpLvp0ROHzJkjX4OcX2Z2GXiYB - AAA= + string: '{"token_type":"bearer","access_token":"1dHqBx4tqibm+lUQDoc1dfPYlCqbhnp4EA6oaI2F3xqSfi57yM4faCiZmIvETNoD3zT4eu+aq8s1794qiWI0rLjbVr6GUmqQqlVEkGqFLSk=","expires_in":1800,"refresh_token":"PvyZ7zC8GEmmOeKj/XJdw19lF4VMiTivElZ/vezp1gRKdOvWDCGNhqr0hyDwK6dk/QqoMSIKh5tQQh1mgiugCVlplaETJFr1jzgLVgtMq14="}' http_version: - recorded_at: Thu, 03 Mar 2016 14:22:36 GMT + recorded_at: Sat, 19 Oct 2019 13:42:10 GMT - request: method: post - uri: https://testgw.gopay.cz/api/payments/payment/3027321817/void-recurrence + uri: https://testgw.gopay.cz/api/payments/payment/3090067123/void-recurrence body: - encoding: ASCII-8BIT + encoding: US-ASCII string: '' headers: Accept: - application/json - Accept-Encoding: - - gzip + User-Agent: + - rest-client/2.1.0 (darwin17.7.0 x86_64) ruby/2.5.3p105 Content-Type: - application/x-www-form-urlencoded Authorization: - "" - User-Agent: - - unirest-ruby/1.1 Content-Length: - '0' + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Host: + - testgw.gopay.cz response: status: code: 200 message: OK headers: Date: - - Thu, 03 Mar 2016 14:22:38 GMT + - Sat, 19 Oct 2019 13:42:10 GMT Server: - - GOPAY + - Apache Strict-Transport-Security: - max-age=15552000; includeSubDomains; preload - X-Powered-By: - - GOPAY + Cache-Control: + - no-cache, no-store, must-revalidate, max-age=600 X-Xss-Protection: - 1; mode=block X-Frame-Options: @@ -103,16 +98,14 @@ http_interactions: Content-Type: - application/json Content-Length: - - '56' + - '37' Set-Cookie: - "" - Cache-Control: - - max-age=600 Expires: - - Thu, 03 Mar 2016 14:32:38 GMT + - Sat, 19 Oct 2019 13:52:10 GMT body: encoding: UTF-8 - string: '{"id":3027321817,"result":"FINISHED","description":null}' + string: '{"id":3090067123,"result":"FINISHED"}' http_version: - recorded_at: Thu, 03 Mar 2016 14:22:37 GMT -recorded_with: VCR 3.0.1 + recorded_at: Sat, 19 Oct 2019 13:42:10 GMT +recorded_with: VCR 5.0.0 diff --git a/spec/cassettes/GoPay_Payment/void_recurrence/returns_gopay_error_when_payment_not_found.yml b/spec/cassettes/GoPay_Payment/void_recurrence/returns_gopay_error_when_payment_not_found.yml index 22ef71f..b134c0d 100644 --- a/spec/cassettes/GoPay_Payment/void_recurrence/returns_gopay_error_when_payment_not_found.yml +++ b/spec/cassettes/GoPay_Payment/void_recurrence/returns_gopay_error_when_payment_not_found.yml @@ -2,34 +2,38 @@ http_interactions: - request: method: post - uri: https://client_id_filtered:client_secret_filtered@testgw.gopay.cz/api/oauth2/token + uri: https://testgw.gopay.cz/api/oauth2/token body: encoding: UTF-8 string: grant_type=client_credentials&scope=payment-all headers: Accept: - application/json - Accept-Encoding: - - gzip + User-Agent: + - rest-client/2.1.0 (darwin17.7.0 x86_64) ruby/2.5.3p105 Content-Type: - application/x-www-form-urlencoded - User-Agent: - - unirest-ruby/1.1 + Authorization: + - "" Content-Length: - '47' + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Host: + - testgw.gopay.cz response: status: code: 200 message: OK headers: Date: - - Thu, 03 Mar 2016 14:22:38 GMT + - Sat, 19 Oct 2019 13:41:36 GMT Server: - - GOPAY + - Apache Strict-Transport-Security: - max-age=15552000; includeSubDomains; preload - X-Powered-By: - - GOPAY + Cache-Control: + - no-cache, no-store, must-revalidate, max-age=600 X-Xss-Protection: - 1; mode=block X-Frame-Options: @@ -42,58 +46,49 @@ http_interactions: - "" Vary: - Accept-Encoding - Content-Encoding: - - gzip - Cache-Control: - - max-age=600 Expires: - - Thu, 03 Mar 2016 14:32:38 GMT + - Sat, 19 Oct 2019 13:51:35 GMT Content-Length: - - '274' + - '270' body: encoding: ASCII-8BIT - string: !binary |- - H4sIAAAAAAAAAz2Oy26CQAAA/2WvmLhQHksTD6wKIkhRWaq9EMBlgUJ5KQ+b - /ntJD73OHGa+wb36pF/BfaopeAURDVvaggUI45h2XfAnZ/7Q/CZiUWMgbiil - dU58d226t2ngxKVF9CEKVVPslzLWTdtjrFZHu3TcC1EyvxREsbgkReXkoSdf - bSaku/5MRlTgUJW97V0ylre4gnuiw3clgau5Tsc6a2kXZHObRxAuQEuTGaT/ - Q5D3qbRXjw+ElYzfP57WxD2jy1GIoNo/h0pAH90pkWNlFJpNPjEhzuXDxsbY - cnliOrGWXhlvGYqmnbEDd8eh8XSmcRsHlWzw0i3dbV8k+IYJOqzAzy+Rdrfp - JgEAAA== + string: '{"token_type":"bearer","access_token":"bK1oEFFSE5p5Nu0B0NHf25x7PZC9xwSlZz4QfLcHFx1qThJm/X0M8HEbcT2KmZoZe9U6AGPtQZ8OIOXXytlKHaZuwwcQJ8iaMtZG4c94Kns=","expires_in":1800,"refresh_token":"nGp2WrNPR3wMZ5mkoh4CIQyTXv5J2OpzGSIsAyNm5n9R8lCDS8ptvaeLgmxFY+GKM1C3mWQlDmABy9ntRAtCE6TvbtVnTDYniwswti7kYTs="}' http_version: - recorded_at: Thu, 03 Mar 2016 14:22:37 GMT + recorded_at: Sat, 19 Oct 2019 13:41:36 GMT - request: method: post uri: https://testgw.gopay.cz/api/payments/payment/100/void-recurrence body: - encoding: ASCII-8BIT + encoding: US-ASCII string: '' headers: Accept: - application/json - Accept-Encoding: - - gzip + User-Agent: + - rest-client/2.1.0 (darwin17.7.0 x86_64) ruby/2.5.3p105 Content-Type: - application/x-www-form-urlencoded Authorization: - "" - User-Agent: - - unirest-ruby/1.1 Content-Length: - '0' + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Host: + - testgw.gopay.cz response: status: code: 409 message: Conflict headers: Date: - - Thu, 03 Mar 2016 14:22:38 GMT + - Sat, 19 Oct 2019 13:41:36 GMT Server: - - GOPAY + - Apache Strict-Transport-Security: - max-age=15552000; includeSubDomains; preload - X-Powered-By: - - GOPAY + Cache-Control: + - no-cache, no-store, must-revalidate X-Xss-Protection: - 1; mode=block X-Frame-Options: @@ -103,12 +98,13 @@ http_interactions: Content-Type: - application/json Content-Length: - - '203' + - '166' Set-Cookie: - "" body: encoding: UTF-8 - string: '{"date_issued":"2016-03-03T15:22:38.893+0100","errors":[{"scope":"G","field":null,"error_code":340,"error_name":"PAYMENT_RECURRENCE_FAILED","message":"api.PAYMENT_RECURRENCE_FAILED","description":null}]}' + string: '{"date_issued":"2019-10-19T15:41:36.346+0200","errors":[{"scope":"G","error_code":340,"error_name":"PAYMENT_RECURRENCE_FAILED","message":"Recurring + payment failed"}]}' http_version: - recorded_at: Thu, 03 Mar 2016 14:22:37 GMT -recorded_with: VCR 3.0.1 + recorded_at: Sat, 19 Oct 2019 13:41:36 GMT +recorded_with: VCR 5.0.0 diff --git a/spec/gateway_spec.rb b/spec/gateway_spec.rb new file mode 100644 index 0000000..34b7a30 --- /dev/null +++ b/spec/gateway_spec.rb @@ -0,0 +1,117 @@ +require 'spec_helper' + +describe GoPay::Gateway, vcr: VCR_OPTIONS do + let(:gopay_config) { + { + gate: ENV['GOPAY_GATE'], + goid: ENV['GOPAY_1_GOID'], + client_id: ENV['GOPAY_1_CLIENT_ID'], + client_secret: ENV['GOPAY_1_CLIENT_SECRET'] + } + } + + before(:each) { + @gateway = GoPay::Gateway.new(gopay_config) + } + + it 'allows to switch goid' do + gateway1 = GoPay::Gateway.new(gopay_config) + expect(gateway1.retrieve 3090060402).to include("id" => 3090060402, "target" => include("goid" => ENV['GOPAY_1_GOID'].to_i)) + gateway2 = GoPay::Gateway.new( + gate: ENV['GOPAY_GATE'], + goid: ENV['GOPAY_2_GOID'], + client_id: ENV['GOPAY_2_CLIENT_ID'], + client_secret: ENV['GOPAY_2_CLIENT_SECRET'] + ) + expect(gateway2.retrieve 3088999875).to include("id" => 3088999875, "target" => include("goid" => ENV['GOPAY_2_GOID'].to_i)) + end + + describe 'create' do + let(:params) { { payer: { allowed_payment_instruments: ["PAYMENT_CARD"], + contact: { first_name: 'John', + last_name: 'Doe', + email: 'john@example.com' } }, + amount: 10000, + currency: 'CZK', + order_number: 'order-1', + order_description: 'foo', + lang: 'CS', + callback: { return_url: 'http://localhost', + notification_url: 'http://localhost/2' } } } + let(:recurrence_params) { { recurrence: { recurrence_cycle: 'WEEK', recurrence_period: 10, recurrence_date_to: '2050-01-01' } } } + + it 'returns existing payment for standard payment' do + expect(@gateway.create(params)).to include( + "order_number" => "order-1", + "state" => "CREATED", + "amount" => 10000, + "currency" => "CZK", + "payer" => include( + "allowed_payment_instruments" => ["PAYMENT_CARD"], + "contact" => include( + "first_name" => "John", + "last_name" => "Doe", + "email" => "john@example.com" + ) + ), + "lang" => "cs" + ) + end + + it 'returns existing payment for recurrent payment' do + expect(@gateway.create(params.merge(recurrence_params))).to include( + "order_number" => "order-1", + "state" => "CREATED", + "amount" => 10000, + "currency" => "CZK", + "payer" => include( + "allowed_payment_instruments" => ["PAYMENT_CARD"], + "contact" => include( + "first_name" => "John", + "last_name" => "Doe", + "email" => "john@example.com" + ) + ), + "recurrence" => { + "recurrence_cycle" => "WEEK", + "recurrence_period" => 10, + "recurrence_date_to" => "2050-01-01", + "recurrence_state" => "REQUESTED" + }, + "lang" => "cs" + ) + end + end + + describe 'retrieve' do + it 'returns existing payment' do + expect(@gateway.retrieve 3090060402).to include("id" => 3090060402) + end + + it 'returns gopay error when payment not found' do + expect { @gateway.retrieve 100 }.to raise_error(GoPay::Error) + end + end + + describe 'refund' do + # the payment has to be paid. Use gw_url to go to gateway and pay + it 'returns existing payment' do + expect(@gateway.refund 3090066980, 10000).to include("id" => 3090066980, "result" => "FINISHED") + end + + it 'returns gopay error when payment not found' do + expect { @gateway.refund 100, 100 }.to raise_error(GoPay::Error) + end + end + + describe 'void_recurrence' do + # the payment has to be paid. Use gw_url to go to gateway and pay + it 'returns existing payment' do + expect(@gateway.void_recurrence 3090066941).to include("id" => 3090066941) + end + + it 'returns gopay error when payment not found' do + expect { @gateway.void_recurrence 100 }.to raise_error(GoPay::Error) + end + end +end \ No newline at end of file diff --git a/spec/gopay_spec.rb b/spec/payment_spec.rb similarity index 73% rename from spec/gopay_spec.rb rename to spec/payment_spec.rb index dd71eef..4157f14 100644 --- a/spec/gopay_spec.rb +++ b/spec/payment_spec.rb @@ -1,11 +1,18 @@ require 'spec_helper' +GoPay.configure do |config| + config.gate = ENV['GOPAY_GATE'] + config.goid = ENV['GOPAY_1_GOID'] + config.client_id = ENV['GOPAY_1_CLIENT_ID'] + config.client_secret = ENV['GOPAY_1_CLIENT_SECRET'] +end + describe GoPay::Payment, vcr: VCR_OPTIONS do subject { described_class } describe 'retrieve' do it 'returns existing payment' do - expect(subject.retrieve 3026370321).to include("id" => 3026370321) + expect(subject.retrieve 3090060402).to include("id" => 3090060402) end it 'returns gopay error when payment not found' do @@ -13,10 +20,10 @@ end end - # find a new payment after you delete casette describe 'void_recurrence' do + # the payment has to be paid. Use gw_url to go to gateway and pay it 'returns existing payment' do - expect(subject.void_recurrence 3027321817).to include("id" => 3027321817) + expect(subject.void_recurrence 3090067123).to include("id" => 3090067123) end it 'returns gopay error when payment not found' do @@ -24,10 +31,10 @@ end end - # find a new payment after you delete casette describe 'refund' do + # the payment has to be paid. Use gw_url to go to gateway and pay it 'returns existing payment' do - expect(subject.refund 3027334050, 46900).to include("id" => 3027334050) + expect(subject.refund 3090067162, 10000).to include("id" => 3090067162, "result" => "FINISHED") end it 'returns gopay error when payment not found' do @@ -36,7 +43,7 @@ end describe 'create' do - let(:params) { { payer: { allowed_payment_instruments: ["BANK_ACCOUNT"], + let(:params) { { payer: { allowed_payment_instruments: ["PAYMENT_CARD"], contact: { first_name: 'John', last_name: 'Doe', email: 'john@example.com' } }, @@ -47,7 +54,7 @@ lang: 'CS', callback: { return_url: 'http://localhost', notification_url: 'http://localhost/2' } } } - let(:recurrence_params) { { recurrence: { recurrence_cycle: 'WEEK', recurrence_period: 10, recurrence_date_to: '2018-01-01' } } } + let(:recurrence_params) { { recurrence: { recurrence_cycle: 'WEEK', recurrence_period: 10, recurrence_date_to: '2050-01-01' } } } it 'returns existing payment for standard payment' do expect(GoPay::Payment.create(params)).to include( @@ -56,14 +63,13 @@ "amount" => 10000, "currency" => "CZK", "payer" => include( - "allowed_payment_instruments" => ["BANK_ACCOUNT"], + "allowed_payment_instruments" => ["PAYMENT_CARD"], "contact" => include( "first_name" => "John", "last_name" => "Doe", "email" => "john@example.com" ) ), - "recurrence" => nil, "lang" => "cs" ) end @@ -75,7 +81,7 @@ "amount" => 10000, "currency" => "CZK", "payer" => include( - "allowed_payment_instruments" => ["BANK_ACCOUNT"], + "allowed_payment_instruments" => ["PAYMENT_CARD"], "contact" => include( "first_name" => "John", "last_name" => "Doe", @@ -85,7 +91,7 @@ "recurrence" => { "recurrence_cycle" => "WEEK", "recurrence_period" => 10, - "recurrence_date_to" => "2018-01-01", + "recurrence_date_to" => "2050-01-01", "recurrence_state" => "REQUESTED" }, "lang" => "cs" diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index e1814c8..914f7be 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,8 +1,12 @@ -$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__) +require 'simplecov' +require 'coveralls' +SimpleCov.start +Coveralls.wear! -require 'gopay' +require 'dotenv/load' require 'vcr' require 'addressable/uri' +require 'gopay' VCR.configure do |config| config.cassette_library_dir = 'spec/cassettes' @@ -28,15 +32,5 @@ end end -VCR_OPTIONS = { :match_requests_on => [:host, :path, :query] } +VCR_OPTIONS = { match_requests_on: [:host, :path, :query], preserve_exact_body_bytes: false, decode_compressed_response: true } # we cannot use default :uri matcher because the secret is in the URI https://23423423:secret@testgw.gopay.cz/api/oauth2/token -# TODO add :body - -GoPay.configure do |config| - config.return_host = 'localhost' - config.notification_host = 'localhost' - config.gate = 'https://testgw.gopay.cz' - config.goid = 'goid' - config.client_id = 'clientid' - config.client_secret = 'clientsecret' -end