adyen-ruby-api-library 6.2.0 → 7.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/CODEOWNERS +1 -1
- data/.github/workflows/codeql.yml +41 -0
- data/.github/workflows/ruby.yml +1 -1
- data/.github/workflows/rubygems_release.yml +1 -1
- data/.gitignore +3 -0
- data/Makefile +72 -0
- data/README.md +20 -18
- data/lib/adyen/client.rb +82 -42
- data/lib/adyen/errors.rb +2 -2
- data/lib/adyen/services/balanceControlService.rb +28 -0
- data/lib/adyen/services/balancePlatform/account_holders_api.rb +63 -0
- data/lib/adyen/services/balancePlatform/balance_accounts_api.rb +123 -0
- data/lib/adyen/services/balancePlatform/bank_account_validation_api.rb +27 -0
- data/lib/adyen/services/balancePlatform/grant_accounts_api.rb +27 -0
- data/lib/adyen/services/balancePlatform/grant_offers_api.rb +39 -0
- data/lib/adyen/services/balancePlatform/payment_instrument_groups_api.rb +51 -0
- data/lib/adyen/services/balancePlatform/payment_instruments_api.rb +75 -0
- data/lib/adyen/services/balancePlatform/platform_api.rb +39 -0
- data/lib/adyen/services/balancePlatform/transaction_rules_api.rb +63 -0
- data/lib/adyen/services/balancePlatform.rb +61 -0
- data/lib/adyen/services/binLookup.rb +40 -0
- data/lib/adyen/services/checkout/classic_checkout_sdk_api.rb +39 -0
- data/lib/adyen/services/checkout/modifications_api.rb +87 -0
- data/lib/adyen/services/checkout/orders_api.rb +51 -0
- data/lib/adyen/services/checkout/payment_links_api.rb +51 -0
- data/lib/adyen/services/checkout/payments_api.rb +87 -0
- data/lib/adyen/services/checkout/recurring_api.rb +39 -0
- data/lib/adyen/services/checkout/utility_api.rb +39 -0
- data/lib/adyen/services/checkout.rb +39 -180
- data/lib/adyen/services/dataProtection.rb +28 -0
- data/lib/adyen/services/legalEntityManagement/business_lines_api.rb +63 -0
- data/lib/adyen/services/legalEntityManagement/documents_api.rb +63 -0
- data/lib/adyen/services/legalEntityManagement/hosted_onboarding_api.rb +51 -0
- data/lib/adyen/services/legalEntityManagement/legal_entities_api.rb +75 -0
- data/lib/adyen/services/legalEntityManagement/pci_questionnaires_api.rb +63 -0
- data/lib/adyen/services/legalEntityManagement/terms_of_service_api.rb +51 -0
- data/lib/adyen/services/legalEntityManagement/transfer_instruments_api.rb +63 -0
- data/lib/adyen/services/legalEntityManagement.rb +51 -0
- data/lib/adyen/services/management/account_company_level_api.rb +51 -0
- data/lib/adyen/services/management/account_merchant_level_api.rb +63 -0
- data/lib/adyen/services/management/account_store_level_api.rb +111 -0
- data/lib/adyen/services/management/allowed_origins_company_level_api.rb +63 -0
- data/lib/adyen/services/management/allowed_origins_merchant_level_api.rb +63 -0
- data/lib/adyen/services/management/api_credentials_company_level_api.rb +63 -0
- data/lib/adyen/services/management/api_credentials_merchant_level_api.rb +63 -0
- data/lib/adyen/services/management/api_key_company_level_api.rb +27 -0
- data/lib/adyen/services/management/api_key_merchant_level_api.rb +27 -0
- data/lib/adyen/services/management/client_key_company_level_api.rb +27 -0
- data/lib/adyen/services/management/client_key_merchant_level_api.rb +27 -0
- data/lib/adyen/services/management/my_api_credential_api.rb +75 -0
- data/lib/adyen/services/management/payment_methods_merchant_level_api.rb +87 -0
- data/lib/adyen/services/management/payout_settings_merchant_level_api.rb +75 -0
- data/lib/adyen/services/management/terminal_actions_company_level_api.rb +63 -0
- data/lib/adyen/services/management/terminal_actions_terminal_level_api.rb +27 -0
- data/lib/adyen/services/management/terminal_orders_company_level_api.rb +135 -0
- data/lib/adyen/services/management/terminal_orders_merchant_level_api.rb +135 -0
- data/lib/adyen/services/management/terminal_settings_company_level_api.rb +63 -0
- data/lib/adyen/services/management/terminal_settings_merchant_level_api.rb +63 -0
- data/lib/adyen/services/management/terminal_settings_store_level_api.rb +111 -0
- data/lib/adyen/services/management/terminal_settings_terminal_level_api.rb +63 -0
- data/lib/adyen/services/management/terminals_terminal_level_api.rb +27 -0
- data/lib/adyen/services/management/users_company_level_api.rb +63 -0
- data/lib/adyen/services/management/users_merchant_level_api.rb +63 -0
- data/lib/adyen/services/management/webhooks_company_level_api.rb +99 -0
- data/lib/adyen/services/management/webhooks_merchant_level_api.rb +99 -0
- data/lib/adyen/services/management.rb +151 -0
- data/lib/adyen/services/payment.rb +172 -0
- data/lib/adyen/services/payout/initialization_api.rb +51 -0
- data/lib/adyen/services/payout/instant_payouts_api.rb +27 -0
- data/lib/adyen/services/payout/reviewing_api.rb +39 -0
- data/lib/adyen/services/payout.rb +31 -0
- data/lib/adyen/services/posTerminalManagement.rb +76 -0
- data/lib/adyen/services/recurring.rb +81 -13
- data/lib/adyen/services/service.rb +6 -1
- data/lib/adyen/services/storedValue.rb +88 -0
- data/lib/adyen/services/transfers/transactions_api.rb +39 -0
- data/lib/adyen/services/transfers/transfers_api.rb +27 -0
- data/lib/adyen/services/transfers.rb +26 -0
- data/lib/adyen/utils/hmac_validator.rb +2 -3
- data/lib/adyen/version.rb +2 -2
- data/lib/adyen-ruby-api-library.rb +11 -5
- data/spec/account_spec.rb +1 -1
- data/spec/balance_control_spec.rb +44 -0
- data/spec/balance_platform_spec.rb +123 -0
- data/spec/bin_lookup_spec.rb +68 -10
- data/spec/checkout_spec.rb +85 -62
- data/spec/client_spec.rb +89 -10
- data/spec/errors_spec.rb +1 -1
- data/spec/fund_spec.rb +1 -1
- data/spec/hop_spec.rb +1 -1
- data/spec/lem_spec.rb +68 -0
- data/spec/management_spec.rb +68 -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/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/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/stored_payment_methods.json +1 -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/Transfers/get_transactions.json +82 -0
- data/spec/mocks/responses/Transfers/make_transfer.json +36 -0
- data/spec/mocks/responses/Webhooks/backslash_notification.json +41 -0
- data/spec/mocks/responses/Webhooks/colon_notification.json +41 -0
- data/spec/mocks/responses/Webhooks/forwardslash_notification.json +41 -0
- data/spec/mocks/responses/Webhooks/mixed_notification.json +41 -0
- data/spec/notification_spec.rb +1 -1
- data/spec/payments_spec.rb +41 -23
- data/spec/payouts_spec.rb +43 -16
- data/spec/pos_terminal_management_spec.rb +46 -0
- data/spec/recurring_spec.rb +2 -2
- data/spec/spec_helper.rb +0 -10
- data/spec/stored_value_spec.rb +43 -0
- data/spec/transfers_spec.rb +63 -0
- data/spec/utils/hmac_validator_spec.rb +20 -6
- data/templates/api-single.mustache +29 -0
- data/templates/api-small.mustache +37 -0
- data/templates/api.mustache +36 -0
- data/templates/config.yaml +10 -0
- metadata +107 -11
- data/lib/adyen/services/bin_lookup.rb +0 -18
- data/lib/adyen/services/data_protection.rb +0 -17
- 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/mocks/requests/Recurring/store_token.json +0 -15
- data/spec/mocks/responses/Recurring/store_token.json +0 -7
- data/spec/postfmapi_spec.rb +0 -16
@@ -0,0 +1,41 @@
|
|
1
|
+
{
|
2
|
+
"additionalData": {
|
3
|
+
"acquirerCode": "TestPmmAcquirer",
|
4
|
+
"acquirerReference": "8NQH5BNF58M",
|
5
|
+
"authCode": "039404",
|
6
|
+
"avsResult": "5 No AVS data provided",
|
7
|
+
"avsResultRaw": "5",
|
8
|
+
"cardSummary": "1111",
|
9
|
+
"checkout.cardAddedBrand": "visa",
|
10
|
+
"cvcResult": "1 Matches",
|
11
|
+
"cvcResultRaw": "M",
|
12
|
+
"expiryDate": "03/2030",
|
13
|
+
"hmacSignature": "2EQYm7YJpKO4EtHSPu55SQTyWf8dkW5u2nD1tJFpViA=",
|
14
|
+
"paymentMethod": "visa",
|
15
|
+
"refusalReasonRaw": "AUTHORISED",
|
16
|
+
"retry.attempt1.acquirer": "TestPmmAcquirer",
|
17
|
+
"retry.attempt1.acquirerAccount": "TestPmmAcquirerAccount",
|
18
|
+
"retry.attempt1.avsResultRaw": "5",
|
19
|
+
"retry.attempt1.rawResponse": "AUTHORISED",
|
20
|
+
"retry.attempt1.responseCode": "Approved",
|
21
|
+
"retry.attempt1.scaExemptionRequested": "lowValue",
|
22
|
+
"scaExemptionRequested": "lowValue"
|
23
|
+
},
|
24
|
+
"amount": {
|
25
|
+
"currency": "EUR",
|
26
|
+
"value": 1000
|
27
|
+
},
|
28
|
+
"eventCode": "AUTHORISATION",
|
29
|
+
"eventDate": "2023-01-10T13:40:54+01:00",
|
30
|
+
"merchantAccountCode": "AntoniStroinski",
|
31
|
+
"merchantReference": ":slashes are fun",
|
32
|
+
"operations": [
|
33
|
+
"CANCEL",
|
34
|
+
"CAPTURE",
|
35
|
+
"REFUND"
|
36
|
+
],
|
37
|
+
"paymentMethod": "visa",
|
38
|
+
"pspReference": "M8NB66SBZSGLNK82",
|
39
|
+
"reason": "039404:1111:03/2030",
|
40
|
+
"success": "true"
|
41
|
+
}
|
@@ -0,0 +1,41 @@
|
|
1
|
+
{
|
2
|
+
"amount": {
|
3
|
+
"value": 1000,
|
4
|
+
"currency": "EUR"
|
5
|
+
},
|
6
|
+
"reason": "087330:1111:03/2030",
|
7
|
+
"success": "true",
|
8
|
+
"eventCode": "AUTHORISATION",
|
9
|
+
"eventDate": "2023-01-10T13:37:30+01:00",
|
10
|
+
"operations": [
|
11
|
+
"CANCEL",
|
12
|
+
"CAPTURE",
|
13
|
+
"REFUND"
|
14
|
+
],
|
15
|
+
"pspReference": "X3GWNS6KJ8NKGK82",
|
16
|
+
"paymentMethod": "visa",
|
17
|
+
"additionalData": {
|
18
|
+
"authCode": "087330",
|
19
|
+
"avsResult": "5 No AVS data provided",
|
20
|
+
"cvcResult": "1 Matches",
|
21
|
+
"expiryDate": "03/2030",
|
22
|
+
"cardSummary": "1111",
|
23
|
+
"acquirerCode": "TestPmmAcquirer",
|
24
|
+
"avsResultRaw": "5",
|
25
|
+
"cvcResultRaw": "M",
|
26
|
+
"hmacSignature": "9Z0xdpG9Xi3zcmXv14t/BvMBut77O/Xq9D4CQXSDUi4=",
|
27
|
+
"paymentMethod": "visa",
|
28
|
+
"refusalReasonRaw": "AUTHORISED",
|
29
|
+
"acquirerReference": "HHCCC326PH6",
|
30
|
+
"scaExemptionRequested": "lowValue",
|
31
|
+
"checkout.cardAddedBrand": "visa",
|
32
|
+
"retry.attempt1.acquirer": "TestPmmAcquirer",
|
33
|
+
"retry.attempt1.rawResponse": "AUTHORISED",
|
34
|
+
"retry.attempt1.avsResultRaw": "5",
|
35
|
+
"retry.attempt1.responseCode": "Approved",
|
36
|
+
"retry.attempt1.acquirerAccount": "TestPmmAcquirerAccount",
|
37
|
+
"retry.attempt1.scaExemptionRequested": "lowValue"
|
38
|
+
},
|
39
|
+
"merchantReference": "//slashes are fun",
|
40
|
+
"merchantAccountCode": "AntoniStroinski"
|
41
|
+
}
|
@@ -0,0 +1,41 @@
|
|
1
|
+
{
|
2
|
+
"additionalData": {
|
3
|
+
"acquirerCode": "TestPmmAcquirer",
|
4
|
+
"acquirerReference": "J8DXDJ2PV6P",
|
5
|
+
"authCode": "052095",
|
6
|
+
"avsResult": "5 No AVS data provided",
|
7
|
+
"avsResultRaw": "5",
|
8
|
+
"cardSummary": "1111",
|
9
|
+
"checkout.cardAddedBrand": "visa",
|
10
|
+
"cvcResult": "1 Matches",
|
11
|
+
"cvcResultRaw": "M",
|
12
|
+
"expiryDate": "03/2030",
|
13
|
+
"hmacSignature": "CZErGCNQaSsxbaQfZaJlakqo7KPP+mIa8a+wx3yNs9A=",
|
14
|
+
"paymentMethod": "visa",
|
15
|
+
"refusalReasonRaw": "AUTHORISED",
|
16
|
+
"retry.attempt1.acquirer": "TestPmmAcquirer",
|
17
|
+
"retry.attempt1.acquirerAccount": "TestPmmAcquirerAccount",
|
18
|
+
"retry.attempt1.avsResultRaw": "5",
|
19
|
+
"retry.attempt1.rawResponse": "AUTHORISED",
|
20
|
+
"retry.attempt1.responseCode": "Approved",
|
21
|
+
"retry.attempt1.scaExemptionRequested": "lowValue",
|
22
|
+
"scaExemptionRequested": "lowValue"
|
23
|
+
},
|
24
|
+
"amount": {
|
25
|
+
"currency": "EUR",
|
26
|
+
"value": 1000
|
27
|
+
},
|
28
|
+
"eventCode": "AUTHORISATION",
|
29
|
+
"eventDate": "2023-01-10T13:42:29+01:00",
|
30
|
+
"merchantAccountCode": "AntoniStroinski",
|
31
|
+
"merchantReference": "\\:/\\/slashes are fun",
|
32
|
+
"operations": [
|
33
|
+
"CANCEL",
|
34
|
+
"CAPTURE",
|
35
|
+
"REFUND"
|
36
|
+
],
|
37
|
+
"paymentMethod": "visa",
|
38
|
+
"pspReference": "ZVWN7D3WSMK2WN82",
|
39
|
+
"reason": "052095:1111:03/2030",
|
40
|
+
"success": "true"
|
41
|
+
}
|
data/spec/notification_spec.rb
CHANGED
data/spec/payments_spec.rb
CHANGED
@@ -1,26 +1,44 @@
|
|
1
1
|
require "spec_helper"
|
2
|
+
require "json"
|
3
|
+
|
4
|
+
RSpec.describe Adyen::Payment, service: "Payment" do
|
5
|
+
before(:all) do
|
6
|
+
@shared_values = {
|
7
|
+
client: create_client(:api_key),
|
8
|
+
service: "Payment",
|
9
|
+
}
|
10
|
+
end
|
11
|
+
|
12
|
+
# must be created manually because every field in the response is an array
|
13
|
+
it "makes an adjust_authorisation POST call" do
|
14
|
+
request_body = JSON.parse(json_from_file("mocks/requests/Payment/adjust_authorisation.json"))
|
15
|
+
|
16
|
+
response_body = json_from_file("mocks/responses/Payment/adjust_authorisation.json")
|
17
|
+
|
18
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "adjustAuthorisation", @shared_values[:client].payment.version)
|
19
|
+
WebMock.stub_request(:post, url).
|
20
|
+
with(
|
21
|
+
body: request_body,
|
22
|
+
headers: {
|
23
|
+
"x-api-key" => @shared_values[:client].api_key
|
24
|
+
}
|
25
|
+
).
|
26
|
+
to_return(
|
27
|
+
body: response_body
|
28
|
+
)
|
29
|
+
|
30
|
+
result = @shared_values[:client].payment.adjust_authorisation(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
|
2
42
|
|
3
|
-
RSpec.describe Adyen::Payments, service: "payments service" do
|
4
|
-
# client instance to be used in dynamically generated tests
|
5
|
-
client = create_client(:basic)
|
6
|
-
|
7
|
-
# methods / values to test for
|
8
|
-
# format is defined in spec_helper
|
9
|
-
test_sets = [
|
10
|
-
["authorise", "resultCode", "Authorised"],
|
11
|
-
["adjust_authorisation", "response", "[adjustAuthorisation-received]"],
|
12
|
-
["authorise3d", "resultCode", "Authorised"],
|
13
|
-
["authorise3ds2", "resultCode", "ChallengeShopper"],
|
14
|
-
["cancel", "response", "[cancel-received]"],
|
15
|
-
["cancel_or_refund", "response", "[cancelOrRefund-received]"],
|
16
|
-
["capture", "response", "[capture-received]"],
|
17
|
-
["refund", "response", "[refund-received]"],
|
18
|
-
["donate", "response", "[donation-received]"],
|
19
|
-
["get_authentication_result", "threeDS2Result", {"transStatus" => "Y"}],
|
20
|
-
["retrieve_3ds2_result", "threeDS2Result", {"transStatus" => "Y"}],
|
21
|
-
["technical_cancel", "originalReference", "9914694372990637"],
|
22
|
-
["void_pending_refund", "pspReference", "9914694372990637"]
|
23
|
-
]
|
24
|
-
|
25
|
-
generate_tests(client, "Payment", test_sets, client.payments)
|
26
43
|
end
|
44
|
+
|
data/spec/payouts_spec.rb
CHANGED
@@ -1,19 +1,46 @@
|
|
1
1
|
require "spec_helper"
|
2
|
+
require "json"
|
3
|
+
|
4
|
+
# rubocop:disable Metrics/BlockLength
|
5
|
+
|
6
|
+
RSpec.describe Adyen::Payout, service: "Payout" do
|
7
|
+
before(:all) do
|
8
|
+
@shared_values = {
|
9
|
+
client: create_client(:api_key),
|
10
|
+
service: "Payout",
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
14
|
+
# must be created manually because every field in the response is an array
|
15
|
+
it "makes a business_lines POST call" do
|
16
|
+
request_body = JSON.parse(json_from_file("mocks/requests/Payout/confirm_third_party.json"))
|
17
|
+
|
18
|
+
response_body = json_from_file("mocks/responses/Payout/confirm_third_party.json")
|
19
|
+
|
20
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "confirmThirdParty", @shared_values[:client].payout.version)
|
21
|
+
WebMock.stub_request(:post, url).
|
22
|
+
with(
|
23
|
+
body: request_body,
|
24
|
+
headers: {
|
25
|
+
"x-api-key" => @shared_values[:client].api_key
|
26
|
+
}
|
27
|
+
).
|
28
|
+
to_return(
|
29
|
+
body: response_body
|
30
|
+
)
|
31
|
+
|
32
|
+
result = @shared_values[:client].payout.reviewing_api.confirm_third_party(request_body)
|
33
|
+
response_hash = result.response
|
34
|
+
|
35
|
+
expect(result.status).
|
36
|
+
to eq(200)
|
37
|
+
expect(response_hash).
|
38
|
+
to eq(JSON.parse(response_body))
|
39
|
+
expect(response_hash).
|
40
|
+
to be_a Adyen::HashWithAccessors
|
41
|
+
expect(response_hash).
|
42
|
+
to be_a_kind_of Hash
|
43
|
+
end
|
2
44
|
|
3
|
-
RSpec.describe Adyen::Payments, service: "payouts service" do
|
4
|
-
# client instance to be used in dynamically generated tests
|
5
|
-
client = create_client(:basic)
|
6
|
-
|
7
|
-
# methods / values to test for
|
8
|
-
# format is defined in spec_helper
|
9
|
-
test_sets = [
|
10
|
-
["store_detail", "resultCode", "Success"],
|
11
|
-
["store_detail_and_submit_third_party", "resultCode", "[payout-submit-received]"],
|
12
|
-
["submit_third_party", "resultCode", "[payout-submit-received]"],
|
13
|
-
["confirm_third_party", "response", "[payout-confirm-received]"],
|
14
|
-
["decline_third_party", "response", "[payout-decline-received]"],
|
15
|
-
["payout", "resultCode", "Success"]
|
16
|
-
]
|
17
|
-
|
18
|
-
generate_tests(client, "Payout", test_sets, client.payouts)
|
19
45
|
end
|
46
|
+
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "json"
|
3
|
+
|
4
|
+
# rubocop:disable Metrics/BlockLength
|
5
|
+
|
6
|
+
RSpec.describe Adyen::PosTerminalManagement, service: "PosTerminalManagement" do
|
7
|
+
before(:all) do
|
8
|
+
@shared_values = {
|
9
|
+
client: create_client(:api_key),
|
10
|
+
service: "LegalEntityManagement",
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
14
|
+
# must be created manually because every field in the response is an array
|
15
|
+
it "makes a assign_terminals POST call" do
|
16
|
+
request_body = JSON.parse(json_from_file("mocks/requests/Terminal/assign_terminals.json"))
|
17
|
+
|
18
|
+
response_body = json_from_file("mocks/responses/Terminal/assign_terminals.json")
|
19
|
+
|
20
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "assignTerminals", @shared_values[:client].pos_terminal_management.version)
|
21
|
+
WebMock.stub_request(:post, url).
|
22
|
+
with(
|
23
|
+
body: request_body,
|
24
|
+
headers: {
|
25
|
+
"x-api-key" => @shared_values[:client].api_key
|
26
|
+
}
|
27
|
+
).
|
28
|
+
to_return(
|
29
|
+
body: response_body
|
30
|
+
)
|
31
|
+
|
32
|
+
result = @shared_values[:client].pos_terminal_management.assign_terminals(request_body)
|
33
|
+
response_hash = result.response
|
34
|
+
|
35
|
+
expect(result.status).
|
36
|
+
to eq(200)
|
37
|
+
expect(response_hash).
|
38
|
+
to eq(JSON.parse(response_body))
|
39
|
+
expect(response_hash).
|
40
|
+
to be_a Adyen::HashWithAccessors
|
41
|
+
expect(response_hash).
|
42
|
+
to be_a_kind_of Hash
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
data/spec/recurring_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
require_relative "../lib/adyen/errors"
|
3
3
|
|
4
|
-
RSpec.describe Adyen::
|
4
|
+
RSpec.describe Adyen::Payment, service: "recurring service" do
|
5
5
|
# client instance to be used in dynamically generated tests
|
6
6
|
client = create_client(:basic)
|
7
7
|
|
@@ -10,7 +10,7 @@ RSpec.describe Adyen::Payments, service: "recurring service" do
|
|
10
10
|
test_sets = [
|
11
11
|
["list_recurring_details", "creationDate", "2017-03-01T11:53:11+01:00"],
|
12
12
|
["disable", "response", "[detail-successfully-disabled]"],
|
13
|
-
["
|
13
|
+
["create_permit", "pspReference", "8815260599791117"],
|
14
14
|
["schedule_account_updater", "result", "Success"]
|
15
15
|
]
|
16
16
|
|
data/spec/spec_helper.rb
CHANGED
@@ -18,16 +18,6 @@ def create_test(client, service, method_name, parent_object)
|
|
18
18
|
request_body = JSON.parse(json_from_file("mocks/requests/#{service}/#{method_name}.json"))
|
19
19
|
response_body = json_from_file("mocks/responses/#{service}/#{method_name}.json")
|
20
20
|
|
21
|
-
with_application_info = [
|
22
|
-
"authorise",
|
23
|
-
"authorise3d",
|
24
|
-
"authorise3ds2",
|
25
|
-
"payments",
|
26
|
-
"payment_session",
|
27
|
-
]
|
28
|
-
if with_application_info.include?(method_name)
|
29
|
-
client.add_application_info(request_body)
|
30
|
-
end
|
31
21
|
|
32
22
|
# client-generated headers
|
33
23
|
headers = {
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "json"
|
3
|
+
|
4
|
+
RSpec.describe Adyen::BalancePlatform, service: "balancePlatform" do
|
5
|
+
before(:all) do
|
6
|
+
@shared_values = {
|
7
|
+
client: create_client(:api_key),
|
8
|
+
service: "BalancePlatform",
|
9
|
+
}
|
10
|
+
end
|
11
|
+
|
12
|
+
# must be created manually because every field in the response is an array
|
13
|
+
it "makes a issue POST call" do
|
14
|
+
request_body = JSON.parse(json_from_file("mocks/requests/StoredValue/issue_giftcard.json"))
|
15
|
+
|
16
|
+
response_body = json_from_file("mocks/responses/StoredValue/issue_giftcard.json")
|
17
|
+
|
18
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "issue", @shared_values[:client].stored_value.version)
|
19
|
+
WebMock.stub_request(:post, url).
|
20
|
+
with(
|
21
|
+
body: request_body,
|
22
|
+
headers: {
|
23
|
+
"x-api-key" => @shared_values[:client].api_key
|
24
|
+
}
|
25
|
+
).
|
26
|
+
to_return(
|
27
|
+
body: response_body
|
28
|
+
)
|
29
|
+
|
30
|
+
result = @shared_values[:client].stored_value.issue(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
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "json"
|
3
|
+
|
4
|
+
# rubocop:disable Metrics/BlockLength
|
5
|
+
|
6
|
+
RSpec.describe Adyen::Transfers, service: "transfers" do
|
7
|
+
before(:all) do
|
8
|
+
@shared_values = {
|
9
|
+
client: create_client(:api_key),
|
10
|
+
service: "Transfers",
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
14
|
+
it "makes a transfers POST call" do
|
15
|
+
|
16
|
+
request_body = JSON.parse(json_from_file("mocks/requests/Transfers/make_transfer.json"))
|
17
|
+
|
18
|
+
response_body = json_from_file("mocks/responses/Transfers/make_transfer.json")
|
19
|
+
|
20
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "transfers", @shared_values[:client].transfers.version)
|
21
|
+
WebMock.stub_request(:post, url).
|
22
|
+
with(
|
23
|
+
body: request_body,
|
24
|
+
headers: {
|
25
|
+
"x-api-key" => @shared_values[:client].api_key
|
26
|
+
}
|
27
|
+
).
|
28
|
+
to_return(
|
29
|
+
body: response_body
|
30
|
+
)
|
31
|
+
|
32
|
+
result = @shared_values[:client].transfers.transfers_api.transfer_funds(request_body)
|
33
|
+
response_hash = result.response
|
34
|
+
|
35
|
+
expect(result.status).
|
36
|
+
to eq(200)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "makes a transactions GET call" do
|
40
|
+
|
41
|
+
response_body = json_from_file("mocks/responses/Transfers/make_transfer.json")
|
42
|
+
|
43
|
+
url = @shared_values[:client].service_url(@shared_values[:service], "transactions?createdUntil=2021-05-30T15%3A07%3A40Z&createdSince=2021-05-30T15%3A07%3A40Z", @shared_values[:client].transfers.version)
|
44
|
+
WebMock.stub_request(:get, url).
|
45
|
+
with(
|
46
|
+
headers: {
|
47
|
+
"x-api-key" => @shared_values[:client].api_key
|
48
|
+
}
|
49
|
+
).
|
50
|
+
to_return(
|
51
|
+
body: response_body
|
52
|
+
)
|
53
|
+
|
54
|
+
result = @shared_values[:client].transfers.transactions_api.get_all_transactions(queryParams:{"createdUntil" => "2021-05-30T15:07:40Z", "createdSince" => "2021-05-30T15:07:40Z"})
|
55
|
+
response_hash = result.response
|
56
|
+
|
57
|
+
expect(result.status).
|
58
|
+
to eq(200)
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
end
|
63
|
+
|
@@ -28,12 +28,6 @@ RSpec.describe Adyen::Utils::HmacValidator do
|
|
28
28
|
expect(data_to_sign).to eq '7914073381342284::TestMerchant:TestPayment-1407325143704:1130:EUR:AUTHORISATION:true'
|
29
29
|
end
|
30
30
|
|
31
|
-
it 'should get correct data with escaped characters' do
|
32
|
-
notification_request_item['merchantAccountCode'] = 'Test:\\Merchant'
|
33
|
-
data_to_sign = validator.data_to_sign(notification_request_item)
|
34
|
-
expect(data_to_sign).to eq '7914073381342284::Test\\:\\Merchant:TestPayment-1407325143704:1130:EUR:AUTHORISATION:true'
|
35
|
-
end
|
36
|
-
|
37
31
|
it 'should encrypt properly' do
|
38
32
|
encrypted = validator.calculate_notification_hmac(notification_request_item, key)
|
39
33
|
expect(encrypted).to eq expected_sign
|
@@ -48,5 +42,25 @@ RSpec.describe Adyen::Utils::HmacValidator do
|
|
48
42
|
|
49
43
|
expect(validator.valid_notification_hmac?(notification_request_item, key)).to be false
|
50
44
|
end
|
45
|
+
|
46
|
+
it 'should validate backslashes correctly' do
|
47
|
+
webhook = JSON.parse(json_from_file("mocks/responses/Webhooks/backslash_notification.json"))
|
48
|
+
expect(validator.valid_notification_hmac?(webhook, '74F490DD33F7327BAECC88B2947C011FC02D014A473AAA33A8EC93E4DC069174')).to be true
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should validate colons correctly' do
|
52
|
+
webhook = JSON.parse(json_from_file("mocks/responses/Webhooks/colon_notification.json"))
|
53
|
+
expect(validator.valid_notification_hmac?(webhook, '74F490DD33F7327BAECC88B2947C011FC02D014A473AAA33A8EC93E4DC069174')).to be true
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should validate forward slashes correctly' do
|
57
|
+
webhook = JSON.parse(json_from_file("mocks/responses/Webhooks/forwardslash_notification.json"))
|
58
|
+
expect(validator.valid_notification_hmac?(webhook, '74F490DD33F7327BAECC88B2947C011FC02D014A473AAA33A8EC93E4DC069174')).to be true
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should validate mix of slashes and colon correctly' do
|
62
|
+
webhook = JSON.parse(json_from_file("mocks/responses/Webhooks/mixed_notification.json"))
|
63
|
+
expect(validator.valid_notification_hmac?(webhook, '74F490DD33F7327BAECC88B2947C011FC02D014A473AAA33A8EC93E4DC069174')).to be true
|
64
|
+
end
|
51
65
|
end
|
52
66
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
{{#apiInfo}}
|
2
|
+
{{#apis}}
|
3
|
+
require_relative '{{serviceName}}/{{#lambda.snakecase}}{{classname}}{{/lambda.snakecase}}'
|
4
|
+
{{/apis}}
|
5
|
+
{{/apiInfo}}
|
6
|
+
|
7
|
+
module Adyen
|
8
|
+
|
9
|
+
|
10
|
+
class {{#lambda.titlecase}}{{serviceName}}{{/lambda.titlecase}}
|
11
|
+
attr_accessor :service, :version
|
12
|
+
|
13
|
+
DEFAULT_VERSION = {{version}}
|
14
|
+
def initialize(client, version = DEFAULT_VERSION)
|
15
|
+
@service = "{{#lambda.titlecase}}{{serviceName}}{{/lambda.titlecase}}"
|
16
|
+
@client = client
|
17
|
+
@version = version
|
18
|
+
end
|
19
|
+
|
20
|
+
{{#apiInfo}}
|
21
|
+
{{#apis}}
|
22
|
+
def {{classFilename}}
|
23
|
+
@{{classFilename}} ||= Adyen::{{classname}}.new(@client, @version)
|
24
|
+
end
|
25
|
+
|
26
|
+
{{/apis}}
|
27
|
+
{{/apiInfo}}
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require_relative './service'
|
2
|
+
module Adyen
|
3
|
+
{{#operations}}
|
4
|
+
|
5
|
+
|
6
|
+
class {{#lambda.titlecase}}{{serviceName}}{{/lambda.titlecase}} < Service
|
7
|
+
attr_accessor :service, :version
|
8
|
+
DEFAULT_VERSION = {{version}}
|
9
|
+
|
10
|
+
def initialize(client, version = DEFAULT_VERSION)
|
11
|
+
@service = "{{#lambda.titlecase}}{{serviceName}}{{/lambda.titlecase}}"
|
12
|
+
@client = client
|
13
|
+
@version = version
|
14
|
+
end
|
15
|
+
|
16
|
+
{{#operation}}
|
17
|
+
def {{#lambda.snakecase}}{{#vendorExtensions.x-methodName}}{{.}}{{/vendorExtensions.x-methodName}}{{^vendorExtensions.x-methodName}}{{nickname}}{{/vendorExtensions.x-methodName}}{{/lambda.snakecase}}({{#bodyParams}}request, {{/bodyParams}}{{#requiredParams}}{{^isQueryParam}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}, {{/isQueryParam}}{{/requiredParams}}headers: {} {{#queryParams}}{{#-first}}, queryParams: {}{{/-first}}{{/queryParams}})
|
18
|
+
"""
|
19
|
+
{{{summary}}}{{^summary}}{{operationId}}{{/summary}}
|
20
|
+
"""
|
21
|
+
endpoint = "{{path}}".gsub(/{.+?}/, '%s')
|
22
|
+
endpoint = endpoint.gsub(/^\//, "")
|
23
|
+
endpoint = endpoint % [{{#pathParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}},{{/-last}}{{/pathParams}}]
|
24
|
+
{{#queryParams}}{{#-first}}endpoint = endpoint + create_query_string(queryParams){{/-first}}{{/queryParams}}
|
25
|
+
action = { method: "{{#lambda.lowercase}}{{httpMethod}}{{/lambda.lowercase}}", url: endpoint}
|
26
|
+
{{#bodyParams}}
|
27
|
+
@client.call_adyen_api(@service, action, request, headers, @version)
|
28
|
+
{{/bodyParams}}
|
29
|
+
{{^bodyParams}}
|
30
|
+
@client.call_adyen_api(@service, action, {}, headers, @version)
|
31
|
+
{{/bodyParams}}
|
32
|
+
end
|
33
|
+
|
34
|
+
{{/operation}}
|
35
|
+
{{/operations}}
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require_relative '../service'
|
2
|
+
module Adyen
|
3
|
+
{{#operations}}
|
4
|
+
|
5
|
+
|
6
|
+
class {{classname}} < Service
|
7
|
+
attr_accessor :service, :version
|
8
|
+
|
9
|
+
def initialize(client, version = DEFAULT_VERSION)
|
10
|
+
@service = "{{#lambda.titlecase}}{{serviceName}}{{/lambda.titlecase}}"
|
11
|
+
@client = client
|
12
|
+
@version = version
|
13
|
+
end
|
14
|
+
|
15
|
+
{{#operation}}
|
16
|
+
def {{#lambda.snakecase}}{{#vendorExtensions.x-methodName}}{{.}}{{/vendorExtensions.x-methodName}}{{^vendorExtensions.x-methodName}}{{nickname}}{{/vendorExtensions.x-methodName}}{{/lambda.snakecase}}({{#bodyParams}}request, {{/bodyParams}}{{#requiredParams}}{{^isQueryParam}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}, {{/isQueryParam}}{{/requiredParams}}headers: {} {{#queryParams}}{{#-first}}, queryParams: {}{{/-first}}{{/queryParams}})
|
17
|
+
"""
|
18
|
+
{{{summary}}}{{^summary}}{{operationId}}{{/summary}}
|
19
|
+
"""
|
20
|
+
endpoint = "{{path}}".gsub(/{.+?}/, '%s')
|
21
|
+
endpoint = endpoint.gsub(/^\//, "")
|
22
|
+
endpoint = endpoint % [{{#pathParams}}{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}{{^-last}},{{/-last}}{{/pathParams}}]
|
23
|
+
{{#queryParams}}{{#-first}}endpoint = endpoint + create_query_string(queryParams){{/-first}}{{/queryParams}}
|
24
|
+
action = { method: "{{#lambda.lowercase}}{{httpMethod}}{{/lambda.lowercase}}", url: endpoint}
|
25
|
+
{{#bodyParams}}
|
26
|
+
@client.call_adyen_api(@service, action, request, headers, @version)
|
27
|
+
{{/bodyParams}}
|
28
|
+
{{^bodyParams}}
|
29
|
+
@client.call_adyen_api(@service, action, {}, headers, @version)
|
30
|
+
{{/bodyParams}}
|
31
|
+
end
|
32
|
+
|
33
|
+
{{/operation}}
|
34
|
+
{{/operations}}
|
35
|
+
end
|
36
|
+
end
|