direct-sdk-ruby 1.0.0
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 +7 -0
- data/Gemfile +2 -0
- data/LICENSE.txt +22 -0
- data/README.md +141 -0
- data/Rakefile +34 -0
- data/direct-sdk-ruby.gemspec +28 -0
- data/lib/ingenico/direct/sdk.rb +26 -0
- data/lib/ingenico/direct/sdk/api_exception.rb +42 -0
- data/lib/ingenico/direct/sdk/api_resource.rb +115 -0
- data/lib/ingenico/direct/sdk/authenticator.rb +16 -0
- data/lib/ingenico/direct/sdk/authorization_exception.rb +13 -0
- data/lib/ingenico/direct/sdk/call_context.rb +26 -0
- data/lib/ingenico/direct/sdk/client.rb +85 -0
- data/lib/ingenico/direct/sdk/communication_exception.rb +16 -0
- data/lib/ingenico/direct/sdk/communicator.rb +301 -0
- data/lib/ingenico/direct/sdk/communicator_configuration.rb +59 -0
- data/lib/ingenico/direct/sdk/connection.rb +41 -0
- data/lib/ingenico/direct/sdk/data_object.rb +32 -0
- data/lib/ingenico/direct/sdk/declined_payment_exception.rb +30 -0
- data/lib/ingenico/direct/sdk/declined_payout_exception.rb +32 -0
- data/lib/ingenico/direct/sdk/declined_refund_exception.rb +32 -0
- data/lib/ingenico/direct/sdk/declined_transaction_exception.rb +16 -0
- data/lib/ingenico/direct/sdk/defaultimpl.rb +6 -0
- data/lib/ingenico/direct/sdk/defaultimpl/authorization_type.rb +24 -0
- data/lib/ingenico/direct/sdk/defaultimpl/default_authenticator.rb +108 -0
- data/lib/ingenico/direct/sdk/defaultimpl/default_connection.rb +293 -0
- data/lib/ingenico/direct/sdk/defaultimpl/default_marshaller.rb +32 -0
- data/lib/ingenico/direct/sdk/direct_exception.rb +15 -0
- data/lib/ingenico/direct/sdk/domain/account_on_file.rb +50 -0
- data/lib/ingenico/direct/sdk/domain/account_on_file_attribute.rb +39 -0
- data/lib/ingenico/direct/sdk/domain/account_on_file_display_hints.rb +38 -0
- data/lib/ingenico/direct/sdk/domain/additional_order_input.rb +47 -0
- data/lib/ingenico/direct/sdk/domain/address.rb +51 -0
- data/lib/ingenico/direct/sdk/domain/address_personal.rb +59 -0
- data/lib/ingenico/direct/sdk/domain/airline_data.rb +129 -0
- data/lib/ingenico/direct/sdk/domain/airline_flight_leg.rb +99 -0
- data/lib/ingenico/direct/sdk/domain/airline_passenger.rb +39 -0
- data/lib/ingenico/direct/sdk/domain/amount_breakdown.rb +31 -0
- data/lib/ingenico/direct/sdk/domain/amount_of_money.rb +31 -0
- data/lib/ingenico/direct/sdk/domain/api_error.rb +47 -0
- data/lib/ingenico/direct/sdk/domain/browser_data.rb +39 -0
- data/lib/ingenico/direct/sdk/domain/cancel_payment_response.rb +31 -0
- data/lib/ingenico/direct/sdk/domain/capture.rb +47 -0
- data/lib/ingenico/direct/sdk/domain/capture_output.rb +79 -0
- data/lib/ingenico/direct/sdk/domain/capture_payment_request.rb +31 -0
- data/lib/ingenico/direct/sdk/domain/capture_response.rb +47 -0
- data/lib/ingenico/direct/sdk/domain/capture_status_output.rb +27 -0
- data/lib/ingenico/direct/sdk/domain/captures_response.rb +34 -0
- data/lib/ingenico/direct/sdk/domain/card.rb +39 -0
- data/lib/ingenico/direct/sdk/domain/card_essentials.rb +31 -0
- data/lib/ingenico/direct/sdk/domain/card_fraud_results.rb +35 -0
- data/lib/ingenico/direct/sdk/domain/card_payment_method_specific_input.rb +95 -0
- data/lib/ingenico/direct/sdk/domain/card_payment_method_specific_input_base.rb +79 -0
- data/lib/ingenico/direct/sdk/domain/card_payment_method_specific_output.rb +67 -0
- data/lib/ingenico/direct/sdk/domain/card_payout_method_specific_input.rb +39 -0
- data/lib/ingenico/direct/sdk/domain/card_recurrence_details.rb +27 -0
- data/lib/ingenico/direct/sdk/domain/card_without_cvv.rb +35 -0
- data/lib/ingenico/direct/sdk/domain/company_information.rb +27 -0
- data/lib/ingenico/direct/sdk/domain/complete_payment_card_payment_method_specific_input.rb +31 -0
- data/lib/ingenico/direct/sdk/domain/complete_payment_request.rb +39 -0
- data/lib/ingenico/direct/sdk/domain/complete_payment_response.rb +47 -0
- data/lib/ingenico/direct/sdk/domain/contact_details.rb +43 -0
- data/lib/ingenico/direct/sdk/domain/create_hosted_checkout_request.rb +63 -0
- data/lib/ingenico/direct/sdk/domain/create_hosted_checkout_response.rb +49 -0
- data/lib/ingenico/direct/sdk/domain/create_hosted_tokenization_request.rb +39 -0
- data/lib/ingenico/direct/sdk/domain/create_hosted_tokenization_response.rb +41 -0
- data/lib/ingenico/direct/sdk/domain/create_payment_request.rb +67 -0
- data/lib/ingenico/direct/sdk/domain/create_payment_response.rb +47 -0
- data/lib/ingenico/direct/sdk/domain/create_payout_request.rb +47 -0
- data/lib/ingenico/direct/sdk/domain/create_token_request.rb +35 -0
- data/lib/ingenico/direct/sdk/domain/created_payment_output.rb +35 -0
- data/lib/ingenico/direct/sdk/domain/created_token_response.rb +51 -0
- data/lib/ingenico/direct/sdk/domain/customer.rb +87 -0
- data/lib/ingenico/direct/sdk/domain/customer_account.rb +71 -0
- data/lib/ingenico/direct/sdk/domain/customer_account_authentication.rb +31 -0
- data/lib/ingenico/direct/sdk/domain/customer_device.rb +51 -0
- data/lib/ingenico/direct/sdk/domain/customer_payment_activity.rb +35 -0
- data/lib/ingenico/direct/sdk/domain/customer_token.rb +47 -0
- data/lib/ingenico/direct/sdk/domain/decrypted_payment_data.rb +43 -0
- data/lib/ingenico/direct/sdk/domain/directory_entry.rb +35 -0
- data/lib/ingenico/direct/sdk/domain/empty_validator.rb +13 -0
- data/lib/ingenico/direct/sdk/domain/error_response.rb +38 -0
- data/lib/ingenico/direct/sdk/domain/external_cardholder_authentication_data.rb +59 -0
- data/lib/ingenico/direct/sdk/domain/external_token_linked.rb +27 -0
- data/lib/ingenico/direct/sdk/domain/fixed_list_validator.rb +33 -0
- data/lib/ingenico/direct/sdk/domain/fraud_fields.rb +31 -0
- data/lib/ingenico/direct/sdk/domain/fraud_results.rb +27 -0
- data/lib/ingenico/direct/sdk/domain/g_pay_three_d_secure.rb +47 -0
- data/lib/ingenico/direct/sdk/domain/get_hosted_checkout_response.rb +35 -0
- data/lib/ingenico/direct/sdk/domain/get_hosted_tokenization_response.rb +35 -0
- data/lib/ingenico/direct/sdk/domain/get_payment_product_groups_response.rb +34 -0
- data/lib/ingenico/direct/sdk/domain/get_payment_products_response.rb +34 -0
- data/lib/ingenico/direct/sdk/domain/gift_card_purchase.rb +35 -0
- data/lib/ingenico/direct/sdk/domain/hosted_checkout_specific_input.rb +55 -0
- data/lib/ingenico/direct/sdk/domain/hosted_checkout_specific_output.rb +31 -0
- data/lib/ingenico/direct/sdk/domain/label_template_element.rb +31 -0
- data/lib/ingenico/direct/sdk/domain/length_validator.rb +31 -0
- data/lib/ingenico/direct/sdk/domain/line_item.rb +47 -0
- data/lib/ingenico/direct/sdk/domain/line_item_invoice_data.rb +27 -0
- data/lib/ingenico/direct/sdk/domain/loan_recipient.rb +43 -0
- data/lib/ingenico/direct/sdk/domain/merchant_action.rb +35 -0
- data/lib/ingenico/direct/sdk/domain/mobile_payment_data.rb +31 -0
- data/lib/ingenico/direct/sdk/domain/mobile_payment_method_specific_input.rb +63 -0
- data/lib/ingenico/direct/sdk/domain/mobile_payment_method_specific_output.rb +59 -0
- data/lib/ingenico/direct/sdk/domain/mobile_payment_product320_specific_input.rb +31 -0
- data/lib/ingenico/direct/sdk/domain/order.rb +71 -0
- data/lib/ingenico/direct/sdk/domain/order_line_details.rb +55 -0
- data/lib/ingenico/direct/sdk/domain/order_references.rb +31 -0
- data/lib/ingenico/direct/sdk/domain/order_status_output.rb +50 -0
- data/lib/ingenico/direct/sdk/domain/order_type_information.rb +31 -0
- data/lib/ingenico/direct/sdk/domain/payment_account_on_file.rb +31 -0
- data/lib/ingenico/direct/sdk/domain/payment_creation_output.rb +39 -0
- data/lib/ingenico/direct/sdk/domain/payment_error_response.rb +46 -0
- data/lib/ingenico/direct/sdk/domain/payment_output.rb +79 -0
- data/lib/ingenico/direct/sdk/domain/payment_product.rb +77 -0
- data/lib/ingenico/direct/sdk/domain/payment_product5100_specific_input.rb +27 -0
- data/lib/ingenico/direct/sdk/domain/payment_product5402_specific_output.rb +27 -0
- data/lib/ingenico/direct/sdk/domain/payment_product5500_specific_output.rb +35 -0
- data/lib/ingenico/direct/sdk/domain/payment_product771_specific_output.rb +13 -0
- data/lib/ingenico/direct/sdk/domain/payment_product840_customer_account.rb +55 -0
- data/lib/ingenico/direct/sdk/domain/payment_product840_specific_output.rb +54 -0
- data/lib/ingenico/direct/sdk/domain/payment_product_display_hints.rb +35 -0
- data/lib/ingenico/direct/sdk/domain/payment_product_field.rb +47 -0
- data/lib/ingenico/direct/sdk/domain/payment_product_field_data_restrictions.rb +35 -0
- data/lib/ingenico/direct/sdk/domain/payment_product_field_display_element.rb +39 -0
- data/lib/ingenico/direct/sdk/domain/payment_product_field_display_hints.rb +71 -0
- data/lib/ingenico/direct/sdk/domain/payment_product_field_form_element.rb +38 -0
- data/lib/ingenico/direct/sdk/domain/payment_product_field_tooltip.rb +31 -0
- data/lib/ingenico/direct/sdk/domain/payment_product_field_validators.rb +91 -0
- data/lib/ingenico/direct/sdk/domain/payment_product_filter.rb +43 -0
- data/lib/ingenico/direct/sdk/domain/payment_product_filters_hosted_checkout.rb +38 -0
- data/lib/ingenico/direct/sdk/domain/payment_product_group.rb +43 -0
- data/lib/ingenico/direct/sdk/domain/payment_product_networks_response.rb +33 -0
- data/lib/ingenico/direct/sdk/domain/payment_references.rb +27 -0
- data/lib/ingenico/direct/sdk/domain/payment_response.rb +55 -0
- data/lib/ingenico/direct/sdk/domain/payment_status_output.rb +58 -0
- data/lib/ingenico/direct/sdk/domain/payout_error_response.rb +46 -0
- data/lib/ingenico/direct/sdk/domain/payout_output.rb +31 -0
- data/lib/ingenico/direct/sdk/domain/payout_response.rb +47 -0
- data/lib/ingenico/direct/sdk/domain/payout_result.rb +47 -0
- data/lib/ingenico/direct/sdk/domain/payout_status_output.rb +35 -0
- data/lib/ingenico/direct/sdk/domain/personal_information.rb +39 -0
- data/lib/ingenico/direct/sdk/domain/personal_information_token.rb +31 -0
- data/lib/ingenico/direct/sdk/domain/personal_name.rb +35 -0
- data/lib/ingenico/direct/sdk/domain/personal_name_token.rb +31 -0
- data/lib/ingenico/direct/sdk/domain/product_directory.rb +34 -0
- data/lib/ingenico/direct/sdk/domain/protection_eligibility.rb +31 -0
- data/lib/ingenico/direct/sdk/domain/range_validator.rb +31 -0
- data/lib/ingenico/direct/sdk/domain/redirect_data.rb +31 -0
- data/lib/ingenico/direct/sdk/domain/redirect_payment_method_specific_input.rb +67 -0
- data/lib/ingenico/direct/sdk/domain/redirect_payment_method_specific_output.rb +67 -0
- data/lib/ingenico/direct/sdk/domain/redirect_payment_product809_specific_input.rb +27 -0
- data/lib/ingenico/direct/sdk/domain/redirect_payment_product840_specific_input.rb +27 -0
- data/lib/ingenico/direct/sdk/domain/redirection_data.rb +27 -0
- data/lib/ingenico/direct/sdk/domain/refund_card_method_specific_output.rb +31 -0
- data/lib/ingenico/direct/sdk/domain/refund_e_wallet_method_specific_output.rb +39 -0
- data/lib/ingenico/direct/sdk/domain/refund_error_response.rb +46 -0
- data/lib/ingenico/direct/sdk/domain/refund_mobile_method_specific_output.rb +35 -0
- data/lib/ingenico/direct/sdk/domain/refund_output.rb +79 -0
- data/lib/ingenico/direct/sdk/domain/refund_payment_product840_customer_account.rb +35 -0
- data/lib/ingenico/direct/sdk/domain/refund_payment_product840_specific_output.rb +31 -0
- data/lib/ingenico/direct/sdk/domain/refund_redirect_method_specific_output.rb +31 -0
- data/lib/ingenico/direct/sdk/domain/refund_request.rb +31 -0
- data/lib/ingenico/direct/sdk/domain/refund_response.rb +47 -0
- data/lib/ingenico/direct/sdk/domain/refunds_response.rb +34 -0
- data/lib/ingenico/direct/sdk/domain/regular_expression_validator.rb +27 -0
- data/lib/ingenico/direct/sdk/domain/sepa_direct_debit_payment_method_specific_output.rb +43 -0
- data/lib/ingenico/direct/sdk/domain/session_request.rb +33 -0
- data/lib/ingenico/direct/sdk/domain/session_response.rb +49 -0
- data/lib/ingenico/direct/sdk/domain/shipping.rb +51 -0
- data/lib/ingenico/direct/sdk/domain/shopping_cart.rb +65 -0
- data/lib/ingenico/direct/sdk/domain/shopping_cart_extension.rb +52 -0
- data/lib/ingenico/direct/sdk/domain/test_connection.rb +27 -0
- data/lib/ingenico/direct/sdk/domain/three_d_secure.rb +63 -0
- data/lib/ingenico/direct/sdk/domain/three_d_secure_base.rb +47 -0
- data/lib/ingenico/direct/sdk/domain/three_d_secure_data.rb +35 -0
- data/lib/ingenico/direct/sdk/domain/three_d_secure_results.rb +31 -0
- data/lib/ingenico/direct/sdk/domain/token_card.rb +35 -0
- data/lib/ingenico/direct/sdk/domain/token_card_data.rb +31 -0
- data/lib/ingenico/direct/sdk/domain/token_card_specific_input.rb +31 -0
- data/lib/ingenico/direct/sdk/domain/token_data.rb +31 -0
- data/lib/ingenico/direct/sdk/domain/token_e_wallet.rb +35 -0
- data/lib/ingenico/direct/sdk/domain/token_response.rb +55 -0
- data/lib/ingenico/direct/sdk/domain/value_mapping_element.rb +38 -0
- data/lib/ingenico/direct/sdk/endpoint_configuration.rb +127 -0
- data/lib/ingenico/direct/sdk/exceptions.rb +8 -0
- data/lib/ingenico/direct/sdk/factory.rb +136 -0
- data/lib/ingenico/direct/sdk/idempotence_exception.rb +24 -0
- data/lib/ingenico/direct/sdk/logging.rb +10 -0
- data/lib/ingenico/direct/sdk/logging/communicator_logger.rb +22 -0
- data/lib/ingenico/direct/sdk/logging/log_message_builder.rb +56 -0
- data/lib/ingenico/direct/sdk/logging/logging_capable.rb +19 -0
- data/lib/ingenico/direct/sdk/logging/logging_util.rb +271 -0
- data/lib/ingenico/direct/sdk/logging/request_log_message_builder.rb +39 -0
- data/lib/ingenico/direct/sdk/logging/response_log_message_builder.rb +34 -0
- data/lib/ingenico/direct/sdk/logging/ruby_communicator_logger.rb +57 -0
- data/lib/ingenico/direct/sdk/logging/stdout_communicator_logger.rb +34 -0
- data/lib/ingenico/direct/sdk/marshaller.rb +24 -0
- data/lib/ingenico/direct/sdk/marshaller_syntax_exception.rb +6 -0
- data/lib/ingenico/direct/sdk/merchant/hostedcheckout/hosted_checkout_client.rb +87 -0
- data/lib/ingenico/direct/sdk/merchant/hostedtokenization/hosted_tokenization_client.rb +87 -0
- data/lib/ingenico/direct/sdk/merchant/merchant_client.rb +83 -0
- data/lib/ingenico/direct/sdk/merchant/payments/payments_client.rb +291 -0
- data/lib/ingenico/direct/sdk/merchant/payouts/payouts_client.rb +87 -0
- data/lib/ingenico/direct/sdk/merchant/productgroups/get_product_group_params.rb +58 -0
- data/lib/ingenico/direct/sdk/merchant/productgroups/get_product_groups_params.rb +58 -0
- data/lib/ingenico/direct/sdk/merchant/productgroups/product_groups_client.rb +88 -0
- data/lib/ingenico/direct/sdk/merchant/products/get_payment_product_networks_params.rb +39 -0
- data/lib/ingenico/direct/sdk/merchant/products/get_payment_product_params.rb +58 -0
- data/lib/ingenico/direct/sdk/merchant/products/get_payment_products_params.rb +58 -0
- data/lib/ingenico/direct/sdk/merchant/products/get_product_directory_params.rb +31 -0
- data/lib/ingenico/direct/sdk/merchant/products/products_client.rb +156 -0
- data/lib/ingenico/direct/sdk/merchant/services/services_client.rb +52 -0
- data/lib/ingenico/direct/sdk/merchant/sessions/sessions_client.rb +55 -0
- data/lib/ingenico/direct/sdk/merchant/tokens/tokens_client.rb +117 -0
- data/lib/ingenico/direct/sdk/meta_data_provider.rb +150 -0
- data/lib/ingenico/direct/sdk/modules.rb +71 -0
- data/lib/ingenico/direct/sdk/not_found_exception.rb +16 -0
- data/lib/ingenico/direct/sdk/param_request.rb +11 -0
- data/lib/ingenico/direct/sdk/pooled_connection.rb +21 -0
- data/lib/ingenico/direct/sdk/proxy_configuration.rb +74 -0
- data/lib/ingenico/direct/sdk/reference_exception.rb +14 -0
- data/lib/ingenico/direct/sdk/request_header.rb +50 -0
- data/lib/ingenico/direct/sdk/request_param.rb +23 -0
- data/lib/ingenico/direct/sdk/response_exception.rb +47 -0
- data/lib/ingenico/direct/sdk/response_header.rb +42 -0
- data/lib/ingenico/direct/sdk/validation_exception.rb +14 -0
- data/lib/ingenico/direct/sdk/webhooks.rb +11 -0
- data/lib/ingenico/direct/sdk/webhooks/api_version_mismatch_exception.rb +20 -0
- data/lib/ingenico/direct/sdk/webhooks/in_memory_secret_key_store.rb +56 -0
- data/lib/ingenico/direct/sdk/webhooks/secret_key_not_available_exception.rb +17 -0
- data/lib/ingenico/direct/sdk/webhooks/secret_key_store.rb +16 -0
- data/lib/ingenico/direct/sdk/webhooks/signature_validation_exception.rb +19 -0
- data/lib/ingenico/direct/sdk/webhooks/webhooks.rb +22 -0
- data/lib/ingenico/direct/sdk/webhooks/webhooks_event.rb +58 -0
- data/lib/ingenico/direct/sdk/webhooks/webhooks_helper.rb +99 -0
- data/lib/ingenico/direct/sdk/webhooks/webhooks_helper_builder.rb +25 -0
- metadata +385 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 608d59a24ebd4eb3ec8e92c39cce3c00f4feeb684e8d7488dcfa84cb116a393f
|
|
4
|
+
data.tar.gz: f1361fbd5ea74f47a3c2b98cb4ab1a035c375e5874f9588b0fa4ff7842a609a8
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: ad5862eb925037956977f3461badbff8e317cc2748b31704649e9d82221d2a8455bc1a9bf9c646d46ab23f08918b2d9cc6583e6227f1cb2d9c140a6d0201e906
|
|
7
|
+
data.tar.gz: a7e2c636f4b33918ad34d1985a7b29e56b26bcd69ce40b633d2983f53e7a4cea5353b3a0f6e659dd951c7e76442d938cdd3c3a9a0e68ca03c3af8f335d7a14e7
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2016 Global Collect Services B.V.
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person
|
|
4
|
+
obtaining a copy of this software and associated documentation
|
|
5
|
+
files (the "Software"), to deal in the Software without
|
|
6
|
+
restriction, including without limitation the rights to use,
|
|
7
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the
|
|
9
|
+
Software is furnished to do so, subject to the following
|
|
10
|
+
conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be
|
|
13
|
+
included in all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
17
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
19
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
20
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
21
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# Ingenico Direct Ruby SDK
|
|
2
|
+
|
|
3
|
+
## Introduction
|
|
4
|
+
|
|
5
|
+
The Ruby SDK helps you to communicate with the [Ingenico Direct](https://support.direct.ingenico.com/) Server API. Its primary features are:
|
|
6
|
+
|
|
7
|
+
* convenient Ruby library for the API calls and responses
|
|
8
|
+
* marshalls Ruby request objects to HTTP requests
|
|
9
|
+
* unmarshalls HTTP responses to Ruby response objects or Ruby exceptions
|
|
10
|
+
* handling of all the details concerning authentication
|
|
11
|
+
* handling of required meta data
|
|
12
|
+
|
|
13
|
+
Its use is demonstrated by an example for each possible call. The examples execute a call using the provided API keys.
|
|
14
|
+
|
|
15
|
+
See the [Ingenico Direct Developer Hub](https://support.direct.ingenico.com/documentation/sdk/server/ruby/) for more information on how to use the SDK.
|
|
16
|
+
|
|
17
|
+
## Structure of this repository
|
|
18
|
+
|
|
19
|
+
This repository consists out of three main components:
|
|
20
|
+
|
|
21
|
+
1. The source code of the SDK itself: `/lib/ingenico/direct/sdk/`
|
|
22
|
+
2. The source code of the SDK unit tests: `/spec/lib/`
|
|
23
|
+
3. The source code of the SDK integration tests: `/spec/integration/`
|
|
24
|
+
|
|
25
|
+
Note that the source code of the unit tests and integration tests can only be found on GitHub.
|
|
26
|
+
|
|
27
|
+
## Requirements
|
|
28
|
+
|
|
29
|
+
Ruby 2.3 or higher is required.
|
|
30
|
+
As for JRuby, version 9.0.0.0 and higher are supported.
|
|
31
|
+
In addition, the following packages are required:
|
|
32
|
+
|
|
33
|
+
* [httpclient](https://github.com/nahi/httpclient) 2.8 or higher
|
|
34
|
+
* [concurrent-ruby](https://github.com/ruby-concurrency/concurrent-ruby) 1.0 or higher
|
|
35
|
+
|
|
36
|
+
## Installation
|
|
37
|
+
|
|
38
|
+
### Using RubyGems
|
|
39
|
+
|
|
40
|
+
To install the SDK using `gem`, execute the following command:
|
|
41
|
+
|
|
42
|
+
gem install direct-sdk-ruby
|
|
43
|
+
|
|
44
|
+
### Using a pre-built gem
|
|
45
|
+
|
|
46
|
+
1. Download the latest version of the Ruby SDK from GitHub. Choose the `direct-sdk-ruby-x.y.z.gem` file from the [releases](https://github.com/Ingenico/direct-sdk-ruby/releases) page, where `x.y.z` is the version number.
|
|
47
|
+
2. Navigate into the folder where the gem file is downloaded to, and execute the following command:
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
gem install direct-sdk-ruby-x.y.z.gem
|
|
51
|
+
```
|
|
52
|
+
3. Feel free to delete the gem file at this point, it is no longer required.
|
|
53
|
+
|
|
54
|
+
### From source
|
|
55
|
+
|
|
56
|
+
1. Download the latest version of the Ruby SDK from GitHub. Choose the `direct-sdk-ruby-x.y.z.zip` file from the [releases](https://github.com/Ingenico/direct-sdk-ruby/releases) page, where `x.y.z` is the version number.
|
|
57
|
+
2. Unzip the file, navigate into the folder where the file is unzipped to, and execute the following commands:
|
|
58
|
+
|
|
59
|
+
```
|
|
60
|
+
gem build direct-sdk-ruby.gemspec
|
|
61
|
+
gem install direct-sdk-ruby-x.y.z.gem
|
|
62
|
+
```
|
|
63
|
+
3. Feel free to delete the unzipped archive, the zip file, and the gem file at this point; they are no longer required.
|
|
64
|
+
|
|
65
|
+
## Uninstalling
|
|
66
|
+
|
|
67
|
+
After the Ruby SDK has been installed, it can be uninstalled using the
|
|
68
|
+
following command:
|
|
69
|
+
|
|
70
|
+
gem uninstall direct-sdk-ruby
|
|
71
|
+
|
|
72
|
+
The required packages can be uninstalled in the same way.
|
|
73
|
+
|
|
74
|
+
## Usage
|
|
75
|
+
|
|
76
|
+
After the Ruby SDK has been installed, it can be required in Ruby program as follows:
|
|
77
|
+
|
|
78
|
+
require 'ingenico/direct/sdk'
|
|
79
|
+
|
|
80
|
+
## Running tests
|
|
81
|
+
|
|
82
|
+
There are two types of tests: unit tests and integration tests. The unit tests will work out-of-the-box; for the integration tests some configuration is required.
|
|
83
|
+
First, some environment variables need to be set:
|
|
84
|
+
|
|
85
|
+
* `direct_api_apiKeyId` for the API key id to use. This can be retrieved from the Configuration Center.
|
|
86
|
+
* `direct_api_secretApiKey` for the secret API key to use. This can be retrieved from the Configuration Center.
|
|
87
|
+
* `direct_api_merchantId` for your merchant ID.
|
|
88
|
+
|
|
89
|
+
In addition, to run the proxy integration tests, the proxy URI, username and password should be set in the `spec/fixtures/resources/properties.proxy.yml` file.
|
|
90
|
+
|
|
91
|
+
In order to run the unit and integration tests, some additional dependencies are required:
|
|
92
|
+
|
|
93
|
+
* [rake](https://ruby.github.io/rake/) 12.3.3 or higher
|
|
94
|
+
* [rspec](https://github.com/rspec/rspec) 3.5 or higher
|
|
95
|
+
* [webmock](https://github.com/bblimke/webmock) 2.1 or higher
|
|
96
|
+
* [sinatra](https://github.com/sinatra/sinatra) 1.4 or higher
|
|
97
|
+
|
|
98
|
+
They can be installed using the following command:
|
|
99
|
+
|
|
100
|
+
gem install rake rspec webmock sinatra
|
|
101
|
+
|
|
102
|
+
*Note: if rake is already installed as part of the Ruby installation, this will cause a conflict error. This can safely be ignored.*
|
|
103
|
+
|
|
104
|
+
The following commands can now be executed from the root directory of the SDK folder (/) to execute the tests:
|
|
105
|
+
|
|
106
|
+
* Unit tests:
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
rake unit
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
* Integration tests:
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
rake integration
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
* Both unit and integration tests:
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
rake spec
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Generating documentation
|
|
125
|
+
|
|
126
|
+
Documentation can be generated with YARD. YARD can be installed as a gem. The gems required to generate documentation are:
|
|
127
|
+
|
|
128
|
+
* [rake](https://ruby.github.io/rake/) 12.3.3 or higher
|
|
129
|
+
* [yard](https://github.com/lsegal/yard) 0.9.5 or higher
|
|
130
|
+
|
|
131
|
+
They can be installed using the following command:
|
|
132
|
+
|
|
133
|
+
gem install rake yard
|
|
134
|
+
|
|
135
|
+
*Note: if rake is already installed as part of the Ruby installation, this will cause a conflict error. This can safely be ignored.*
|
|
136
|
+
|
|
137
|
+
Once YARD and rake are installed, documentation can be generated with the following command (ran from the root folder):
|
|
138
|
+
|
|
139
|
+
rake yard
|
|
140
|
+
|
|
141
|
+
Documentation will be generated in the `/doc` folder. The file `/doc/index.html` is the main documentation file.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
begin
|
|
2
|
+
require 'rspec/core/rake_task'
|
|
3
|
+
|
|
4
|
+
RSpec::Core::RakeTask.new(:spec) do |t| # supports automated testing using the command *rake* *spec*
|
|
5
|
+
t.rspec_opts = '--color --format documentation'
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
RSpec::Core::RakeTask.new(:unit) do |t| # supports automated testing using unit tests using the command *rake* *unit*
|
|
9
|
+
t.rspec_opts = '--color --format documentation'
|
|
10
|
+
t.exclude_pattern = 'spec/integration/**'
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
RSpec::Core::RakeTask.new(:integration) do |t| # supports automated testing of integration using the command *rake* *integration*
|
|
14
|
+
t.rspec_opts = '--color --format documentation'
|
|
15
|
+
t.pattern = 'spec/integration/**_spec.rb'
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
task :default => :spec
|
|
19
|
+
rescue LoadError
|
|
20
|
+
puts '[*] error -- development dependency is not installed'
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
begin
|
|
24
|
+
require 'yard'
|
|
25
|
+
|
|
26
|
+
YARD::Rake::YardocTask.new(:yard) do |t| # supports generating documentation using the command *rake* *yard*
|
|
27
|
+
# t.files = ['lib/**/*.rb', OTHER_PATHS] # optional
|
|
28
|
+
t.options = ['--no-private']
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
task :doc => :yard # alternative alias to generate documentation
|
|
32
|
+
rescue LoadError
|
|
33
|
+
puts '[*] error -- development dependency is not installed'
|
|
34
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
Gem::Specification.new do |spec|
|
|
2
|
+
spec.name = 'direct-sdk-ruby'
|
|
3
|
+
spec.version = '1.0.0'
|
|
4
|
+
spec.authors = ['Ingenico ePayments']
|
|
5
|
+
spec.email = ['60233882+ingenico-dev-team@users.noreply.github.com']
|
|
6
|
+
spec.summary = %q{SDK to communicate with the Ingenico ePayments platform using the Ingenico Direct Server API}
|
|
7
|
+
spec.description = %q{SDK to communicate with the Ingenico ePayments platform using the Ingenico Direct Server API}
|
|
8
|
+
spec.homepage = %q{https://github.com/Ingenico/direct-sdk-ruby}
|
|
9
|
+
spec.license = 'MIT'
|
|
10
|
+
|
|
11
|
+
# exclude hidden files like .gitignore
|
|
12
|
+
spec.files = Dir['lib/**/*'] + %w[direct-sdk-ruby.gemspec Gemfile LICENSE.txt Rakefile README.md]
|
|
13
|
+
spec.executables = spec.files.grep(%r{^bin\/}) { |f| File.basename(f) }
|
|
14
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)\/})
|
|
15
|
+
spec.require_paths = ['lib']
|
|
16
|
+
|
|
17
|
+
spec.required_ruby_version = '>= 2.0'
|
|
18
|
+
|
|
19
|
+
spec.add_dependency 'httpclient', '~> 2.8'
|
|
20
|
+
spec.add_dependency 'concurrent-ruby', '~>1.0'
|
|
21
|
+
|
|
22
|
+
spec.add_development_dependency 'yard', '~> 0.9'
|
|
23
|
+
spec.add_development_dependency 'rspec', '~> 3.5'
|
|
24
|
+
spec.add_development_dependency 'webmock', '~> 2.1'
|
|
25
|
+
spec.add_development_dependency 'sinatra', '~> 1.4'
|
|
26
|
+
spec.add_development_dependency 'rake', '~> 12.3', '>= 12.3.3'
|
|
27
|
+
# spec.metadata['yard.run'] = 'yri' # compiles yard doc on install
|
|
28
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
prefix = 'ingenico/direct/sdk'
|
|
2
|
+
|
|
3
|
+
require "#{prefix}/logging"
|
|
4
|
+
require "#{prefix}/exceptions"
|
|
5
|
+
|
|
6
|
+
require "#{prefix}/marshaller"
|
|
7
|
+
require "#{prefix}/response_header"
|
|
8
|
+
require "#{prefix}/authenticator"
|
|
9
|
+
require "#{prefix}/data_object"
|
|
10
|
+
require "#{prefix}/proxy_configuration"
|
|
11
|
+
require "#{prefix}/connection"
|
|
12
|
+
require "#{prefix}/pooled_connection"
|
|
13
|
+
require "#{prefix}/communicator"
|
|
14
|
+
require "#{prefix}/endpoint_configuration"
|
|
15
|
+
require "#{prefix}/communicator_configuration"
|
|
16
|
+
require "#{prefix}/client"
|
|
17
|
+
require "#{prefix}/call_context"
|
|
18
|
+
require "#{prefix}/api_resource"
|
|
19
|
+
require "#{prefix}/request_param"
|
|
20
|
+
require "#{prefix}/request_header"
|
|
21
|
+
require "#{prefix}/param_request"
|
|
22
|
+
require "#{prefix}/meta_data_provider"
|
|
23
|
+
require "#{prefix}/factory"
|
|
24
|
+
|
|
25
|
+
require "#{prefix}/defaultimpl"
|
|
26
|
+
require "#{prefix}/webhooks"
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
module Ingenico::Direct::SDK
|
|
2
|
+
|
|
3
|
+
# Base class for many exceptions raised by the SDK.
|
|
4
|
+
# It is raised when an error response is received from the Ingenico ePayments platform.
|
|
5
|
+
# It contains data about the returned response.
|
|
6
|
+
#
|
|
7
|
+
# @attr_reader [Integer] status_code HTTP status code of the returned response.
|
|
8
|
+
# @attr_reader [String] response_body Message body of the returned response.
|
|
9
|
+
# @attr_reader [String] error_id An error id corresponding to the error that occurred, if available.
|
|
10
|
+
# @attr_reader [Array<Ingenico::Direct::SDK::Domain::APIError>] errors A list of errors received from the Ingenico ePayments platform;
|
|
11
|
+
# may be empty but never _nil_
|
|
12
|
+
class ApiException < RuntimeError
|
|
13
|
+
|
|
14
|
+
# Creates a new ApiException that reports an error response from the Ingenico ePayments platform.
|
|
15
|
+
#
|
|
16
|
+
# @param status_code (Integer) HTTP status code the response
|
|
17
|
+
# @param response_body (String) HTTP response body
|
|
18
|
+
# @param error_id (String) error id of the error, may be _nil_
|
|
19
|
+
# @param errors (Array<Ingenico::Direct::SDK::Domain::APIError>) a list of errors that occurred, may be empty
|
|
20
|
+
# @param message (String) error message to include
|
|
21
|
+
def initialize(status_code, response_body, error_id, errors,
|
|
22
|
+
message = 'the Ingenico ePayments platform returned an error response')
|
|
23
|
+
super(message)
|
|
24
|
+
@status_code = status_code
|
|
25
|
+
@response_body = response_body
|
|
26
|
+
@error_id = error_id
|
|
27
|
+
@errors = errors || [].freeze
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
attr_reader :status_code
|
|
31
|
+
attr_reader :response_body
|
|
32
|
+
attr_reader :error_id
|
|
33
|
+
attr_reader :errors
|
|
34
|
+
|
|
35
|
+
def to_s
|
|
36
|
+
str = super.to_s
|
|
37
|
+
str += "; status_code=#{@status_code}" if @status_code.positive?
|
|
38
|
+
str += "; response_body='#{@response_body}'" if @response_body&.length&.positive?
|
|
39
|
+
str.to_s
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
require 'ingenico/direct/sdk/domain/error_response'
|
|
2
|
+
|
|
3
|
+
module Ingenico::Direct::SDK
|
|
4
|
+
|
|
5
|
+
# Base class of all Ingenico ePayments platform API resources.
|
|
6
|
+
# Provides shared functionality to facilitate communication with the Ingenico ePayments platform.
|
|
7
|
+
#
|
|
8
|
+
# @attr_reader [Ingenico::Direct::SDK::Communicator] communicator Communicator instance that provides communication with the Ingenico ePayments platform.
|
|
9
|
+
# @attr_reader [String] client_meta_info JSON string containing client info specific to the current client.
|
|
10
|
+
class ApiResource
|
|
11
|
+
|
|
12
|
+
# Creates a new ApiResource.
|
|
13
|
+
#
|
|
14
|
+
# @param arg [Ingenico::Direct::SDK::ApiResource, Ingenico::Direct::SDK::Communicator] parent class or Communicator instance.
|
|
15
|
+
# If a parent class is given its communicator will be used for communication.
|
|
16
|
+
# @param path_context [Hash, nil] hash that contains substitutions for generic locations in the URL path.
|
|
17
|
+
# This hash will be used to instantiate a concrete URL used to access specific resources.
|
|
18
|
+
# For example in the URL https://payment.preprod.direct.ingenico.com/!{version}/!{merchantId}/payments
|
|
19
|
+
# !{version} and !{merchantId} can be instantiated using the hash
|
|
20
|
+
# !{'version' => 'v2', 'merchantId' => '1'}. The final URL in this case will be
|
|
21
|
+
# https://payment.preprod.direct.ingenico.com/v2/1/payments.
|
|
22
|
+
# @param client_meta_info [String, nil] JSON string containing the meta data for the client.
|
|
23
|
+
def initialize(arg, path_context = nil, client_meta_info = false)
|
|
24
|
+
if client_meta_info == false
|
|
25
|
+
raise ArgumentError, 'parent is required' unless arg
|
|
26
|
+
|
|
27
|
+
@parent = arg
|
|
28
|
+
@communicator = arg.communicator
|
|
29
|
+
@client_meta_info = arg.client_meta_info
|
|
30
|
+
else
|
|
31
|
+
raise ArgumentError, 'communicator is required' unless arg
|
|
32
|
+
|
|
33
|
+
@parent = nil
|
|
34
|
+
@communicator = arg
|
|
35
|
+
@client_meta_info = client_meta_info
|
|
36
|
+
end
|
|
37
|
+
@path_context = path_context
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
attr_reader :communicator
|
|
41
|
+
attr_reader :client_meta_info
|
|
42
|
+
|
|
43
|
+
protected
|
|
44
|
+
|
|
45
|
+
# @return [Array<Ingenico::Direct::SDK::RequestHeader>, nil] the X-GCS-ClientMetaInfo header.
|
|
46
|
+
def client_headers
|
|
47
|
+
@client_meta_info ?
|
|
48
|
+
[RequestHeader.new('X-GCS-ClientMetaInfo', @client_meta_info)] :
|
|
49
|
+
nil
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def instantiate_uri(uri, path_context = nil)
|
|
53
|
+
uri = replace_all(uri, path_context) if path_context
|
|
54
|
+
uri = replace_all(uri, @path_context)
|
|
55
|
+
@parent ? @parent.instantiate_uri(uri) : uri
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def create_exception(status_code, response_body, error_object, context)
|
|
59
|
+
if error_object.nil?
|
|
60
|
+
error_id = nil
|
|
61
|
+
errors = []
|
|
62
|
+
elsif error_object.is_a?(Ingenico::Direct::SDK::Domain::PaymentErrorResponse) && error_object.payment_result
|
|
63
|
+
return DeclinedPaymentException.new(status_code, response_body, error_object)
|
|
64
|
+
elsif error_object.is_a?(Ingenico::Direct::SDK::Domain::PayoutErrorResponse) && error_object.payout_result
|
|
65
|
+
return DeclinedPayoutException.new(status_code, response_body, error_object)
|
|
66
|
+
elsif error_object.is_a?(Ingenico::Direct::SDK::Domain::RefundErrorResponse) && error_object.refund_result
|
|
67
|
+
return DeclinedRefundException.new(status_code, response_body, error_object)
|
|
68
|
+
elsif error_object.is_a?(Ingenico::Direct::SDK::Domain::PaymentErrorResponse) ||
|
|
69
|
+
error_object.is_a?(Ingenico::Direct::SDK::Domain::PayoutErrorResponse) ||
|
|
70
|
+
error_object.is_a?(Ingenico::Direct::SDK::Domain::RefundErrorResponse) ||
|
|
71
|
+
error_object.is_a?(Ingenico::Direct::SDK::Domain::ErrorResponse)
|
|
72
|
+
error_id = error_object.error_id
|
|
73
|
+
errors = error_object.errors
|
|
74
|
+
else
|
|
75
|
+
raise ArgumentError, "unsupported error object type: #{error_object.class.name}"
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
case status_code
|
|
79
|
+
when 400
|
|
80
|
+
return ValidationException.new(status_code, response_body, error_id, errors)
|
|
81
|
+
when 403
|
|
82
|
+
return AuthorizationException.new(status_code, response_body, error_id, errors)
|
|
83
|
+
when 404, 410
|
|
84
|
+
return ReferenceException.new(status_code, response_body, error_id, errors)
|
|
85
|
+
when 409
|
|
86
|
+
if is_idempotence_error(errors, context)
|
|
87
|
+
idempotence_key = context.idempotence_key
|
|
88
|
+
idempotence_request_timestamp = context.idempotence_request_timestamp
|
|
89
|
+
return IdempotenceException.new(status_code, response_body, error_id,
|
|
90
|
+
errors, idempotence_key,
|
|
91
|
+
idempotence_request_timestamp)
|
|
92
|
+
else
|
|
93
|
+
return ReferenceException.new(status_code, response_body, error_id, errors)
|
|
94
|
+
end
|
|
95
|
+
when 500, 502, 503
|
|
96
|
+
return DirectException.new(status_code, response_body, error_id, errors)
|
|
97
|
+
else
|
|
98
|
+
return ApiException.new(status_code, response_body, error_id, errors)
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
private
|
|
103
|
+
|
|
104
|
+
def replace_all(uri, path_context)
|
|
105
|
+
path_context&.each do |key, value|
|
|
106
|
+
uri = uri.gsub("{#{key}}", value)
|
|
107
|
+
end
|
|
108
|
+
uri
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def is_idempotence_error(errors, context)
|
|
112
|
+
context&.idempotence_key && errors.length == 1 && errors[0].code == '1409'
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Ingenico::Direct::SDK
|
|
2
|
+
|
|
3
|
+
# Abstract class that is responsible for authenticating requests sent to the Ingenico ePayments platform.
|
|
4
|
+
class Authenticator
|
|
5
|
+
|
|
6
|
+
# Creates a signature to authenticate a request.
|
|
7
|
+
#
|
|
8
|
+
# @param http_method [String] 'GET', 'PUT', 'POST' or 'DELETE' indicating which HTTP method will be used with the request
|
|
9
|
+
# @param resource_uri [URI::HTTP] URI object that includes #path and #query of the URL that will be used, #query may be *nil*
|
|
10
|
+
# @param request_headers [Array<Ingenico::Direct::SDK::RequestHeader>] all headers used by the request
|
|
11
|
+
# @return [String] the created signature
|
|
12
|
+
def create_simple_authentication_signature(http_method, resource_uri, request_headers)
|
|
13
|
+
raise NotImplementedError
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|