connect-sdk-ruby 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +2 -0
- data/LICENSE.txt +22 -0
- data/README.md +140 -0
- data/Rakefile +34 -0
- data/connect-sdk-ruby.gemspec +28 -0
- data/examples/merchant/example_configuration.yml +6 -0
- data/examples/merchant/hostedcheckouts/create_hosted_checkout_example.rb +53 -0
- data/examples/merchant/hostedcheckouts/get_hosted_checkout_example.rb +22 -0
- data/examples/merchant/payments/approve_payment_example.rb +42 -0
- data/examples/merchant/payments/cancel_approval_payment_example.rb +22 -0
- data/examples/merchant/payments/cancel_payment_example.rb +22 -0
- data/examples/merchant/payments/create_payment_example.rb +177 -0
- data/examples/merchant/payments/get_payment_example.rb +22 -0
- data/examples/merchant/payments/process_challenged_payment_example.rb +22 -0
- data/examples/merchant/payments/refund_payment_example.rb +85 -0
- data/examples/merchant/payments/tokenize_payment_example.rb +27 -0
- data/examples/merchant/payouts/approve_payout_example.rb +27 -0
- data/examples/merchant/payouts/cancel_approval_payout_example.rb +22 -0
- data/examples/merchant/payouts/cancel_payout_example.rb +22 -0
- data/examples/merchant/payouts/create_payout_example.rb +96 -0
- data/examples/merchant/payouts/get_payout_example.rb +22 -0
- data/examples/merchant/productgroups/get_payment_product_group_example.rb +32 -0
- data/examples/merchant/productgroups/get_payment_product_groups_example.rb +32 -0
- data/examples/merchant/products/get_directory_example.rb +28 -0
- data/examples/merchant/products/get_payment_product_example.rb +32 -0
- data/examples/merchant/products/get_payment_products_example.rb +32 -0
- data/examples/merchant/refunds/approve_refund_example.rb +27 -0
- data/examples/merchant/refunds/cancel_approval_refund_example.rb +22 -0
- data/examples/merchant/refunds/cancel_refund_example.rb +22 -0
- data/examples/merchant/refunds/get_refund_example.rb +22 -0
- data/examples/merchant/riskassessments/risk_assessment_bank_account_example.rb +54 -0
- data/examples/merchant/riskassessments/risk_assessment_cards_example.rb +114 -0
- data/examples/merchant/services/convert_amount_example.rb +29 -0
- data/examples/merchant/services/convert_bank_account_example.rb +34 -0
- data/examples/merchant/services/iin_details_example.rb +27 -0
- data/examples/merchant/services/test_connection_example.rb +22 -0
- data/examples/merchant/sessions/create_session_example.rb +34 -0
- data/examples/merchant/tokens/approve_sepa_direct_debit_token_example.rb +29 -0
- data/examples/merchant/tokens/create_token_example.rb +82 -0
- data/examples/merchant/tokens/delete_token_example.rb +27 -0
- data/examples/merchant/tokens/get_token_example.rb +22 -0
- data/examples/merchant/tokens/update_token_example.rb +76 -0
- data/lib/ingenico/connect/sdk.rb +27 -0
- data/lib/ingenico/connect/sdk/api_exception.rb +52 -0
- data/lib/ingenico/connect/sdk/api_resource.rb +126 -0
- data/lib/ingenico/connect/sdk/authenticator.rb +15 -0
- data/lib/ingenico/connect/sdk/authorization_exception.rb +13 -0
- data/lib/ingenico/connect/sdk/call_context.rb +26 -0
- data/lib/ingenico/connect/sdk/client.rb +92 -0
- data/lib/ingenico/connect/sdk/communication_exception.rb +15 -0
- data/lib/ingenico/connect/sdk/communicator.rb +277 -0
- data/lib/ingenico/connect/sdk/communicator_configuration.rb +98 -0
- data/lib/ingenico/connect/sdk/connection.rb +31 -0
- data/lib/ingenico/connect/sdk/data_object.rb +43 -0
- data/lib/ingenico/connect/sdk/declined_payment_exception.rb +44 -0
- data/lib/ingenico/connect/sdk/declined_payout_exception.rb +44 -0
- data/lib/ingenico/connect/sdk/declined_refund_exception.rb +46 -0
- data/lib/ingenico/connect/sdk/declined_transaction_exception.rb +16 -0
- data/lib/ingenico/connect/sdk/defaultimpl.rb +6 -0
- data/lib/ingenico/connect/sdk/defaultimpl/authorization_type.rb +18 -0
- data/lib/ingenico/connect/sdk/defaultimpl/default_authenticator.rb +106 -0
- data/lib/ingenico/connect/sdk/defaultimpl/default_connection.rb +242 -0
- data/lib/ingenico/connect/sdk/defaultimpl/default_marshaller.rb +35 -0
- data/lib/ingenico/connect/sdk/domain/definitions/abstract_order_status.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/definitions/abstract_payment_method_specific_input.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/definitions/additional_order_input_airline_data.rb +36 -0
- data/lib/ingenico/connect/sdk/domain/definitions/address.rb +81 -0
- data/lib/ingenico/connect/sdk/domain/definitions/airline_data.rb +165 -0
- data/lib/ingenico/connect/sdk/domain/definitions/airline_flight_leg.rb +102 -0
- data/lib/ingenico/connect/sdk/domain/definitions/amount_of_money.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/definitions/bank_account.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/definitions/bank_account_bban.rb +67 -0
- data/lib/ingenico/connect/sdk/domain/definitions/bank_account_iban.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/definitions/card.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/definitions/card_essentials.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/definitions/card_fraud_results.rb +50 -0
- data/lib/ingenico/connect/sdk/domain/definitions/card_without_cvv.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/definitions/company_information.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/definitions/contact_details_base.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/definitions/customer_base.rb +50 -0
- data/lib/ingenico/connect/sdk/domain/definitions/fraud_fields.rb +115 -0
- data/lib/ingenico/connect/sdk/domain/definitions/fraud_results.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/definitions/fraud_results_retail_decisions.rb +46 -0
- data/lib/ingenico/connect/sdk/domain/definitions/key_value_pair.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/definitions/order_status_output.rb +67 -0
- data/lib/ingenico/connect/sdk/domain/definitions/payment_product_filter.rb +51 -0
- data/lib/ingenico/connect/sdk/domain/definitions/personal_name_base.rb +46 -0
- data/lib/ingenico/connect/sdk/domain/definitions/result_do_risk_assessment.rb +61 -0
- data/lib/ingenico/connect/sdk/domain/definitions/retail_decisions_cc_fraud_check_output.rb +46 -0
- data/lib/ingenico/connect/sdk/domain/definitions/validation_bank_account_check.rb +46 -0
- data/lib/ingenico/connect/sdk/domain/definitions/validation_bank_account_output.rb +67 -0
- data/lib/ingenico/connect/sdk/domain/errors/api_error.rb +60 -0
- data/lib/ingenico/connect/sdk/domain/errors/error_response.rb +46 -0
- data/lib/ingenico/connect/sdk/domain/hostedcheckout/create_hosted_checkout_request.rb +102 -0
- data/lib/ingenico/connect/sdk/domain/hostedcheckout/create_hosted_checkout_response.rb +59 -0
- data/lib/ingenico/connect/sdk/domain/hostedcheckout/created_payment_output.rb +72 -0
- data/lib/ingenico/connect/sdk/domain/hostedcheckout/displayed_data.rb +53 -0
- data/lib/ingenico/connect/sdk/domain/hostedcheckout/get_hosted_checkout_response.rb +43 -0
- data/lib/ingenico/connect/sdk/domain/hostedcheckout/hosted_checkout_specific_input.rb +78 -0
- data/lib/ingenico/connect/sdk/domain/hostedcheckout/payment_product_filters_hosted_checkout.rb +53 -0
- data/lib/ingenico/connect/sdk/domain/metadata/shopping_cart_extension.rb +48 -0
- data/lib/ingenico/connect/sdk/domain/payment/abstract_payment_method_specific_output.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/payment/additional_order_input.rb +72 -0
- data/lib/ingenico/connect/sdk/domain/payment/address_personal.rb +36 -0
- data/lib/ingenico/connect/sdk/domain/payment/approve_payment_card_payment_method_specific_output.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/payment/approve_payment_non_sepa_direct_debit_payment_method_specific_input.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/payment/approve_payment_payment_method_specific_input.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/payment/approve_payment_request.rb +65 -0
- data/lib/ingenico/connect/sdk/domain/payment/approve_payment_sepa_direct_debit_payment_method_specific_input.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/payment/bank_transfer_payment_method_specific_input.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/payment/bank_transfer_payment_method_specific_input_base.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/payment/bank_transfer_payment_method_specific_output.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/payment/cancel_approval_payment_response.rb +36 -0
- data/lib/ingenico/connect/sdk/domain/payment/cancel_payment_card_payment_method_specific_output.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/payment/cancel_payment_response.rb +47 -0
- data/lib/ingenico/connect/sdk/domain/payment/card_payment_method_specific_input.rb +61 -0
- data/lib/ingenico/connect/sdk/domain/payment/card_payment_method_specific_input_base.rb +60 -0
- data/lib/ingenico/connect/sdk/domain/payment/card_payment_method_specific_output.rb +65 -0
- data/lib/ingenico/connect/sdk/domain/payment/cash_payment_method_specific_input.rb +47 -0
- data/lib/ingenico/connect/sdk/domain/payment/cash_payment_method_specific_input_base.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/payment/cash_payment_method_specific_output.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/payment/cash_payment_product1503_specific_input.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/payment/cash_payment_product1504_specific_input.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/payment/contact_details.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/payment/create_payment_request.rb +131 -0
- data/lib/ingenico/connect/sdk/domain/payment/create_payment_response.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/payment/create_payment_result.rb +58 -0
- data/lib/ingenico/connect/sdk/domain/payment/customer.rb +83 -0
- data/lib/ingenico/connect/sdk/domain/payment/external_cardholder_authentication_data.rb +60 -0
- data/lib/ingenico/connect/sdk/domain/payment/invoice_payment_method_specific_input.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/payment/invoice_payment_method_specific_output.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/payment/level3_summary_data.rb +46 -0
- data/lib/ingenico/connect/sdk/domain/payment/line_item.rb +58 -0
- data/lib/ingenico/connect/sdk/domain/payment/line_item_invoice_data.rb +60 -0
- data/lib/ingenico/connect/sdk/domain/payment/line_item_level3_interchange_information.rb +81 -0
- data/lib/ingenico/connect/sdk/domain/payment/merchant_action.rb +64 -0
- data/lib/ingenico/connect/sdk/domain/payment/non_sepa_direct_debit_payment_method_specific_input.rb +71 -0
- data/lib/ingenico/connect/sdk/domain/payment/non_sepa_direct_debit_payment_method_specific_output.rb +36 -0
- data/lib/ingenico/connect/sdk/domain/payment/non_sepa_direct_debit_payment_product705_specific_input.rb +50 -0
- data/lib/ingenico/connect/sdk/domain/payment/order.rb +83 -0
- data/lib/ingenico/connect/sdk/domain/payment/order_approve_payment.rb +47 -0
- data/lib/ingenico/connect/sdk/domain/payment/order_invoice_data.rb +59 -0
- data/lib/ingenico/connect/sdk/domain/payment/order_output.rb +47 -0
- data/lib/ingenico/connect/sdk/domain/payment/order_references.rb +57 -0
- data/lib/ingenico/connect/sdk/domain/payment/order_references_approve_payment.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/payment/order_type_information.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/payment/payment.rb +54 -0
- data/lib/ingenico/connect/sdk/domain/payment/payment_approval_response.rb +47 -0
- data/lib/ingenico/connect/sdk/domain/payment/payment_creation_output.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/payment/payment_creation_references.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/payment/payment_error_response.rb +57 -0
- data/lib/ingenico/connect/sdk/domain/payment/payment_output.rb +116 -0
- data/lib/ingenico/connect/sdk/domain/payment/payment_product836_specific_output.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/payment/payment_product840_customer_account.rb +88 -0
- data/lib/ingenico/connect/sdk/domain/payment/payment_product840_specific_output.rb +47 -0
- data/lib/ingenico/connect/sdk/domain/payment/payment_references.rb +67 -0
- data/lib/ingenico/connect/sdk/domain/payment/payment_response.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/payment/payment_status_output.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/payment/personal_information.rb +50 -0
- data/lib/ingenico/connect/sdk/domain/payment/personal_name.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/payment/redirect_data.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/payment/redirect_payment_method_specific_input.rb +72 -0
- data/lib/ingenico/connect/sdk/domain/payment/redirect_payment_method_specific_input_base.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/payment/redirect_payment_method_specific_output.rb +58 -0
- data/lib/ingenico/connect/sdk/domain/payment/redirect_payment_product809_specific_input.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/payment/redirect_payment_product816_specific_input.rb +36 -0
- data/lib/ingenico/connect/sdk/domain/payment/redirect_payment_product882_specific_input.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/payment/refund_bank_method_specific_output.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/payment/refund_card_method_specific_output.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/payment/refund_e_wallet_method_specific_output.rb +36 -0
- data/lib/ingenico/connect/sdk/domain/payment/refund_method_specific_output.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/payment/refund_output.rb +72 -0
- data/lib/ingenico/connect/sdk/domain/payment/refund_payment_product840_customer_account.rb +46 -0
- data/lib/ingenico/connect/sdk/domain/payment/refund_payment_product840_specific_output.rb +36 -0
- data/lib/ingenico/connect/sdk/domain/payment/sepa_direct_debit_payment_method_specific_input.rb +60 -0
- data/lib/ingenico/connect/sdk/domain/payment/sepa_direct_debit_payment_method_specific_output.rb +36 -0
- data/lib/ingenico/connect/sdk/domain/payment/three_d_secure_results.rb +46 -0
- data/lib/ingenico/connect/sdk/domain/payment/tokenize_payment_request.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/payout/approve_payout_request.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/payout/create_payout_request.rb +101 -0
- data/lib/ingenico/connect/sdk/domain/payout/payout_customer.rb +76 -0
- data/lib/ingenico/connect/sdk/domain/payout/payout_error_response.rb +57 -0
- data/lib/ingenico/connect/sdk/domain/payout/payout_references.rb +46 -0
- data/lib/ingenico/connect/sdk/domain/payout/payout_response.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/payout/payout_result.rb +54 -0
- data/lib/ingenico/connect/sdk/domain/product/account_on_file.rb +64 -0
- data/lib/ingenico/connect/sdk/domain/product/account_on_file_attribute.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/product/account_on_file_display_hints.rb +46 -0
- data/lib/ingenico/connect/sdk/domain/product/directory.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/product/directory_entry.rb +59 -0
- data/lib/ingenico/connect/sdk/domain/product/empty_validator.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/product/fixed_list_validator.rb +38 -0
- data/lib/ingenico/connect/sdk/domain/product/label_template_element.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/product/length_validator.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/product/payment_product.rb +134 -0
- data/lib/ingenico/connect/sdk/domain/product/payment_product_display_hints.rb +46 -0
- data/lib/ingenico/connect/sdk/domain/product/payment_product_field.rb +61 -0
- data/lib/ingenico/connect/sdk/domain/product/payment_product_field_data_restrictions.rb +43 -0
- data/lib/ingenico/connect/sdk/domain/product/payment_product_field_display_hints.rb +96 -0
- data/lib/ingenico/connect/sdk/domain/product/payment_product_field_form_element.rb +46 -0
- data/lib/ingenico/connect/sdk/domain/product/payment_product_field_tooltip.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/product/payment_product_field_validators.rb +100 -0
- data/lib/ingenico/connect/sdk/domain/product/payment_product_group.rb +71 -0
- data/lib/ingenico/connect/sdk/domain/product/payment_product_group_response.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/product/payment_product_groups.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/product/payment_product_response.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/product/payment_products.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/product/range_validator.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/product/regular_expression_validator.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/product/value_mapping_element.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/refund/approve_refund_request.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/refund/bank_account_bban_refund.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/refund/bank_refund_method_specific_input.rb +54 -0
- data/lib/ingenico/connect/sdk/domain/refund/refund_customer.rb +58 -0
- data/lib/ingenico/connect/sdk/domain/refund/refund_error_response.rb +57 -0
- data/lib/ingenico/connect/sdk/domain/refund/refund_references.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/refund/refund_request.rb +76 -0
- data/lib/ingenico/connect/sdk/domain/refund/refund_response.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/refund/refund_result.rb +54 -0
- data/lib/ingenico/connect/sdk/domain/riskassessments/customer_risk_assessment.rb +65 -0
- data/lib/ingenico/connect/sdk/domain/riskassessments/order_risk_assessment.rb +58 -0
- data/lib/ingenico/connect/sdk/domain/riskassessments/personal_information_risk_assessment.rb +36 -0
- data/lib/ingenico/connect/sdk/domain/riskassessments/personal_name_risk_assessment.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/riskassessments/risk_assessment.rb +54 -0
- data/lib/ingenico/connect/sdk/domain/riskassessments/risk_assessment_bank_account.rb +47 -0
- data/lib/ingenico/connect/sdk/domain/riskassessments/risk_assessment_card.rb +36 -0
- data/lib/ingenico/connect/sdk/domain/riskassessments/risk_assessment_response.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/services/bank_data.rb +53 -0
- data/lib/ingenico/connect/sdk/domain/services/bank_details.rb +47 -0
- data/lib/ingenico/connect/sdk/domain/services/bank_details_request.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/services/bank_details_response.rb +69 -0
- data/lib/ingenico/connect/sdk/domain/services/convert_amount.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/services/get_iin_details_request.rb +43 -0
- data/lib/ingenico/connect/sdk/domain/services/get_iin_details_response.rb +60 -0
- data/lib/ingenico/connect/sdk/domain/services/iin_detail.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/services/payment_context.rb +50 -0
- data/lib/ingenico/connect/sdk/domain/services/swift.rb +95 -0
- data/lib/ingenico/connect/sdk/domain/services/test_connection.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/sessions/payment_product_filters_client_session.rb +46 -0
- data/lib/ingenico/connect/sdk/domain/sessions/session_request.rb +49 -0
- data/lib/ingenico/connect/sdk/domain/sessions/session_response.rb +59 -0
- data/lib/ingenico/connect/sdk/domain/token/abstract_token.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/token/approve_token_request.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/token/contact_details_token.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/token/create_token_request.rb +76 -0
- data/lib/ingenico/connect/sdk/domain/token/create_token_response.rb +39 -0
- data/lib/ingenico/connect/sdk/domain/token/creditor.rb +102 -0
- data/lib/ingenico/connect/sdk/domain/token/customer_token.rb +47 -0
- data/lib/ingenico/connect/sdk/domain/token/customer_token_with_contact_details.rb +36 -0
- data/lib/ingenico/connect/sdk/domain/token/debtor.rb +102 -0
- data/lib/ingenico/connect/sdk/domain/token/mandate_approval.rb +46 -0
- data/lib/ingenico/connect/sdk/domain/token/mandate_non_sepa_direct_debit.rb +36 -0
- data/lib/ingenico/connect/sdk/domain/token/mandate_sepa_direct_debit.rb +36 -0
- data/lib/ingenico/connect/sdk/domain/token/mandate_sepa_direct_debit_with_mandate_id.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/token/mandate_sepa_direct_debit_without_creditor.rb +79 -0
- data/lib/ingenico/connect/sdk/domain/token/personal_information_token.rb +36 -0
- data/lib/ingenico/connect/sdk/domain/token/personal_name_token.rb +16 -0
- data/lib/ingenico/connect/sdk/domain/token/token_card.rb +47 -0
- data/lib/ingenico/connect/sdk/domain/token/token_card_data.rb +50 -0
- data/lib/ingenico/connect/sdk/domain/token/token_e_wallet.rb +47 -0
- data/lib/ingenico/connect/sdk/domain/token/token_e_wallet_data.rb +32 -0
- data/lib/ingenico/connect/sdk/domain/token/token_non_sepa_direct_debit.rb +47 -0
- data/lib/ingenico/connect/sdk/domain/token/token_non_sepa_direct_debit_payment_product705_specific_data.rb +43 -0
- data/lib/ingenico/connect/sdk/domain/token/token_response.rb +83 -0
- data/lib/ingenico/connect/sdk/domain/token/token_sepa_direct_debit.rb +47 -0
- data/lib/ingenico/connect/sdk/domain/token/token_sepa_direct_debit_without_creditor.rb +47 -0
- data/lib/ingenico/connect/sdk/domain/token/update_token_request.rb +76 -0
- data/lib/ingenico/connect/sdk/endpoint_configuration.rb +139 -0
- data/lib/ingenico/connect/sdk/exceptions.rb +8 -0
- data/lib/ingenico/connect/sdk/factory.rb +200 -0
- data/lib/ingenico/connect/sdk/global_collect_exception.rb +15 -0
- data/lib/ingenico/connect/sdk/idempotence_exception.rb +24 -0
- data/lib/ingenico/connect/sdk/logging.rb +10 -0
- data/lib/ingenico/connect/sdk/logging/communicator_logger.rb +19 -0
- data/lib/ingenico/connect/sdk/logging/log_message_builder.rb +61 -0
- data/lib/ingenico/connect/sdk/logging/logging_capable.rb +19 -0
- data/lib/ingenico/connect/sdk/logging/logging_util.rb +298 -0
- data/lib/ingenico/connect/sdk/logging/request_log_message_builder.rb +42 -0
- data/lib/ingenico/connect/sdk/logging/response_log_message_builder.rb +34 -0
- data/lib/ingenico/connect/sdk/logging/ruby_communicator_logger.rb +58 -0
- data/lib/ingenico/connect/sdk/logging/stdout_communicator_logger.rb +36 -0
- data/lib/ingenico/connect/sdk/marshaller.rb +19 -0
- data/lib/ingenico/connect/sdk/marshaller_syntax_exception.rb +6 -0
- data/lib/ingenico/connect/sdk/merchant/hostedcheckouts/hostedcheckouts_client.rb +88 -0
- data/lib/ingenico/connect/sdk/merchant/merchant_client.rb +110 -0
- data/lib/ingenico/connect/sdk/merchant/payments/payments_client.rb +319 -0
- data/lib/ingenico/connect/sdk/merchant/payouts/payouts_client.rb +197 -0
- data/lib/ingenico/connect/sdk/merchant/productgroups/find_productgroups_params.rb +55 -0
- data/lib/ingenico/connect/sdk/merchant/productgroups/get_productgroup_params.rb +55 -0
- data/lib/ingenico/connect/sdk/merchant/productgroups/productgroups_client.rb +90 -0
- data/lib/ingenico/connect/sdk/merchant/products/directory_params.rb +31 -0
- data/lib/ingenico/connect/sdk/merchant/products/find_products_params.rb +55 -0
- data/lib/ingenico/connect/sdk/merchant/products/get_product_params.rb +55 -0
- data/lib/ingenico/connect/sdk/merchant/products/products_client.rb +124 -0
- data/lib/ingenico/connect/sdk/merchant/refunds/refunds_client.rb +154 -0
- data/lib/ingenico/connect/sdk/merchant/riskassessments/riskassessments_client.rb +85 -0
- data/lib/ingenico/connect/sdk/merchant/services/convert_amount_params.rb +35 -0
- data/lib/ingenico/connect/sdk/merchant/services/services_client.rb +149 -0
- data/lib/ingenico/connect/sdk/merchant/sessions/sessions_client.rb +55 -0
- data/lib/ingenico/connect/sdk/merchant/tokens/delete_token_params.rb +27 -0
- data/lib/ingenico/connect/sdk/merchant/tokens/tokens_client.rb +192 -0
- data/lib/ingenico/connect/sdk/meta_data_provider.rb +152 -0
- data/lib/ingenico/connect/sdk/modules.rb +130 -0
- data/lib/ingenico/connect/sdk/not_found_exception.rb +19 -0
- data/lib/ingenico/connect/sdk/param_request.rb +33 -0
- data/lib/ingenico/connect/sdk/pooled_connection.rb +21 -0
- data/lib/ingenico/connect/sdk/proxy_configuration.rb +75 -0
- data/lib/ingenico/connect/sdk/reference_exception.rb +14 -0
- data/lib/ingenico/connect/sdk/request_header.rb +25 -0
- data/lib/ingenico/connect/sdk/request_param.rb +24 -0
- data/lib/ingenico/connect/sdk/response.rb +62 -0
- data/lib/ingenico/connect/sdk/response_exception.rb +54 -0
- data/lib/ingenico/connect/sdk/response_header.rb +25 -0
- data/lib/ingenico/connect/sdk/session.rb +39 -0
- data/lib/ingenico/connect/sdk/validation_exception.rb +14 -0
- data/spec/comparable_extension.rb +29 -0
- data/spec/fixtures/resources/defaultimpl/convertAmount.json +3 -0
- data/spec/fixtures/resources/defaultimpl/createPayment.failure.invalidCardNumber.json +11 -0
- data/spec/fixtures/resources/defaultimpl/createPayment.failure.rejected.json +48 -0
- data/spec/fixtures/resources/defaultimpl/createPayment.json +40 -0
- data/spec/fixtures/resources/defaultimpl/idempotence_duplicate_failure.json +8 -0
- data/spec/fixtures/resources/defaultimpl/idempotence_rejected.json +46 -0
- data/spec/fixtures/resources/defaultimpl/idempotence_success.json +39 -0
- data/spec/fixtures/resources/defaultimpl/notFound.html +1 -0
- data/spec/fixtures/resources/defaultimpl/testConnection.json +3 -0
- data/spec/fixtures/resources/defaultimpl/unknownServerError.json +10 -0
- data/spec/fixtures/resources/logging/bodyNoObfuscation.json +17 -0
- data/spec/fixtures/resources/logging/bodyWithBinObfuscated.json +3 -0
- data/spec/fixtures/resources/logging/bodyWithBinOriginal.json +3 -0
- data/spec/fixtures/resources/logging/bodyWithCardObfuscated.json +21 -0
- data/spec/fixtures/resources/logging/bodyWithCardOriginal.json +21 -0
- data/spec/fixtures/resources/logging/bodyWithIbanObfuscated.json +19 -0
- data/spec/fixtures/resources/logging/bodyWithIbanOriginal.json +19 -0
- data/spec/fixtures/resources/payment/duplicate_request.json +8 -0
- data/spec/fixtures/resources/payment/invalid_authorization.json +9 -0
- data/spec/fixtures/resources/payment/invalid_request.json +11 -0
- data/spec/fixtures/resources/payment/method_not_allowed.html +1 -0
- data/spec/fixtures/resources/payment/not_found.html +1 -0
- data/spec/fixtures/resources/payment/pending_approval.json +39 -0
- data/spec/fixtures/resources/payment/rejected.json +46 -0
- data/spec/fixtures/resources/properties.proxy.yml +13 -0
- data/spec/fixtures/resources/properties.yml +7 -0
- data/spec/integration/connection_pooling_spec.rb +78 -0
- data/spec/integration/convert_amount_spec.rb +25 -0
- data/spec/integration/idempotence_spec.rb +59 -0
- data/spec/integration/multiline_header_spec.rb +30 -0
- data/spec/integration/payment_product_groups_spec.rb +23 -0
- data/spec/integration/payment_products_spec.rb +22 -0
- data/spec/integration/risk_assessments_spec.rb +37 -0
- data/spec/integration/sdk_proxy_spec.rb +89 -0
- data/spec/integration/token_spec.rb +42 -0
- data/spec/integration_setup.rb +50 -0
- data/spec/lib/client_spec.rb +69 -0
- data/spec/lib/communicator_configuration_spec.rb +179 -0
- data/spec/lib/communicator_spec.rb +31 -0
- data/spec/lib/defaultimpl/default_authenticator_spec.rb +74 -0
- data/spec/lib/defaultimpl/default_connection_idempotence_spec.rb +142 -0
- data/spec/lib/defaultimpl/default_connection_logger_spec.rb +526 -0
- data/spec/lib/defaultimpl/default_connection_spec.rb +334 -0
- data/spec/lib/defaultimpl/default_marshaller_spec.rb +36 -0
- data/spec/lib/factory_spec.rb +41 -0
- data/spec/lib/logging/header_obfuscator_spec.rb +51 -0
- data/spec/lib/logging/logging_util_spec.rb +143 -0
- data/spec/lib/logging/obfuscator_spec.rb +52 -0
- data/spec/lib/logging/ruby_communicator_logger_spec.rb +84 -0
- data/spec/lib/logging/stdout_communicator_logger_spec.rb +64 -0
- data/spec/lib/logging/value_obfuscator_spec.rb +95 -0
- data/spec/lib/meta_data_provider_spec.rb +71 -0
- data/spec/lib/payments_client_spec.rb +157 -0
- data/spec/lib/requestparams/delete_params_spec.rb +21 -0
- data/spec/lib/requestparams/directory_params_spec.rb +27 -0
- data/spec/lib/requestparams/find_params_spec.rb +58 -0
- data/spec/lib/requestparams/get_params_spec.rb +59 -0
- data/spec/lib/requestparams/param_request_spec.rb +57 -0
- data/spec/spec_helper.rb +23 -0
- metadata +565 -0
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'integration_setup'
|
3
|
+
require 'webmock/rspec'
|
4
|
+
require 'ingenico/connect/sdk/domain/definitions/address'
|
5
|
+
require 'ingenico/connect/sdk/domain/definitions/card_without_cvv'
|
6
|
+
require 'ingenico/connect/sdk/domain/token/create_token_request'
|
7
|
+
require 'ingenico/connect/sdk/domain/token/customer_token'
|
8
|
+
require 'ingenico/connect/sdk/domain/token/token_card'
|
9
|
+
require 'ingenico/connect/sdk/domain/token/token_card_data'
|
10
|
+
require 'ingenico/connect/sdk/merchant/tokens/delete_token_params'
|
11
|
+
|
12
|
+
describe 'token' do
|
13
|
+
|
14
|
+
before(:context){WebMock.allow_net_connect!}
|
15
|
+
after(:context){WebMock.disable_net_connect!}
|
16
|
+
|
17
|
+
it 'can be created and deleted' do
|
18
|
+
billing_address = Ingenico::Connect::SDK::Domain::Definitions::Address.new
|
19
|
+
billing_address.country_code = 'NL'
|
20
|
+
customer = Ingenico::Connect::SDK::Domain::Token::CustomerToken.new
|
21
|
+
customer.billing_address = billing_address
|
22
|
+
card_without_ccv = Ingenico::Connect::SDK::Domain::Definitions::CardWithoutCvv.new
|
23
|
+
card_without_ccv.cardholder_name = 'Jan'
|
24
|
+
card_without_ccv.issue_number = '12'
|
25
|
+
card_without_ccv.card_number = '4567350000427977'
|
26
|
+
card_without_ccv.expiry_date = '0820'
|
27
|
+
card_data = Ingenico::Connect::SDK::Domain::Token::TokenCardData.new
|
28
|
+
card_data.card_without_cvv = card_without_ccv
|
29
|
+
card = Ingenico::Connect::SDK::Domain::Token::TokenCard.new
|
30
|
+
card.customer = customer
|
31
|
+
card.data = card_data
|
32
|
+
create_token_request = Ingenico::Connect::SDK::Domain::Token::CreateTokenRequest.new
|
33
|
+
create_token_request.payment_product_id = 1
|
34
|
+
create_token_request.card = card
|
35
|
+
|
36
|
+
Integration.init_client(false) do |client|
|
37
|
+
token_response = client.merchant(Integration::MERCHANT_ID).tokens.create(create_token_request)
|
38
|
+
expect(token_response.token).to_not be_nil
|
39
|
+
client.merchant(Integration::MERCHANT_ID).tokens.delete(token_response.token, Ingenico::Connect::SDK::Merchant::Tokens::DeleteTokenParams.new)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
module Integration
|
5
|
+
MERCHANT_ID = ENV['connect.api.merchantId']
|
6
|
+
API_KEY_ID = ENV['connect.api.apiKeyId']
|
7
|
+
SECRET_API_KEY = ENV['connect.api.secretApiKey']
|
8
|
+
raise 'could not access environment variable connect.api.merchantId required for testing' unless MERCHANT_ID
|
9
|
+
raise 'could not access environment variable connect.api.apiKeyId required for testing' unless API_KEY_ID
|
10
|
+
raise 'could not access environment variable connect.api.secretApiKey required for testing' unless SECRET_API_KEY
|
11
|
+
PROPERTIES_URI = File.absolute_path(File.join(__FILE__, '../fixtures/resources/properties.yml'))
|
12
|
+
PROPERTIES_URI_PROXY = File.absolute_path(File.join(__FILE__, '../fixtures/resources/properties.proxy.yml'))
|
13
|
+
|
14
|
+
def self.create_uri(scheme, host, port)
|
15
|
+
if port == -1
|
16
|
+
"#{scheme}://#{host}"
|
17
|
+
else
|
18
|
+
"#{scheme}://#{host}:#{port.to_s}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.init_communicator_configuration(properties_url: PROPERTIES_URI, max_connections: nil)
|
23
|
+
yaml = YAML.load_file(properties_url)
|
24
|
+
configuration = Ingenico::Connect::SDK::CommunicatorConfiguration.new(properties: yaml,
|
25
|
+
api_endpoint: 'https://api-sandbox.globalcollect.com',
|
26
|
+
authorization_type: 'v1HMAC',
|
27
|
+
api_key_id: API_KEY_ID,
|
28
|
+
secret_api_key: SECRET_API_KEY,
|
29
|
+
max_connections: max_connections)
|
30
|
+
host = ENV['connect.api.endpoint.host']
|
31
|
+
if host
|
32
|
+
scheme = ENV.fetch('connect.api.endpoint.scheme', 'https')
|
33
|
+
port = ENV.fetch('connect.api.endpoint.port', -1)
|
34
|
+
configuration.api_endpoint = create_uri(scheme, host, port)
|
35
|
+
end
|
36
|
+
configuration
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.init_client(with_proxy, max_connections = nil)
|
40
|
+
if with_proxy
|
41
|
+
url = PROPERTIES_URI_PROXY
|
42
|
+
else
|
43
|
+
url = PROPERTIES_URI
|
44
|
+
end
|
45
|
+
yaml = YAML.load_file(url)
|
46
|
+
configuration = init_communicator_configuration(properties_url: url, max_connections: max_connections)
|
47
|
+
yield client = Ingenico::Connect::SDK::Factory.create_client_from_configuration(configuration).with_client_meta_info('{"test":"test"}')
|
48
|
+
client.close
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Client' do
|
4
|
+
Factory ||= Ingenico::Connect::SDK::Factory
|
5
|
+
Connection ||= Ingenico::Connect::SDK::Connection
|
6
|
+
PooledConnection ||= Ingenico::Connect::SDK::PooledConnection
|
7
|
+
|
8
|
+
it 'should return properly modified clients from *with_client_meta_info*' do
|
9
|
+
client1 = Factory.create_client_from_file(PROPERTIES_URI, API_KEY_ID, SECRET_API_KEY)
|
10
|
+
client2 = client1.with_client_meta_info(nil)
|
11
|
+
client_meta_info = Ingenico::Connect::SDK::DefaultImpl::DefaultMarshaller.INSTANCE.marshal({test: 'test'})
|
12
|
+
client3 = client1.with_client_meta_info(client_meta_info)
|
13
|
+
client4 = client3.with_client_meta_info(client_meta_info)
|
14
|
+
client5 = client3.with_client_meta_info(nil)
|
15
|
+
|
16
|
+
|
17
|
+
expect(client1.instance_variable_get(:@client_headers)).to be_nil
|
18
|
+
expect(client1).to be(client2)
|
19
|
+
expect(client1).to_not be(client3)
|
20
|
+
# Check if client3 has the meta_info stored
|
21
|
+
client3_info = client3.instance_variable_get(:@client_meta_info)
|
22
|
+
meta_info_encoded = Base64.strict_encode64(client_meta_info.encode('utf-8'))
|
23
|
+
expect(client3_info).to eq(meta_info_encoded)
|
24
|
+
|
25
|
+
expect(client3).to be(client4)
|
26
|
+
expect(client3).to_not be(client5)
|
27
|
+
expect(client5.instance_variable_get(:@client_headers)).to be_nil
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should not close idle connections of an unpooled connection' do
|
31
|
+
conn = Connection.allocate # Create fake (uninitialized) connection
|
32
|
+
session = Factory.create_session_from_file(PROPERTIES_URI, API_KEY_ID, SECRET_API_KEY, connection: conn)
|
33
|
+
client = Factory.create_client_from_session(session)
|
34
|
+
|
35
|
+
expect(session.connection).to_not receive(:close_idle_connections)
|
36
|
+
|
37
|
+
client.close_idle_connections(0.500)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should close idle connections of a pooled connection' do
|
41
|
+
conn = PooledConnection.allocate # Create fake (uninitialized) connection
|
42
|
+
session = Factory.create_session_from_file(PROPERTIES_URI, API_KEY_ID, SECRET_API_KEY, connection: conn)
|
43
|
+
client = Factory.create_client_from_session(session)
|
44
|
+
|
45
|
+
expect(session.connection).to receive(:close_idle_connections).with(0.500)
|
46
|
+
|
47
|
+
client.close_idle_connections(0.500)
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should not close expired connections of an unpooled connection' do
|
51
|
+
conn = Connection.allocate # Create fake (uninitialized) connection
|
52
|
+
session = Factory.create_session_from_file(PROPERTIES_URI, API_KEY_ID, SECRET_API_KEY, connection: conn)
|
53
|
+
client = Factory.create_client_from_session(session)
|
54
|
+
|
55
|
+
expect(session.connection).to_not receive(:close_expired_connections)
|
56
|
+
|
57
|
+
client.close_expired_connections
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'should close expired connections of a pooled connection' do
|
61
|
+
conn = PooledConnection.allocate # Create fake (uninitialized) connection
|
62
|
+
session = Factory.create_session_from_file(PROPERTIES_URI, API_KEY_ID, SECRET_API_KEY, connection: conn)
|
63
|
+
client = Factory.create_client_from_session(session)
|
64
|
+
|
65
|
+
expect(session.connection).to receive(:close_expired_connections)
|
66
|
+
|
67
|
+
client.close_expired_connections
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,179 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
CommunicatorConfiguration ||= Ingenico::Connect::SDK::CommunicatorConfiguration
|
5
|
+
|
6
|
+
describe 'CommunicatorConfiguration' do
|
7
|
+
|
8
|
+
it 'can be constructed without a proxy' do
|
9
|
+
yaml = '---
|
10
|
+
connect.api.endpoint.host: api-sandbox.globalcollect.com
|
11
|
+
connect.api.authorizationType: v1HMAC
|
12
|
+
connect.api.connectTimeout: 20
|
13
|
+
connect.api.socketTimeout: 10'
|
14
|
+
config = YAML.load(yaml)
|
15
|
+
|
16
|
+
communicator_config = CommunicatorConfiguration.new(properties: config)
|
17
|
+
|
18
|
+
expect(communicator_config.api_endpoint).to eq('https://api-sandbox.globalcollect.com')
|
19
|
+
expect(communicator_config.authorization_type).to eq('v1HMAC')
|
20
|
+
expect(communicator_config.connect_timeout).to eq(20)
|
21
|
+
expect(communicator_config.socket_timeout).to eq(10)
|
22
|
+
|
23
|
+
expect(communicator_config.api_key_id).to be_nil
|
24
|
+
expect(communicator_config.secret_api_key).to be_nil
|
25
|
+
expect(communicator_config.proxy_configuration).to be_nil
|
26
|
+
expect(communicator_config.integrator).to be_nil
|
27
|
+
expect(communicator_config.shopping_cart_extension).to be_nil
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'can be constructed with a proxy, without authentication' do
|
31
|
+
yaml = '---
|
32
|
+
connect.api.endpoint.host: api-sandbox.globalcollect.com
|
33
|
+
connect.api.authorizationType: v1HMAC
|
34
|
+
connect.api.connectTimeout: 20
|
35
|
+
connect.api.socketTimeout: 10
|
36
|
+
connect.api.proxy.uri: http://proxy.example.org:3128'
|
37
|
+
config = YAML.load(yaml)
|
38
|
+
|
39
|
+
communicator_config = CommunicatorConfiguration.new(properties: config)
|
40
|
+
proxy_config = communicator_config.proxy_configuration
|
41
|
+
|
42
|
+
expect(communicator_config.api_endpoint).to eq('https://api-sandbox.globalcollect.com')
|
43
|
+
expect(communicator_config.authorization_type).to eq('v1HMAC')
|
44
|
+
expect(communicator_config.connect_timeout).to eq(20)
|
45
|
+
expect(communicator_config.socket_timeout).to eq(10)
|
46
|
+
|
47
|
+
expect(communicator_config.api_key_id).to be_nil
|
48
|
+
expect(communicator_config.secret_api_key).to be_nil
|
49
|
+
expect(proxy_config).to be_truthy
|
50
|
+
expect(proxy_config.scheme).to eq('http')
|
51
|
+
expect(proxy_config.host).to eq('proxy.example.org')
|
52
|
+
expect(proxy_config.port).to eq(3128)
|
53
|
+
expect(proxy_config.username).to be_nil
|
54
|
+
expect(proxy_config.password).to be_nil
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'can be constructed to authenticate to a proxy' do
|
58
|
+
yaml = '---
|
59
|
+
connect.api.endpoint.host: api-sandbox.globalcollect.com
|
60
|
+
connect.api.authorizationType: v1HMAC
|
61
|
+
connect.api.connectTimeout: 20
|
62
|
+
connect.api.socketTimeout: 10
|
63
|
+
connect.api.proxy.uri: http://proxy.example.org:3128
|
64
|
+
connect.api.proxy.username: global-collect-username
|
65
|
+
connect.api.proxy.password: global-collect-password'
|
66
|
+
config = YAML.load(yaml)
|
67
|
+
|
68
|
+
communicator_config = CommunicatorConfiguration.new(properties: config)
|
69
|
+
proxy_config = communicator_config.proxy_configuration
|
70
|
+
|
71
|
+
expect(communicator_config.api_endpoint).to eq('https://api-sandbox.globalcollect.com')
|
72
|
+
expect(communicator_config.authorization_type).to eq('v1HMAC')
|
73
|
+
expect(communicator_config.connect_timeout).to eq(20)
|
74
|
+
expect(communicator_config.socket_timeout).to eq(10)
|
75
|
+
|
76
|
+
expect(communicator_config.api_key_id).to be_nil
|
77
|
+
expect(communicator_config.secret_api_key).to be_nil
|
78
|
+
expect(proxy_config).to be_truthy
|
79
|
+
expect(proxy_config.scheme).to eq('http')
|
80
|
+
expect(proxy_config.host).to eq('proxy.example.org')
|
81
|
+
expect(proxy_config.port).to eq(3128)
|
82
|
+
expect(proxy_config.username).to eq('global-collect-username')
|
83
|
+
expect(proxy_config.password).to eq('global-collect-password')
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'accepts a different number of maximum connections' do
|
87
|
+
yaml = '---
|
88
|
+
connect.api.endpoint.host: api-sandbox.globalcollect.com
|
89
|
+
connect.api.authorizationType: v1HMAC
|
90
|
+
connect.api.connectTimeout: 20
|
91
|
+
connect.api.socketTimeout: 10
|
92
|
+
connect.api.maxConnections: 100'
|
93
|
+
config = YAML.load(yaml)
|
94
|
+
|
95
|
+
communicator_config = CommunicatorConfiguration.new(properties: config)
|
96
|
+
|
97
|
+
expect(communicator_config.api_endpoint).to eq('https://api-sandbox.globalcollect.com')
|
98
|
+
expect(communicator_config.authorization_type).to eq('v1HMAC')
|
99
|
+
expect(communicator_config.connect_timeout).to eq(20)
|
100
|
+
expect(communicator_config.socket_timeout).to eq(10)
|
101
|
+
expect(communicator_config.max_connections).to eq(100)
|
102
|
+
|
103
|
+
expect(communicator_config.api_key_id).to be_nil
|
104
|
+
expect(communicator_config.secret_api_key).to be_nil
|
105
|
+
expect(communicator_config.proxy_configuration).to be_nil
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'uses specific scheme to override default' do
|
109
|
+
yaml = '---
|
110
|
+
connect.api.endpoint.host: api-sandbox.globalcollect.com
|
111
|
+
connect.api.authorizationType: v1HMAC
|
112
|
+
connect.api.connectTimeout: 20
|
113
|
+
connect.api.socketTimeout: 10
|
114
|
+
connect.api.endpoint.scheme: http'
|
115
|
+
config = YAML.load(yaml)
|
116
|
+
|
117
|
+
communicator_config = CommunicatorConfiguration.new(properties: config)
|
118
|
+
|
119
|
+
expect(communicator_config.api_endpoint).to eq('http://api-sandbox.globalcollect.com')
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'uses specific port to override default' do
|
123
|
+
yaml = '---
|
124
|
+
connect.api.endpoint.host: api-sandbox.globalcollect.com
|
125
|
+
connect.api.authorizationType: v1HMAC
|
126
|
+
connect.api.connectTimeout: 20
|
127
|
+
connect.api.socketTimeout: 10
|
128
|
+
connect.api.endpoint.port: 8080'
|
129
|
+
config = YAML.load(yaml)
|
130
|
+
|
131
|
+
communicator_config = CommunicatorConfiguration.new(properties: config)
|
132
|
+
|
133
|
+
expect(communicator_config.api_endpoint).to eq('https://api-sandbox.globalcollect.com:8080')
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'uses specific scheme and port to override default' do
|
137
|
+
yaml = '---
|
138
|
+
connect.api.endpoint.host: api-sandbox.globalcollect.com
|
139
|
+
connect.api.authorizationType: v1HMAC
|
140
|
+
connect.api.connectTimeout: 20
|
141
|
+
connect.api.socketTimeout: 10
|
142
|
+
connect.api.endpoint.scheme: http
|
143
|
+
connect.api.endpoint.port: 8080'
|
144
|
+
config = YAML.load(yaml)
|
145
|
+
|
146
|
+
communicator_config = CommunicatorConfiguration.new(properties: config)
|
147
|
+
|
148
|
+
expect(communicator_config.api_endpoint).to eq('http://api-sandbox.globalcollect.com:8080')
|
149
|
+
end
|
150
|
+
|
151
|
+
it 'stores shoppingCartExtension data' do
|
152
|
+
yaml = '---
|
153
|
+
connect.api.endpoint.host: api-sandbox.globalcollect.com
|
154
|
+
connect.api.authorizationType: v1HMAC
|
155
|
+
connect.api.connectTimeout: 20
|
156
|
+
connect.api.socketTimeout: 10
|
157
|
+
connect.api.integrator: Ingenico.Integrator
|
158
|
+
connect.api.shoppingCartExtension.creator: Ingenico.Creator
|
159
|
+
connect.api.shoppingCartExtension.name: Ingenico.ShoppingCarts
|
160
|
+
connect.api.shoppingCartExtension.version: 1.0'
|
161
|
+
config = YAML.load(yaml)
|
162
|
+
|
163
|
+
communicator_config = CommunicatorConfiguration.new(properties: config)
|
164
|
+
|
165
|
+
expect(communicator_config.api_endpoint).to eq('https://api-sandbox.globalcollect.com')
|
166
|
+
expect(communicator_config.authorization_type).to eq('v1HMAC')
|
167
|
+
expect(communicator_config.connect_timeout).to eq(20)
|
168
|
+
expect(communicator_config.socket_timeout).to eq(10)
|
169
|
+
|
170
|
+
expect(communicator_config.api_key_id).to be_nil
|
171
|
+
expect(communicator_config.secret_api_key).to be_nil
|
172
|
+
expect(communicator_config.proxy_configuration).to be_nil
|
173
|
+
expect(communicator_config.integrator).to eq('Ingenico.Integrator')
|
174
|
+
expect(communicator_config.shopping_cart_extension).to be_truthy
|
175
|
+
expect(communicator_config.shopping_cart_extension.creator).to eq('Ingenico.Creator')
|
176
|
+
expect(communicator_config.shopping_cart_extension.name).to eq('Ingenico.ShoppingCarts')
|
177
|
+
expect(communicator_config.shopping_cart_extension.version).to eq('1.0')
|
178
|
+
end
|
179
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'uri'
|
3
|
+
|
4
|
+
Communicator ||= Ingenico::Connect::SDK::Communicator
|
5
|
+
DefaultMarshaller ||= Ingenico::Connect::SDK::DefaultImpl::DefaultMarshaller
|
6
|
+
RequestParam ||= Ingenico::Connect::SDK::RequestParam
|
7
|
+
|
8
|
+
describe Communicator do
|
9
|
+
|
10
|
+
let(:session){instance_double('Session', :api_endpoint => URI('https://api-sandbox.globalcollect.com'))}
|
11
|
+
let(:communicator){communicator = Communicator.new(session, DefaultMarshaller.INSTANCE)}
|
12
|
+
context 'to_absolute_uri()' do
|
13
|
+
it 'accepts a uri with or without a leading slash' do
|
14
|
+
uri1 = communicator.send(:to_absolute_uri, 'v1/merchant/20000/convertamount', [])
|
15
|
+
uri2 = communicator.send(:to_absolute_uri, '/v1/merchant/20000/convertamount', [])
|
16
|
+
# Ruby URI library adds port in HTTPS url's by default
|
17
|
+
expect(uri1.to_s).to eq('https://api-sandbox.globalcollect.com:443/v1/merchant/20000/convertamount')
|
18
|
+
expect(uri2.to_s).to eq('https://api-sandbox.globalcollect.com:443/v1/merchant/20000/convertamount')
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'adds request parameters to the uri' do
|
22
|
+
request_params = [RequestParam.new('amount', '123'), RequestParam.new('source', 'USD'),
|
23
|
+
RequestParam.new('target', 'EUR'), RequestParam.new('dummy', 'é&%=')]
|
24
|
+
|
25
|
+
uri = communicator.send(:to_absolute_uri, 'v1/merchant/20000/convertamount', request_params)
|
26
|
+
|
27
|
+
expect(uri.to_s).to eq('https://api-sandbox.globalcollect.com:443/v1/merchant/20000/convertamount'\
|
28
|
+
'?amount=123&source=USD&target=EUR&dummy=%C3%A9%26%25%3D')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe 'DefaultAuthenticator' do
|
5
|
+
RequestHeader ||= Ingenico::Connect::SDK::RequestHeader
|
6
|
+
|
7
|
+
let(:authenticator) {Ingenico::Connect::SDK::DefaultImpl::DefaultAuthenticator.new(
|
8
|
+
Ingenico::Connect::SDK::DefaultImpl::AuthorizationType.get_authorization('v1HMAC'), 'apiKeyId', 'secretApiKey')}
|
9
|
+
|
10
|
+
it 'should canonicalize headers' do
|
11
|
+
expect(authenticator.send(:to_canonical_header_value, "aap\nnoot ")).to eq('aap noot')
|
12
|
+
expect(authenticator.send(:to_canonical_header_value, " aap\r\n noot")).to eq('aap noot')
|
13
|
+
end
|
14
|
+
|
15
|
+
# Tests if a request can be converted to a canonical format to sign
|
16
|
+
it 'converts a request properly to signable data' do
|
17
|
+
http_headers = [RequestHeader.new('X-GCS-ServerMetaInfo',
|
18
|
+
'{"platformIdentifier":"Windows 7/6.1 Java/1.7 (Oracle Corporation; '+
|
19
|
+
'Java HotSpot(TM) 64-Bit Server VM; 1.7.0_45)","sdkIdentifier":"1.0"}'),
|
20
|
+
RequestHeader.new('Content-Type', 'application/json'),
|
21
|
+
RequestHeader.new('X-GCS-ClientMetaInfo', '{"aap","noot"}'),
|
22
|
+
RequestHeader.new('User-Agent', 'Apache-HttpClient/4.3.4 (java 1.5)'),
|
23
|
+
RequestHeader.new('Date', 'Mon, 07 Jul 2014 12:12:40 GMT')]
|
24
|
+
|
25
|
+
expected_start = "POST\n"+
|
26
|
+
"application/json\n"
|
27
|
+
expected_end = %Q(x-gcs-clientmetainfo:{"aap","noot"}\n) +
|
28
|
+
%Q(x-gcs-servermetainfo:{"platformIdentifier":"Windows 7/6.1 Java/1.7 )+
|
29
|
+
%Q((Oracle Corporation; Java HotSpot(TM) 64-Bit Server VM; 1.7.0_45)",)+
|
30
|
+
%Q("sdkIdentifier":"1.0"}\n)+
|
31
|
+
%Q(/v1/9991/services%20bla/convert/amount?aap=noot&mies=geen%20noot\n)
|
32
|
+
|
33
|
+
data_to_sign = authenticator.send(:to_data_to_sign, 'POST',
|
34
|
+
URI('http://localhost:8080/v1/9991/services%20bla/convert/amount?aap=noot&mies=geen%20noot'),
|
35
|
+
http_headers)
|
36
|
+
|
37
|
+
# NOTE: Ruby has two types of range about end point:
|
38
|
+
# 1) inclusive: 0..1 => 0, 1
|
39
|
+
# 2) exclusive: 0...1 => 0
|
40
|
+
actual_start = data_to_sign[0...22]
|
41
|
+
actual_end = data_to_sign[52..-1]
|
42
|
+
expect(actual_start).to eq(expected_start)
|
43
|
+
expect(actual_end).to eq(expected_end)
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'create_authentication_signature' do
|
47
|
+
it 'creates authentication signatures' do
|
48
|
+
data_to_sign = "DELETE\n"+
|
49
|
+
"application/json\n"+
|
50
|
+
"Fri, 06 Jun 2014 13:39:43 GMT\n"+
|
51
|
+
"x-gcs-clientmetainfo:processed header value\n"+
|
52
|
+
"x-gcs-customerheader:processed header value\n"+
|
53
|
+
"x-gcs-servermetainfo:processed header value\n"+
|
54
|
+
"/v1/9991/tokens/123456789\n"
|
55
|
+
|
56
|
+
authentication_signature = authenticator.send(:create_auth_signature, data_to_sign)
|
57
|
+
|
58
|
+
expect(authentication_signature).to eq('VfnXpPBQQoHZivTcAg0JvOWkhnzlPnaCPKpTQn/uMJM=')
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'creates authentication signatures for more than one key' do
|
62
|
+
authenticator = Ingenico::Connect::SDK::DefaultImpl::DefaultAuthenticator.new(
|
63
|
+
Ingenico::Connect::SDK::DefaultImpl::AuthorizationType.get_authorization('v1HMAC'), 'apiKeyId', '6Kj5HT0MQKC6D8eb7W3lTg71kVKVDSt1')
|
64
|
+
data_to_sign = "GET\n"+
|
65
|
+
"\n"+
|
66
|
+
"Fri, 06 Jun 2014 13:39:43 GMT\n"+
|
67
|
+
"/v1/9991/tokens/123456789\n"
|
68
|
+
|
69
|
+
authentication_signature = authenticator.send(:create_auth_signature, data_to_sign)
|
70
|
+
|
71
|
+
expect(authentication_signature).to eq('9ond5EIN05dBXJGCLRK5om9pxHsyrh/12pZJ7bvmwNM=')
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|