adyen-ruby-api-library 6.0.0 → 10.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/CODEOWNERS +1 -1
- data/.github/release.yml +18 -0
- data/.github/workflows/codeql.yml +37 -0
- data/.github/workflows/label_new_issues.yml +15 -0
- data/.github/workflows/release.yml +40 -0
- data/.github/workflows/ruby.yml +2 -2
- data/.github/workflows/rubygems_release.yml +18 -0
- data/.github/workflows/stale.yml +26 -0
- data/.gitignore +3 -0
- data/.rubocop.yml +8 -0
- data/CONTRIBUTING.md +1 -1
- data/Gemfile +7 -7
- data/Makefile +79 -0
- data/README.md +158 -20
- data/Rakefile +3 -3
- data/VERSION +2 -0
- data/adyen-ruby-api-library.gemspec +6 -3
- data/bin/console +2 -2
- data/lib/adyen/client.rb +213 -99
- data/lib/adyen/errors.rb +30 -22
- data/lib/adyen/hash_with_accessors.rb +12 -7
- data/lib/adyen/services/balanceControlService.rb +27 -0
- data/lib/adyen/services/balancePlatform/account_holders_api.rb +76 -0
- data/lib/adyen/services/balancePlatform/balance_accounts_api.rb +116 -0
- data/lib/adyen/services/balancePlatform/bank_account_validation_api.rb +26 -0
- data/lib/adyen/services/balancePlatform/card_orders_api.rb +36 -0
- data/lib/adyen/services/balancePlatform/grant_accounts_api.rb +26 -0
- data/lib/adyen/services/balancePlatform/grant_offers_api.rb +36 -0
- data/lib/adyen/services/balancePlatform/manage_card_pin_api.rb +46 -0
- data/lib/adyen/services/balancePlatform/manage_sca_devices_api.rb +56 -0
- data/lib/adyen/services/balancePlatform/network_tokens_api.rb +36 -0
- data/lib/adyen/services/balancePlatform/payment_instrument_groups_api.rb +46 -0
- data/lib/adyen/services/balancePlatform/payment_instruments_api.rb +86 -0
- data/lib/adyen/services/balancePlatform/platform_api.rb +46 -0
- data/lib/adyen/services/balancePlatform/transaction_rules_api.rb +56 -0
- data/lib/adyen/services/balancePlatform/transfer_routes_api.rb +26 -0
- data/lib/adyen/services/balancePlatform.rb +89 -0
- data/lib/adyen/services/binLookup.rb +37 -0
- data/lib/adyen/services/checkout/donations_api.rb +36 -0
- data/lib/adyen/services/checkout/modifications_api.rb +76 -0
- data/lib/adyen/services/checkout/orders_api.rb +46 -0
- data/lib/adyen/services/checkout/payment_links_api.rb +46 -0
- data/lib/adyen/services/checkout/payments_api.rb +76 -0
- data/lib/adyen/services/checkout/recurring_api.rb +46 -0
- data/lib/adyen/services/checkout/utility_api.rb +48 -0
- data/lib/adyen/services/checkout.rb +29 -108
- data/lib/adyen/services/dataProtection.rb +27 -0
- data/lib/adyen/services/disputes.rb +67 -0
- data/lib/adyen/services/legalEntityManagement/business_lines_api.rb +56 -0
- data/lib/adyen/services/legalEntityManagement/documents_api.rb +56 -0
- data/lib/adyen/services/legalEntityManagement/hosted_onboarding_api.rb +46 -0
- data/lib/adyen/services/legalEntityManagement/legal_entities_api.rb +76 -0
- data/lib/adyen/services/legalEntityManagement/pci_questionnaires_api.rb +66 -0
- data/lib/adyen/services/legalEntityManagement/tax_e_delivery_consent_api.rb +36 -0
- data/lib/adyen/services/legalEntityManagement/terms_of_service_api.rb +66 -0
- data/lib/adyen/services/legalEntityManagement/transfer_instruments_api.rb +56 -0
- data/lib/adyen/services/legalEntityManagement.rb +59 -0
- data/lib/adyen/services/management/account_company_level_api.rb +46 -0
- data/lib/adyen/services/management/account_merchant_level_api.rb +56 -0
- data/lib/adyen/services/management/account_store_level_api.rb +96 -0
- data/lib/adyen/services/management/allowed_origins_company_level_api.rb +56 -0
- data/lib/adyen/services/management/allowed_origins_merchant_level_api.rb +56 -0
- data/lib/adyen/services/management/android_files_company_level_api.rb +76 -0
- data/lib/adyen/services/management/api_credentials_company_level_api.rb +56 -0
- data/lib/adyen/services/management/api_credentials_merchant_level_api.rb +56 -0
- data/lib/adyen/services/management/api_key_company_level_api.rb +26 -0
- data/lib/adyen/services/management/api_key_merchant_level_api.rb +26 -0
- data/lib/adyen/services/management/client_key_company_level_api.rb +26 -0
- data/lib/adyen/services/management/client_key_merchant_level_api.rb +26 -0
- data/lib/adyen/services/management/my_api_credential_api.rb +76 -0
- data/lib/adyen/services/management/payment_methods_merchant_level_api.rb +76 -0
- data/lib/adyen/services/management/payout_settings_merchant_level_api.rb +66 -0
- data/lib/adyen/services/management/split_configuration_merchant_level_api.rb +106 -0
- data/lib/adyen/services/management/terminal_actions_company_level_api.rb +36 -0
- data/lib/adyen/services/management/terminal_actions_terminal_level_api.rb +26 -0
- data/lib/adyen/services/management/terminal_orders_company_level_api.rb +116 -0
- data/lib/adyen/services/management/terminal_orders_merchant_level_api.rb +116 -0
- data/lib/adyen/services/management/terminal_settings_company_level_api.rb +56 -0
- data/lib/adyen/services/management/terminal_settings_merchant_level_api.rb +56 -0
- data/lib/adyen/services/management/terminal_settings_store_level_api.rb +96 -0
- data/lib/adyen/services/management/terminal_settings_terminal_level_api.rb +56 -0
- data/lib/adyen/services/management/terminals_terminal_level_api.rb +36 -0
- data/lib/adyen/services/management/users_company_level_api.rb +56 -0
- data/lib/adyen/services/management/users_merchant_level_api.rb +56 -0
- data/lib/adyen/services/management/webhooks_company_level_api.rb +86 -0
- data/lib/adyen/services/management/webhooks_merchant_level_api.rb +86 -0
- data/lib/adyen/services/management.rb +164 -0
- data/lib/adyen/services/marketpay.rb +42 -36
- data/lib/adyen/services/payment.rb +149 -0
- data/lib/adyen/services/paymentsApp.rb +67 -0
- data/lib/adyen/services/payout/initialization_api.rb +46 -0
- data/lib/adyen/services/payout/instant_payouts_api.rb +26 -0
- data/lib/adyen/services/payout/reviewing_api.rb +36 -0
- data/lib/adyen/services/payout.rb +34 -0
- data/lib/adyen/services/posMobile.rb +27 -0
- data/lib/adyen/services/posTerminalManagement.rb +82 -0
- data/lib/adyen/services/recurring.rb +70 -13
- data/lib/adyen/services/service.rb +8 -2
- data/lib/adyen/services/storedValue.rb +77 -0
- data/lib/adyen/services/terminalCloudAPI.rb +38 -0
- data/lib/adyen/services/transfers/capital_api.rb +55 -0
- data/lib/adyen/services/transfers/transactions_api.rb +36 -0
- data/lib/adyen/services/transfers/transfers_api.rb +76 -0
- data/lib/adyen/services/transfers.rb +34 -0
- data/lib/adyen/utils/hmac_validator.rb +52 -22
- data/lib/adyen/version.rb +2 -2
- data/lib/adyen-ruby-api-library.rb +23 -15
- data/renovate.json +3 -3
- data/spec/account_spec.rb +20 -20
- data/spec/balance_control_spec.rb +43 -0
- data/spec/balance_platform_spec.rb +129 -0
- data/spec/bin_lookup_spec.rb +69 -11
- data/spec/checkout-oauth_spec.rb +588 -0
- data/spec/checkout_spec.rb +591 -314
- data/spec/client_spec.rb +240 -45
- data/spec/data_protection_spec.rb +4 -4
- data/spec/disputes_spec.rb +45 -0
- data/spec/errors_spec.rb +44 -15
- data/spec/fund_spec.rb +10 -10
- data/spec/hash_with_accessors_spec.rb +18 -8
- data/spec/hop_spec.rb +4 -4
- data/spec/lem_spec.rb +63 -0
- data/spec/management-oauth_spec.rb +62 -0
- data/spec/management_spec.rb +66 -0
- data/spec/mocks/requests/BalanceControl/balance_transfer.json +10 -0
- data/spec/mocks/requests/BalancePlatform/create_account_holder.json +5 -0
- data/spec/mocks/requests/BalancePlatform/update_account_holder.json +10 -0
- data/spec/mocks/requests/Checkout/amount_updates.json +22 -0
- data/spec/mocks/requests/Checkout/apple_pay_sessions.json +5 -0
- data/spec/mocks/requests/Checkout/capture.json +34 -0
- data/spec/mocks/requests/Checkout/generic_cancel.json +5 -0
- data/spec/mocks/requests/Checkout/modifications_request.json +0 -0
- data/spec/mocks/requests/Checkout/psp_cancel.json +4 -0
- data/spec/mocks/requests/Checkout/refund.json +34 -0
- data/spec/mocks/requests/DisputesService/retrieve_applicable_defense_reasons.json +4 -0
- data/spec/mocks/requests/LegalEntityManagement/create_business_line.json +15 -0
- data/spec/mocks/requests/Management/create_store.json +15 -0
- data/spec/mocks/requests/Recurring/create_permit.json +6 -0
- data/spec/mocks/requests/StoredValue/issue_giftcard.json +12 -0
- data/spec/mocks/requests/TerminalCloudAPI/connected_terminals.json +3 -0
- data/spec/mocks/requests/TerminalCloudAPI/sync_payment.json +29 -0
- data/spec/mocks/requests/Transfers/get_transactions.json +82 -0
- data/spec/mocks/requests/Transfers/make_transfer.json +32 -0
- data/spec/mocks/responses/BalanceControl/balance_transfer.json +14 -0
- data/spec/mocks/responses/BalancePlatform/create_account_holder.json +41 -0
- data/spec/mocks/responses/BalancePlatform/get_balance_account.json +15 -0
- data/spec/mocks/responses/BalancePlatform/update_account_holder.json +16 -0
- data/spec/mocks/responses/Checkout/amount_updates.json +24 -0
- data/spec/mocks/responses/Checkout/apple_pay_sessions.json +3 -0
- data/spec/mocks/responses/Checkout/capture.json +37 -0
- data/spec/mocks/responses/Checkout/generic_cancel.json +7 -0
- data/spec/mocks/responses/Checkout/modifications.json +0 -0
- data/spec/mocks/responses/Checkout/psp_cancel.json +7 -0
- data/spec/mocks/responses/Checkout/refund.json +37 -0
- data/spec/mocks/responses/Checkout/stored_payment_methods.json +1 -0
- data/spec/mocks/responses/DisputesService/retrieve_applicable_defense_reasons.json +71 -0
- data/spec/mocks/responses/LegalEntityManagement/create_business_line.json +17 -0
- data/spec/mocks/responses/Management/create_store.json +23 -0
- data/spec/mocks/responses/Management/get_companies.json +42 -0
- data/spec/mocks/responses/Recurring/create_permit.json +4 -0
- data/spec/mocks/responses/StoredValue/issue_giftcard.json +13 -0
- data/spec/mocks/responses/TerminalCloudAPI/connected_terminals.json +5 -0
- data/spec/mocks/responses/TerminalCloudAPI/sync_payment.json +18 -0
- data/spec/mocks/responses/Transfers/get_transactions.json +82 -0
- data/spec/mocks/responses/Transfers/make_transfer.json +36 -0
- data/spec/mocks/responses/Webhooks/backslash_webhook.json +41 -0
- data/spec/mocks/responses/Webhooks/colon_webhook.json +41 -0
- data/spec/mocks/responses/Webhooks/forwardslash_webhook.json +41 -0
- data/spec/mocks/responses/Webhooks/mixed_webhook.json +41 -0
- data/spec/notification_spec.rb +9 -9
- data/spec/payments_spec.rb +39 -22
- data/spec/payouts_spec.rb +39 -15
- data/spec/pos_terminal_management_spec.rb +44 -0
- data/spec/recurring_spec.rb +8 -8
- data/spec/service_spec.rb +4 -0
- data/spec/spec_helper.rb +42 -46
- data/spec/stored_value_spec.rb +44 -0
- data/spec/terminal_cloud_api_spec.rb +91 -0
- data/spec/transfers_spec.rb +64 -0
- data/spec/utils/hmac_validator_spec.rb +53 -23
- data/templates/api-single.mustache +32 -0
- data/templates/api-small.mustache +39 -0
- data/templates/api.mustache +38 -0
- data/templates/config.yaml +10 -0
- metadata +160 -47
- data/.github/dependabot.yml +0 -8
- data/docs/checkout.html +0 -128
- data/docs/index.html +0 -50
- data/docs/install-library.html +0 -61
- data/docs/javascripts/prism.js +0 -5
- data/docs/javascripts/scale.fix.js +0 -17
- data/docs/marketpay.html +0 -171
- data/docs/params.json +0 -1
- data/docs/payment.html +0 -106
- data/docs/payout.html +0 -135
- data/docs/recurring.html +0 -113
- data/docs/stylesheets/github-light.css +0 -115
- data/docs/stylesheets/prism.css +0 -140
- data/docs/stylesheets/styles.css +0 -324
- data/docs/using-library.html +0 -67
- data/lib/adyen/services/bin_lookup.rb +0 -18
- data/lib/adyen/services/data_protection.rb +0 -17
- data/lib/adyen/services/dispute.rb +0 -20
- data/lib/adyen/services/payments.rb +0 -34
- data/lib/adyen/services/payouts.rb +0 -22
- data/lib/adyen/services/postfmapi.rb +0 -19
- data/spec/dispute_spec.rb +0 -17
- data/spec/mocks/requests/DisputeService/defend_dispute.json +0 -5
- data/spec/mocks/requests/DisputeService/delete_dispute_defense_document.json +0 -5
- data/spec/mocks/requests/DisputeService/retrieve_applicable_defense_reasons.json +0 -4
- data/spec/mocks/requests/DisputeService/supply_defense_document.json +0 -11
- data/spec/mocks/requests/Recurring/store_token.json +0 -15
- data/spec/mocks/responses/DisputeService/defend_dispute.json +0 -5
- data/spec/mocks/responses/DisputeService/delete_dispute_defense_document.json +0 -5
- data/spec/mocks/responses/DisputeService/retrieve_applicable_defense_reasons.json +0 -28
- data/spec/mocks/responses/DisputeService/supply_defense_document.json +0 -5
- data/spec/mocks/responses/Recurring/store_token.json +0 -7
- data/spec/postfmapi_spec.rb +0 -16
@@ -0,0 +1,588 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "json"
|
3
|
+
|
4
|
+
# rubocop:disable Metrics/BlockLength
|
5
|
+
RSpec.describe "Adyen::Checkout OAuth authentication", service: "checkout" do
|
6
|
+
before(:all) do
|
7
|
+
@shared_values = {
|
8
|
+
client: create_client(:oauth),
|
9
|
+
service: "Checkout",
|
10
|
+
}
|
11
|
+
@auth_header = { "Authorization": "Bearer #{@shared_values[:client].oauth_token}" }
|
12
|
+
end
|
13
|
+
|
14
|
+
# must be created manually because every field in the response is an array
|
15
|
+
it "makes a payment_methods call", focus: true do
|
16
|
+
request_body = JSON.parse(json_from_file("mocks/requests/Checkout/payment_methods.json"))
|
17
|
+
|
18
|
+
response_body = json_from_file("mocks/responses/Checkout/payment_methods.json")
|
19
|
+
|
20
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "paymentMethods", @shared_values[:client].checkout.version)
|
21
|
+
WebMock.stub_request(:post, url).
|
22
|
+
with(
|
23
|
+
body: request_body,
|
24
|
+
headers: @auth_header
|
25
|
+
).
|
26
|
+
to_return(
|
27
|
+
body: response_body
|
28
|
+
)
|
29
|
+
|
30
|
+
result = @shared_values[:client].checkout.payments_api.payment_methods(request_body)
|
31
|
+
response_hash = result.response
|
32
|
+
|
33
|
+
expect(result.status).
|
34
|
+
to eq(200)
|
35
|
+
expect(response_hash).
|
36
|
+
to eq(JSON.parse(response_body))
|
37
|
+
expect(response_hash).
|
38
|
+
to be_a Adyen::HashWithAccessors
|
39
|
+
expect(response_hash).
|
40
|
+
to be_a_kind_of Hash
|
41
|
+
end
|
42
|
+
|
43
|
+
it "makes a paymentMethods/balance call" do
|
44
|
+
request_body = JSON.parse(json_from_file("mocks/requests/Checkout/payment_methods_balance.json"))
|
45
|
+
|
46
|
+
response_body = json_from_file("mocks/responses/Checkout/payment_methods_balance.json")
|
47
|
+
|
48
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "paymentMethods/balance", @shared_values[:client].checkout.version)
|
49
|
+
WebMock.stub_request(:post, url).
|
50
|
+
with(
|
51
|
+
body: request_body,
|
52
|
+
headers: @auth_header
|
53
|
+
).
|
54
|
+
to_return(
|
55
|
+
body: response_body
|
56
|
+
)
|
57
|
+
|
58
|
+
result = @shared_values[:client].checkout.orders_api.get_balance_of_gift_card(request_body)
|
59
|
+
# result.response is already a Ruby hash (rather than an unparsed JSON string)
|
60
|
+
response_hash = result.response
|
61
|
+
|
62
|
+
expect(result.status).
|
63
|
+
to eq(200)
|
64
|
+
expect(response_hash).
|
65
|
+
to eq(JSON.parse(response_body))
|
66
|
+
expect(response_hash).
|
67
|
+
to be_a Adyen::HashWithAccessors
|
68
|
+
expect(response_hash).
|
69
|
+
to be_a_kind_of Hash
|
70
|
+
expect(response_hash["balance"]).
|
71
|
+
to eq("100")
|
72
|
+
end
|
73
|
+
|
74
|
+
# must be created manually due to payments/details format
|
75
|
+
it "makes a payments/details call" do
|
76
|
+
request_body = JSON.parse(json_from_file("mocks/requests/Checkout/payment-details.json"))
|
77
|
+
|
78
|
+
response_body = json_from_file("mocks/responses/Checkout/payment-details.json")
|
79
|
+
|
80
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "payments/details", @shared_values[:client].checkout.version)
|
81
|
+
WebMock.stub_request(:post, url).
|
82
|
+
with(
|
83
|
+
body: request_body,
|
84
|
+
headers: @auth_header
|
85
|
+
).
|
86
|
+
to_return(
|
87
|
+
body: response_body
|
88
|
+
)
|
89
|
+
|
90
|
+
result = @shared_values[:client].checkout.payments_api.payments_details(request_body)
|
91
|
+
# result.response is already a Ruby hash (rather than an unparsed JSON string)
|
92
|
+
response_hash = result.response
|
93
|
+
|
94
|
+
expect(result.status).
|
95
|
+
to eq(200)
|
96
|
+
expect(response_hash).
|
97
|
+
to eq(JSON.parse(response_body))
|
98
|
+
expect(response_hash).
|
99
|
+
to be_a Adyen::HashWithAccessors
|
100
|
+
expect(response_hash).
|
101
|
+
to be_a_kind_of Hash
|
102
|
+
expect(response_hash["resultCode"]).
|
103
|
+
to eq("RedirectShopper")
|
104
|
+
expect(response_hash.resultCode).
|
105
|
+
to eq("RedirectShopper")
|
106
|
+
end
|
107
|
+
|
108
|
+
# must be created manually due to paymentsLinks format
|
109
|
+
it "makes a paymentLinks call" do
|
110
|
+
request_body = JSON.parse(json_from_file("mocks/requests/Checkout/payment_links.json"))
|
111
|
+
|
112
|
+
response_body = json_from_file("mocks/responses/Checkout/payment_links.json")
|
113
|
+
|
114
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "paymentLinks", @shared_values[:client].checkout.version)
|
115
|
+
WebMock.stub_request(:post, url).
|
116
|
+
with(
|
117
|
+
body: request_body,
|
118
|
+
headers: @auth_header
|
119
|
+
).
|
120
|
+
to_return(
|
121
|
+
body: response_body
|
122
|
+
)
|
123
|
+
|
124
|
+
result = @shared_values[:client].checkout.payment_links_api.payment_links(request_body)
|
125
|
+
response_hash = result.response
|
126
|
+
|
127
|
+
expect(result.status).
|
128
|
+
to eq(200)
|
129
|
+
expect(response_hash).
|
130
|
+
to eq(JSON.parse(response_body))
|
131
|
+
expect(response_hash).
|
132
|
+
to be_a Adyen::HashWithAccessors
|
133
|
+
expect(response_hash).
|
134
|
+
to be_a_kind_of Hash
|
135
|
+
end
|
136
|
+
|
137
|
+
# must be created manually due to paymentsLinks/{linkId} format
|
138
|
+
it "makes a get paymentLinks/{linkId} call" do
|
139
|
+
response_body = json_from_file("mocks/responses/Checkout/get-payment-link.json")
|
140
|
+
|
141
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "paymentLinks/1", @shared_values[:client].checkout.version)
|
142
|
+
WebMock.stub_request(:get, url).
|
143
|
+
with(
|
144
|
+
headers: @auth_header
|
145
|
+
).
|
146
|
+
to_return(
|
147
|
+
body: response_body
|
148
|
+
)
|
149
|
+
|
150
|
+
result = @shared_values[:client].checkout.payment_links_api.get_payment_link("1")
|
151
|
+
response_hash = result.response
|
152
|
+
|
153
|
+
expect(result.status).
|
154
|
+
to eq(200)
|
155
|
+
expect(response_hash).
|
156
|
+
to eq(JSON.parse(response_body))
|
157
|
+
expect(response_hash).
|
158
|
+
to be_a Adyen::HashWithAccessors
|
159
|
+
expect(response_hash).
|
160
|
+
to be_a_kind_of Hash
|
161
|
+
expect(response_hash["status"]).
|
162
|
+
to eq("active")
|
163
|
+
expect(response_hash.id).
|
164
|
+
to eq("MockId")
|
165
|
+
end
|
166
|
+
|
167
|
+
# must be created manually due to paymentsLinks/{linkId} format
|
168
|
+
it "makes a patch paymentLinks/{linkId} call" do
|
169
|
+
request_body = {
|
170
|
+
:status => "expired",
|
171
|
+
}
|
172
|
+
|
173
|
+
response_body = json_from_file("mocks/responses/Checkout/update-payment-link.json")
|
174
|
+
|
175
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "paymentLinks/1", @shared_values[:client].checkout.version)
|
176
|
+
WebMock.stub_request(:patch, url).
|
177
|
+
with(
|
178
|
+
body: request_body,
|
179
|
+
headers: @auth_header
|
180
|
+
).
|
181
|
+
to_return(
|
182
|
+
body: response_body
|
183
|
+
)
|
184
|
+
|
185
|
+
result = @shared_values[:client].checkout.payment_links_api.update_payment_link(request_body, "1")
|
186
|
+
response_hash = result.response
|
187
|
+
|
188
|
+
expect(result.status).
|
189
|
+
to eq(200)
|
190
|
+
expect(response_hash).
|
191
|
+
to eq(JSON.parse(response_body))
|
192
|
+
expect(response_hash).
|
193
|
+
to be_a Adyen::HashWithAccessors
|
194
|
+
expect(response_hash).
|
195
|
+
to be_a_kind_of Hash
|
196
|
+
expect(response_hash["status"]).
|
197
|
+
to eq("expired")
|
198
|
+
expect(response_hash.id).
|
199
|
+
to eq("MockId")
|
200
|
+
end
|
201
|
+
|
202
|
+
it "makes an orders call" do
|
203
|
+
request_body = JSON.parse(json_from_file("mocks/requests/Checkout/orders.json"))
|
204
|
+
|
205
|
+
response_body = json_from_file("mocks/responses/Checkout/orders.json")
|
206
|
+
|
207
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "orders", @shared_values[:client].checkout.version)
|
208
|
+
WebMock.stub_request(:post, url).
|
209
|
+
with(
|
210
|
+
body: request_body,
|
211
|
+
headers: @auth_header
|
212
|
+
).
|
213
|
+
to_return(
|
214
|
+
body: response_body
|
215
|
+
)
|
216
|
+
|
217
|
+
result = @shared_values[:client].checkout.orders_api.orders(request_body)
|
218
|
+
response_hash = result.response
|
219
|
+
|
220
|
+
expect(result.status).
|
221
|
+
to eq(200)
|
222
|
+
expect(response_hash).
|
223
|
+
to eq(JSON.parse(response_body))
|
224
|
+
expect(response_hash).
|
225
|
+
to be_a Adyen::HashWithAccessors
|
226
|
+
expect(response_hash).
|
227
|
+
to be_a_kind_of Hash
|
228
|
+
expect(response_hash["remainingAmount"]["value"]).
|
229
|
+
to eq(100)
|
230
|
+
end
|
231
|
+
|
232
|
+
it "makes an orders/cancel call" do
|
233
|
+
request_body = JSON.parse(json_from_file("mocks/requests/Checkout/orders_cancel.json"))
|
234
|
+
|
235
|
+
response_body = json_from_file("mocks/responses/Checkout/orders_cancel.json")
|
236
|
+
|
237
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "orders/cancel", @shared_values[:client].checkout.version)
|
238
|
+
WebMock.stub_request(:post, url).
|
239
|
+
with(
|
240
|
+
body: request_body,
|
241
|
+
headers: @auth_header
|
242
|
+
).
|
243
|
+
to_return(
|
244
|
+
body: response_body
|
245
|
+
)
|
246
|
+
|
247
|
+
result = @shared_values[:client].checkout.orders_api.cancel_order(request_body)
|
248
|
+
response_hash = result.response
|
249
|
+
|
250
|
+
expect(result.status).
|
251
|
+
to eq(200)
|
252
|
+
expect(response_hash).
|
253
|
+
to eq(JSON.parse(response_body))
|
254
|
+
expect(response_hash).
|
255
|
+
to be_a Adyen::HashWithAccessors
|
256
|
+
expect(response_hash).
|
257
|
+
to be_a_kind_of Hash
|
258
|
+
expect(response_hash["resultCode"]).
|
259
|
+
to eq("cancelled")
|
260
|
+
end
|
261
|
+
|
262
|
+
it "makes an applePay/sessions call" do
|
263
|
+
request_body = JSON.parse(json_from_file("mocks/requests/Checkout/apple_pay_sessions.json"))
|
264
|
+
|
265
|
+
response_body = json_from_file("mocks/responses/Checkout/apple_pay_sessions.json")
|
266
|
+
|
267
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "applePay/sessions", @shared_values[:client].checkout.version)
|
268
|
+
WebMock.stub_request(:post, url).
|
269
|
+
with(
|
270
|
+
body: request_body,
|
271
|
+
headers: @auth_header
|
272
|
+
).
|
273
|
+
to_return(
|
274
|
+
body: response_body
|
275
|
+
)
|
276
|
+
|
277
|
+
result = @shared_values[:client].checkout.utility_api.get_apple_pay_session(request_body)
|
278
|
+
response_hash = result.response
|
279
|
+
|
280
|
+
expect(result.status).
|
281
|
+
to eq(200)
|
282
|
+
expect(response_hash).
|
283
|
+
to eq(JSON.parse(response_body))
|
284
|
+
expect(response_hash).
|
285
|
+
to be_a Adyen::HashWithAccessors
|
286
|
+
expect(response_hash).
|
287
|
+
to be_a_kind_of Hash
|
288
|
+
expect(response_hash["data"]).
|
289
|
+
to eq("LARGE_BLOB_HERE")
|
290
|
+
end
|
291
|
+
|
292
|
+
it "makes a sessions call" do
|
293
|
+
request_body = JSON.parse(json_from_file("mocks/requests/Checkout/sessions.json"))
|
294
|
+
|
295
|
+
response_body = json_from_file("mocks/responses/Checkout/sessions-success.json")
|
296
|
+
|
297
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "sessions", @shared_values[:client].checkout.version)
|
298
|
+
WebMock.stub_request(:post, url).
|
299
|
+
with(
|
300
|
+
body: request_body,
|
301
|
+
headers: @auth_header
|
302
|
+
)
|
303
|
+
.to_return(body: response_body, status: 201)
|
304
|
+
|
305
|
+
result = @shared_values[:client].checkout.payments_api.sessions(request_body)
|
306
|
+
response_hash = result.response
|
307
|
+
|
308
|
+
expect(result.status).
|
309
|
+
to eq(201)
|
310
|
+
expect(response_hash).
|
311
|
+
to eq(JSON.parse(response_body))
|
312
|
+
expect(response_hash).
|
313
|
+
to be_a Adyen::HashWithAccessors
|
314
|
+
expect(response_hash).
|
315
|
+
to be_a_kind_of Hash
|
316
|
+
end
|
317
|
+
|
318
|
+
it "makes a capture call" do
|
319
|
+
request_body = JSON.parse(json_from_file("mocks/requests/Checkout/capture.json"))
|
320
|
+
|
321
|
+
response_body = json_from_file("mocks/responses/Checkout/capture.json")
|
322
|
+
|
323
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "payments/12345/captures", @shared_values[:client].checkout.version)
|
324
|
+
WebMock.stub_request(:post, url).
|
325
|
+
with(
|
326
|
+
body: request_body,
|
327
|
+
headers: @auth_header
|
328
|
+
)
|
329
|
+
.to_return(body: response_body, status: 201)
|
330
|
+
|
331
|
+
result = @shared_values[:client].checkout.modifications_api.capture_authorised_payment(request_body, "12345")
|
332
|
+
response_hash = result.response
|
333
|
+
|
334
|
+
expect(result.status).
|
335
|
+
to eq(201)
|
336
|
+
expect(response_hash).
|
337
|
+
to eq(JSON.parse(response_body))
|
338
|
+
expect(response_hash).
|
339
|
+
to be_a Adyen::HashWithAccessors
|
340
|
+
expect(response_hash).
|
341
|
+
to be_a_kind_of Hash
|
342
|
+
expect(response_hash.reference).
|
343
|
+
to eq("123456789")
|
344
|
+
expect(response_hash.pspReference).
|
345
|
+
to eq("12345")
|
346
|
+
end
|
347
|
+
|
348
|
+
it "makes a psp specific cancel call" do
|
349
|
+
request_body = JSON.parse(json_from_file("mocks/requests/Checkout/psp_cancel.json"))
|
350
|
+
|
351
|
+
response_body = json_from_file("mocks/responses/Checkout/psp_cancel.json")
|
352
|
+
|
353
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "payments/12345/cancels", @shared_values[:client].checkout.version)
|
354
|
+
WebMock.stub_request(:post, url).
|
355
|
+
with(
|
356
|
+
body: request_body,
|
357
|
+
headers: @auth_header
|
358
|
+
)
|
359
|
+
.to_return(body: response_body, status: 201)
|
360
|
+
|
361
|
+
result = @shared_values[:client].checkout.modifications_api.cancel_authorised_payment_by_psp_reference(request_body, "12345")
|
362
|
+
response_hash = result.response
|
363
|
+
|
364
|
+
expect(result.status).
|
365
|
+
to eq(201)
|
366
|
+
expect(response_hash).
|
367
|
+
to eq(JSON.parse(response_body))
|
368
|
+
expect(response_hash).
|
369
|
+
to be_a Adyen::HashWithAccessors
|
370
|
+
expect(response_hash).
|
371
|
+
to be_a_kind_of Hash
|
372
|
+
expect(response_hash.reference).
|
373
|
+
to eq("123456789")
|
374
|
+
expect(response_hash.pspReference).
|
375
|
+
to eq("12345")
|
376
|
+
end
|
377
|
+
|
378
|
+
it "makes a psp specific refunds call" do
|
379
|
+
request_body = JSON.parse(json_from_file("mocks/requests/Checkout/refund.json"))
|
380
|
+
|
381
|
+
response_body = json_from_file("mocks/responses/Checkout/refund.json")
|
382
|
+
|
383
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "payments/12345/refunds", @shared_values[:client].checkout.version)
|
384
|
+
WebMock.stub_request(:post, url).
|
385
|
+
with(
|
386
|
+
body: request_body,
|
387
|
+
headers: @auth_header
|
388
|
+
)
|
389
|
+
.to_return(body: response_body, status: 201)
|
390
|
+
|
391
|
+
result = @shared_values[:client].checkout.modifications_api.refund_captured_payment(request_body, "12345")
|
392
|
+
response_hash = result.response
|
393
|
+
|
394
|
+
expect(result.status).
|
395
|
+
to eq(201)
|
396
|
+
expect(response_hash).
|
397
|
+
to eq(JSON.parse(response_body))
|
398
|
+
expect(response_hash).
|
399
|
+
to be_a Adyen::HashWithAccessors
|
400
|
+
expect(response_hash).
|
401
|
+
to be_a_kind_of Hash
|
402
|
+
expect(response_hash.reference).
|
403
|
+
to eq("123456789")
|
404
|
+
expect(response_hash.pspReference).
|
405
|
+
to eq("12345")
|
406
|
+
end
|
407
|
+
|
408
|
+
it "makes a psp specific reversals call" do
|
409
|
+
request_body = JSON.parse(json_from_file("mocks/requests/Checkout/psp_cancel.json"))
|
410
|
+
|
411
|
+
response_body = json_from_file("mocks/responses/Checkout/psp_cancel.json")
|
412
|
+
|
413
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "payments/12345/reversals", @shared_values[:client].checkout.version)
|
414
|
+
WebMock.stub_request(:post, url).
|
415
|
+
with(
|
416
|
+
body: request_body,
|
417
|
+
headers: @auth_header
|
418
|
+
)
|
419
|
+
.to_return(body: response_body, status: 201)
|
420
|
+
|
421
|
+
result = @shared_values[:client].checkout.modifications_api.refund_or_cancel_payment(request_body, "12345")
|
422
|
+
response_hash = result.response
|
423
|
+
|
424
|
+
expect(result.status).
|
425
|
+
to eq(201)
|
426
|
+
expect(response_hash).
|
427
|
+
to eq(JSON.parse(response_body))
|
428
|
+
expect(response_hash).
|
429
|
+
to be_a Adyen::HashWithAccessors
|
430
|
+
expect(response_hash).
|
431
|
+
to be_a_kind_of Hash
|
432
|
+
expect(response_hash.reference).
|
433
|
+
to eq("123456789")
|
434
|
+
expect(response_hash.pspReference).
|
435
|
+
to eq("12345")
|
436
|
+
end
|
437
|
+
|
438
|
+
it "makes a psp specific amountUpdates call" do
|
439
|
+
request_body = JSON.parse(json_from_file("mocks/requests/Checkout/amount_updates.json"))
|
440
|
+
|
441
|
+
response_body = json_from_file("mocks/responses/Checkout/amount_updates.json")
|
442
|
+
|
443
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "payments/12345/amountUpdates", @shared_values[:client].checkout.version)
|
444
|
+
WebMock.stub_request(:post, url).
|
445
|
+
with(
|
446
|
+
body: request_body,
|
447
|
+
headers: @auth_header
|
448
|
+
)
|
449
|
+
.to_return(body: response_body, status: 201)
|
450
|
+
|
451
|
+
result = @shared_values[:client].checkout.modifications_api.update_authorised_amount(request_body, "12345")
|
452
|
+
response_hash = result.response
|
453
|
+
|
454
|
+
expect(result.status).
|
455
|
+
to eq(201)
|
456
|
+
expect(response_hash).
|
457
|
+
to eq(JSON.parse(response_body))
|
458
|
+
expect(response_hash).
|
459
|
+
to be_a Adyen::HashWithAccessors
|
460
|
+
expect(response_hash).
|
461
|
+
to be_a_kind_of Hash
|
462
|
+
expect(response_hash.reference).
|
463
|
+
to eq("123456789")
|
464
|
+
expect(response_hash.pspReference).
|
465
|
+
to eq("12345")
|
466
|
+
end
|
467
|
+
|
468
|
+
it "makes a generic cancel call" do
|
469
|
+
request_body = JSON.parse(json_from_file("mocks/requests/Checkout/generic_cancel.json"))
|
470
|
+
|
471
|
+
response_body = json_from_file("mocks/responses/Checkout/generic_cancel.json")
|
472
|
+
|
473
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "cancels", @shared_values[:client].checkout.version)
|
474
|
+
WebMock.stub_request(:post, url).
|
475
|
+
with(
|
476
|
+
body: request_body,
|
477
|
+
headers: @auth_header
|
478
|
+
)
|
479
|
+
.to_return(body: response_body, status: 201)
|
480
|
+
|
481
|
+
result = @shared_values[:client].checkout.modifications_api.cancel_authorised_payment(request_body)
|
482
|
+
response_hash = result.response
|
483
|
+
|
484
|
+
expect(result.status).
|
485
|
+
to eq(201)
|
486
|
+
expect(response_hash).
|
487
|
+
to eq(JSON.parse(response_body))
|
488
|
+
expect(response_hash).
|
489
|
+
to be_a Adyen::HashWithAccessors
|
490
|
+
expect(response_hash).
|
491
|
+
to be_a_kind_of Hash
|
492
|
+
expect(response_hash.reference).
|
493
|
+
to eq("123456789")
|
494
|
+
expect(response_hash.pspReference).
|
495
|
+
to eq("12345")
|
496
|
+
end
|
497
|
+
|
498
|
+
it "makes a get storedPaymentMethods call" do
|
499
|
+
response_body = json_from_file("mocks/responses/Checkout/stored_payment_methods.json")
|
500
|
+
|
501
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "storedPaymentMethods?merchantAccount=TestMerchantAccount&shopperReference=test-1234", @shared_values[:client].checkout.version)
|
502
|
+
WebMock.stub_request(:get, url).
|
503
|
+
with(
|
504
|
+
headers: @auth_header
|
505
|
+
).
|
506
|
+
to_return(
|
507
|
+
body: response_body
|
508
|
+
)
|
509
|
+
|
510
|
+
result = @shared_values[:client].checkout.recurring_api.get_tokens_for_stored_payment_details(query_params: {"merchantAccount" => "TestMerchantAccount", "shopperReference" => "test-1234"})
|
511
|
+
response_hash = result.response
|
512
|
+
|
513
|
+
expect(result.status).
|
514
|
+
to eq(200)
|
515
|
+
expect(response_hash).
|
516
|
+
to eq(JSON.parse(response_body))
|
517
|
+
expect(response_hash).
|
518
|
+
to be_a Adyen::HashWithAccessors
|
519
|
+
expect(response_hash).
|
520
|
+
to be_a_kind_of Hash
|
521
|
+
expect(response_hash["shopperReference"]).
|
522
|
+
to eq("test-1234")
|
523
|
+
end
|
524
|
+
|
525
|
+
it "makes a delete storedPaymentMethods call" do
|
526
|
+
|
527
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "storedPaymentMethods/RL8FW7WZM6KXWD82?merchantAccount=TestMerchantAccount&shopperReference=test-1234", @shared_values[:client].checkout.version)
|
528
|
+
WebMock.stub_request(:delete, url).
|
529
|
+
with(
|
530
|
+
headers: @auth_header
|
531
|
+
).
|
532
|
+
to_return(
|
533
|
+
body: "{}"
|
534
|
+
)
|
535
|
+
|
536
|
+
result = @shared_values[:client].checkout.recurring_api.delete_token_for_stored_payment_details("RL8FW7WZM6KXWD82", query_params:{"merchantAccount" => "TestMerchantAccount", "shopperReference" => "test-1234"})
|
537
|
+
response_hash = result.response
|
538
|
+
|
539
|
+
expect(result.status).
|
540
|
+
to eq(200)
|
541
|
+
end
|
542
|
+
|
543
|
+
it "tests sending the application headers" do
|
544
|
+
response_body = json_from_file("mocks/responses/Checkout/stored_payment_methods.json")
|
545
|
+
|
546
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "storedPaymentMethods?merchantAccount=TestMerchantAccount&shopperReference=test-1234", @shared_values[:client].checkout.version)
|
547
|
+
WebMock.stub_request(:get, url).
|
548
|
+
with(
|
549
|
+
headers: @auth_header
|
550
|
+
).
|
551
|
+
to_return(
|
552
|
+
body: response_body
|
553
|
+
)
|
554
|
+
|
555
|
+
result = @shared_values[:client].checkout.recurring_api.get_tokens_for_stored_payment_details(query_params:{"merchantAccount" => "TestMerchantAccount", "shopperReference" => "test-1234"})
|
556
|
+
expect(
|
557
|
+
a_request(:get, "http://localhost:3001/v71/storedPaymentMethods?merchantAccount=TestMerchantAccount&shopperReference=test-1234")
|
558
|
+
.with(headers: {
|
559
|
+
'Accept' => '*/*',
|
560
|
+
'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
|
561
|
+
'Adyen-Library-Name' => 'adyen-ruby-api-library',
|
562
|
+
'Adyen-Library-Version' => Adyen::VERSION,
|
563
|
+
'Content-Type' => 'application/json',
|
564
|
+
'User-Agent' => 'adyen-ruby-api-library/' + Adyen::VERSION,
|
565
|
+
'Authorization'=>'Bearer oauth_token'
|
566
|
+
})
|
567
|
+
).to have_been_made.once
|
568
|
+
end
|
569
|
+
|
570
|
+
# must be created manually because every field in the response is an array
|
571
|
+
it "makes a LIVE paymentMethods call" do
|
572
|
+
request_body = JSON.parse(json_from_file("mocks/requests/Checkout/payment_methods.json"))
|
573
|
+
|
574
|
+
response_body = json_from_file("mocks/responses/Checkout/payment_methods.json")
|
575
|
+
|
576
|
+
adyen = Adyen::Client.new
|
577
|
+
adyen.api_key = 'AF5XXXXXXXXXXXXXXXXXXXX'
|
578
|
+
adyen.env = :live
|
579
|
+
adyen.live_url_prefix = "prefix"
|
580
|
+
url = adyen.service_url("Checkout", "paymentMethods", @shared_values[:client].checkout.version)
|
581
|
+
|
582
|
+
expect(url).
|
583
|
+
to eq("https://prefix-checkout-live.adyenpayments.com/checkout/v71/paymentMethods")
|
584
|
+
|
585
|
+
end
|
586
|
+
end
|
587
|
+
|
588
|
+
# rubocop:enable Metrics/BlockLength
|