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,334 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'uri'
|
3
|
+
require 'sinatra'
|
4
|
+
|
5
|
+
DefaultConnection ||= Ingenico::Connect::SDK::DefaultImpl::DefaultConnection
|
6
|
+
StdoutCommunicatorLogger ||= Ingenico::Connect::SDK::Logging::StdoutCommunicatorLogger
|
7
|
+
|
8
|
+
describe DefaultConnection do
|
9
|
+
let(:connect_timeout) { 10 }
|
10
|
+
let(:socket_timeout) { 10 }
|
11
|
+
let(:max_connections) { 10 }
|
12
|
+
let(:proxy_configuration) { nil }
|
13
|
+
subject(:connection) do
|
14
|
+
described_class.new(connect_timeout: connect_timeout,
|
15
|
+
socket_timeout: socket_timeout,
|
16
|
+
max_connections: max_connections,
|
17
|
+
proxy_configuration: proxy_configuration)
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'construction' do
|
21
|
+
context 'without proxy' do
|
22
|
+
let(:proxy_configuration) { nil }
|
23
|
+
let(:max_connections) { nil }
|
24
|
+
|
25
|
+
it 'has the correct timeout values' do
|
26
|
+
expect(
|
27
|
+
connection.instance_variable_get(:@connect_timeout)
|
28
|
+
).to eq(connect_timeout)
|
29
|
+
|
30
|
+
expect(
|
31
|
+
connection.instance_variable_get(:@socket_timeout)
|
32
|
+
).to eq(socket_timeout)
|
33
|
+
|
34
|
+
expect(
|
35
|
+
connection.instance_variable_get(:@proxy_configuration)
|
36
|
+
).to be_nil
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'with proxy' do
|
41
|
+
let(:uri) { URI('http://test-proxy') }
|
42
|
+
|
43
|
+
context 'without authentication' do
|
44
|
+
let(:proxy_configuration) { Ingenico::Connect::SDK::ProxyConfiguration.new(address: uri) }
|
45
|
+
|
46
|
+
it 'has the correct timeout values and proxy settings' do
|
47
|
+
expect(
|
48
|
+
connection.instance_variable_get(:@connect_timeout)
|
49
|
+
).to eq(connect_timeout)
|
50
|
+
|
51
|
+
expect(
|
52
|
+
connection.instance_variable_get(:@socket_timeout)
|
53
|
+
).to eq(socket_timeout)
|
54
|
+
|
55
|
+
expect(
|
56
|
+
connection.instance_variable_get(:@proxy_configuration).host
|
57
|
+
).to eq('test-proxy')
|
58
|
+
|
59
|
+
expect(
|
60
|
+
connection.instance_variable_get(:@proxy_configuration).port
|
61
|
+
).to eq(80)
|
62
|
+
|
63
|
+
expect(
|
64
|
+
connection.instance_variable_get(:@proxy_configuration).scheme
|
65
|
+
).to eq('http')
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context 'with authentication' do
|
70
|
+
let(:username) { 'test-username' }
|
71
|
+
let(:password) { 'test-password' }
|
72
|
+
let(:proxy_configuration) do
|
73
|
+
Ingenico::Connect::SDK::ProxyConfiguration.new(address: uri,
|
74
|
+
username: username,
|
75
|
+
password: password)
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'has the correct timeout values and proxy settings' do
|
79
|
+
expect(
|
80
|
+
connection.instance_variable_get(:@connect_timeout)
|
81
|
+
).to eq(connect_timeout)
|
82
|
+
|
83
|
+
expect(
|
84
|
+
connection.instance_variable_get(:@socket_timeout)
|
85
|
+
).to eq(socket_timeout)
|
86
|
+
|
87
|
+
pc = connection.instance_variable_get(:@proxy_configuration)
|
88
|
+
|
89
|
+
expect(pc.host).to eq('test-proxy')
|
90
|
+
expect(pc.port).to eq(80)
|
91
|
+
expect(pc.scheme).to eq('http')
|
92
|
+
expect(pc.username).to eq(username)
|
93
|
+
expect(pc.password).to eq(password)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end # construction
|
98
|
+
|
99
|
+
context 'sending and receiving' do
|
100
|
+
|
101
|
+
class DummyResponse
|
102
|
+
def status
|
103
|
+
200
|
104
|
+
end
|
105
|
+
attr_accessor :headers, :body, :content_type, :uri
|
106
|
+
end
|
107
|
+
|
108
|
+
context 'without proxy' do
|
109
|
+
before :example do
|
110
|
+
# mock the HTTPClient obj inside DefaultConnection
|
111
|
+
# for each type of requests so no real requests will be made
|
112
|
+
client = connection.instance_variable_get(:@http_client)
|
113
|
+
allow(client).to receive(:get) do |uri, hash|
|
114
|
+
dummy_response = DummyResponse.new
|
115
|
+
dummy_response.headers = hash[:header]
|
116
|
+
dummy_response.uri = uri
|
117
|
+
dummy_response
|
118
|
+
end
|
119
|
+
|
120
|
+
allow(client).to receive(:delete) do |uri, hash|
|
121
|
+
dummy_response = DummyResponse.new
|
122
|
+
dummy_response.headers = hash[:header]
|
123
|
+
dummy_response.uri = uri
|
124
|
+
dummy_response
|
125
|
+
end
|
126
|
+
|
127
|
+
allow(client).to receive(:post) do |uri, hash|
|
128
|
+
dummy_response = DummyResponse.new
|
129
|
+
dummy_response.headers = hash[:header]
|
130
|
+
dummy_response.uri = uri
|
131
|
+
dummy_response.body = hash[:body]
|
132
|
+
dummy_response
|
133
|
+
end
|
134
|
+
|
135
|
+
allow(client).to receive(:put) do |uri, hash|
|
136
|
+
dummy_response = DummyResponse.new
|
137
|
+
dummy_response.headers = hash[:header]
|
138
|
+
dummy_response.uri = uri
|
139
|
+
dummy_response.body = hash[:body]
|
140
|
+
dummy_response
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
let(:headers) { { 'header1' => 'dummy', 'header2' => 'yammy' } }
|
145
|
+
let(:sdk_headers) do
|
146
|
+
arr = []
|
147
|
+
headers.each { |k, v| arr << Ingenico::Connect::SDK::ResponseHeader.new(k, v) }
|
148
|
+
arr
|
149
|
+
end
|
150
|
+
let(:uri) { URI('http://foobar.com/v1/1234/services/convert/amount?source=EUR&amount=1000&target=USD') }
|
151
|
+
|
152
|
+
def expected_header_str(headers)
|
153
|
+
str = ''
|
154
|
+
headers.each { |k, v| str += k + '=' + '"' + v + '"' + ', '}
|
155
|
+
str.chomp(', ')
|
156
|
+
end
|
157
|
+
|
158
|
+
def sdk_headers_to_s(sdk_headers)
|
159
|
+
sdk_headers.inject('') { |s, h| s + h.name + ':' + h.value + ',' }
|
160
|
+
end
|
161
|
+
|
162
|
+
it 'sends the correct get request' do
|
163
|
+
res = connection.get(uri, sdk_headers)
|
164
|
+
expect(sdk_headers_to_s(res.headers)).to eq(sdk_headers_to_s(sdk_headers))
|
165
|
+
end
|
166
|
+
|
167
|
+
it 'sends the correct delete request' do
|
168
|
+
res = connection.delete(uri, sdk_headers)
|
169
|
+
expect(sdk_headers_to_s(res.headers)).to eq(sdk_headers_to_s(sdk_headers))
|
170
|
+
end
|
171
|
+
|
172
|
+
context 'with body' do
|
173
|
+
let(:body) { 'dummy body' }
|
174
|
+
|
175
|
+
it 'sends the correct post request' do
|
176
|
+
res = connection.post(uri, sdk_headers, body)
|
177
|
+
expect(res.get_header_value('Content-Type')).to eq('application/json')
|
178
|
+
expect(res.body).to eq(body)
|
179
|
+
end
|
180
|
+
|
181
|
+
it 'sends the correct put request' do
|
182
|
+
res = connection.put(uri, sdk_headers, body)
|
183
|
+
expect(res.get_header_value('Content-Type')).to eq('application/json')
|
184
|
+
expect(res.body).to eq(body)
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
context 'with logging' do
|
189
|
+
let(:logger) { StdoutCommunicatorLogger.INSTANCE }
|
190
|
+
let(:request_regex) do
|
191
|
+
# captures:
|
192
|
+
# 1) uuid
|
193
|
+
# 2) method
|
194
|
+
# 3) uri
|
195
|
+
# 4) headers
|
196
|
+
%r{\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2} Outgoing request \(requestId='([-a-zA-Z0-9]+)'\):
|
197
|
+
method: '([A-Z]+)'
|
198
|
+
uri: '(.+)'
|
199
|
+
headers: '(.*)'}
|
200
|
+
end
|
201
|
+
|
202
|
+
let(:request_with_body_regex) do
|
203
|
+
# captures:
|
204
|
+
# 1) uuid
|
205
|
+
# 2) method
|
206
|
+
# 3) uri
|
207
|
+
# 4) headers
|
208
|
+
# 5) content_type
|
209
|
+
# 6) body
|
210
|
+
%r{\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2} Outgoing request \(requestId='([-a-zA-Z0-9]+)'\):
|
211
|
+
method: '([A-Z]+)'
|
212
|
+
uri: '(.+)'
|
213
|
+
headers: '(.*)'
|
214
|
+
content-type: '(.+)'
|
215
|
+
body: '(.+)'}
|
216
|
+
end
|
217
|
+
|
218
|
+
let(:response_regex) do
|
219
|
+
# captures:
|
220
|
+
# 1) status-cde
|
221
|
+
# 2) headers
|
222
|
+
# 3) content-type
|
223
|
+
# 4) body
|
224
|
+
%r{\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2} Incoming response \(requestId='([-a-zA-Z0-9]+)'.*\):
|
225
|
+
status-code: '(\d+)'
|
226
|
+
headers: '(.*)'
|
227
|
+
content-type: '(.*)'
|
228
|
+
body: '(.*)'}
|
229
|
+
end
|
230
|
+
|
231
|
+
let(:regex) { Regexp.new(request_regex.to_s + "\n" + response_regex.to_s) }
|
232
|
+
|
233
|
+
let(:with_body_regex) do
|
234
|
+
Regexp.new(request_with_body_regex.to_s + "\n" + response_regex.to_s)
|
235
|
+
end
|
236
|
+
|
237
|
+
before :example do
|
238
|
+
$stdout = StringIO.new
|
239
|
+
connection.enable_logging(logger)
|
240
|
+
end
|
241
|
+
|
242
|
+
after :example do
|
243
|
+
connection.disable_logging
|
244
|
+
$stdout.close
|
245
|
+
$stdout = STDOUT
|
246
|
+
end
|
247
|
+
|
248
|
+
# TODO: DELETE is basically the same, do we need to test it?
|
249
|
+
it 'logs the correct get request' do
|
250
|
+
connection.get(uri, sdk_headers)
|
251
|
+
expect($stdout.string).to match(regex)
|
252
|
+
match_info = $stdout.string.match(regex)
|
253
|
+
expect(match_info[2]).to eq('GET')
|
254
|
+
expect(match_info[3]).to eq(uri.path + '?' + uri.query)
|
255
|
+
expect(match_info[4]).to eq(expected_header_str(headers))
|
256
|
+
end
|
257
|
+
|
258
|
+
# TODO: same for PUT
|
259
|
+
context 'with body' do
|
260
|
+
let(:body) { 'dummy body' }
|
261
|
+
it 'logs the correct post request' do
|
262
|
+
connection.post(uri, sdk_headers, body)
|
263
|
+
expect($stdout.string).to match(with_body_regex)
|
264
|
+
match_info = $stdout.string.match(with_body_regex)
|
265
|
+
expect(match_info[2]).to eq('POST')
|
266
|
+
expect(match_info[3]).to eq(uri.path + '?' + uri.query)
|
267
|
+
headers['Content-Type'] = 'application/json' # with body
|
268
|
+
expect(match_info[4]).to eq(expected_header_str(headers))
|
269
|
+
expect(match_info[5]).to eq('application/json')
|
270
|
+
expect(match_info[6]).to eq(body)
|
271
|
+
end
|
272
|
+
end
|
273
|
+
end
|
274
|
+
end
|
275
|
+
end # sending and receiving
|
276
|
+
|
277
|
+
context 'connection' do
|
278
|
+
server = nil
|
279
|
+
before :context do
|
280
|
+
WebMock.allow_net_connect!
|
281
|
+
server = Thread.new do
|
282
|
+
class DummyServer < Sinatra::Application
|
283
|
+
prefix = 'spec/fixtures/resources/defaultimpl/'
|
284
|
+
|
285
|
+
get '/convert_amount.json' do
|
286
|
+
content_type :json
|
287
|
+
IO.read(prefix + 'convertAmount.json')
|
288
|
+
end
|
289
|
+
|
290
|
+
get '/' do
|
291
|
+
'testing'
|
292
|
+
end
|
293
|
+
|
294
|
+
run!
|
295
|
+
end
|
296
|
+
end
|
297
|
+
sleep 1 # wait for the server
|
298
|
+
end
|
299
|
+
|
300
|
+
after :context do
|
301
|
+
Thread.kill(server) # shutdown the server
|
302
|
+
WebMock.disable_net_connect!
|
303
|
+
end
|
304
|
+
|
305
|
+
before :example do
|
306
|
+
connection.close
|
307
|
+
end
|
308
|
+
|
309
|
+
let(:uri) { URI('http://localhost:4567/convert_amount.json') }
|
310
|
+
let(:sdk_headers) { [] }
|
311
|
+
|
312
|
+
it 'uses persistent connection if HTTP 1.1 is supported' do
|
313
|
+
100.times { connection.get(uri, sdk_headers) }
|
314
|
+
expect(connection.session_count).to eq(1)
|
315
|
+
end
|
316
|
+
|
317
|
+
it 'retrieves the correct json file' do
|
318
|
+
res = connection.get(uri, sdk_headers)
|
319
|
+
prefix = 'spec/fixtures/resources/defaultimpl/'
|
320
|
+
expect(res.body).to eq(IO.read(prefix + 'convertAmount.json'))
|
321
|
+
end
|
322
|
+
|
323
|
+
it 'can explicitly close connections' do
|
324
|
+
connection.get(uri, sdk_headers)
|
325
|
+
expect(connection.session_count).to eq(1)
|
326
|
+
|
327
|
+
connection.close
|
328
|
+
expect(connection.session_count).to eq(0)
|
329
|
+
|
330
|
+
connection.get(uri, sdk_headers)
|
331
|
+
expect(connection.session_count).to eq(1)
|
332
|
+
end
|
333
|
+
end
|
334
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'ingenico/connect/sdk/domain/definitions/address'
|
3
|
+
require 'ingenico/connect/sdk/domain/token/customer_token'
|
4
|
+
require 'ingenico/connect/sdk/domain/token/token_card'
|
5
|
+
require 'ingenico/connect/sdk/domain/token/token_card_data'
|
6
|
+
require 'ingenico/connect/sdk/domain/token/token_response'
|
7
|
+
|
8
|
+
DataObject ||= Ingenico::Connect::SDK::DataObject
|
9
|
+
DefaultMarshaller ||= Ingenico::Connect::SDK::DefaultImpl::DefaultMarshaller
|
10
|
+
Token ||= Ingenico::Connect::SDK::Domain::Token
|
11
|
+
|
12
|
+
class TokenResponseWithExtraField < Token::TokenResponse
|
13
|
+
attr_accessor :dummy
|
14
|
+
end
|
15
|
+
|
16
|
+
describe DefaultMarshaller do
|
17
|
+
context 'unmarshal()' do
|
18
|
+
it 'should unmarshal extra fields' do
|
19
|
+
token = TokenResponseWithExtraField.new
|
20
|
+
token.card = Token::TokenCard.new
|
21
|
+
token.card.customer = Token::CustomerToken.new
|
22
|
+
token.card.customer.billing_address = Ingenico::Connect::SDK::Domain::Definitions::Address.new
|
23
|
+
token.card.customer.billing_address.country_code = 'NL'
|
24
|
+
token.card.data = Token::TokenCardData.new
|
25
|
+
token.dummy = 'foobar'
|
26
|
+
# marshal the extended token and unmarshal it as a regular token response
|
27
|
+
unmarshalled = DefaultMarshaller.INSTANCE.unmarshal(DefaultMarshaller.INSTANCE.marshal(token), Token::TokenResponse)
|
28
|
+
|
29
|
+
expect(unmarshalled.card).to_not be_nil
|
30
|
+
expect(unmarshalled.card.customer).to_not be_nil
|
31
|
+
expect(unmarshalled.card.customer.billing_address).to_not be_nil
|
32
|
+
expect(unmarshalled.card.customer.billing_address.country_code).to eq('NL')
|
33
|
+
expect(token.card.data).to_not be_nil
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'uri'
|
3
|
+
|
4
|
+
Factory ||= Ingenico::Connect::SDK::Factory
|
5
|
+
|
6
|
+
describe 'Factory' do
|
7
|
+
it 'can initialize configurations' do
|
8
|
+
configuration = Factory.create_configuration(PROPERTIES_URI, API_KEY_ID, SECRET_API_KEY)
|
9
|
+
|
10
|
+
expect(configuration.api_endpoint).to eq('https://api-sandbox.globalcollect.com')
|
11
|
+
expect(configuration.authorization_type).to eq('v1HMAC')
|
12
|
+
expect(configuration.connect_timeout).to eq(-1)
|
13
|
+
expect(configuration.socket_timeout).to eq(-1)
|
14
|
+
expect(configuration.max_connections).to eq(100)
|
15
|
+
expect(configuration.api_key_id).to eq(API_KEY_ID)
|
16
|
+
expect(configuration.secret_api_key).to eq(SECRET_API_KEY)
|
17
|
+
expect(configuration.proxy_configuration).to be_nil
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'can initialize communicators' do
|
21
|
+
communicator = Factory.create_communicator_from_file(PROPERTIES_URI, API_KEY_ID, SECRET_API_KEY)
|
22
|
+
session = communicator.instance_variable_get(:@session)
|
23
|
+
connection = session.connection
|
24
|
+
authenticator = session.authenticator
|
25
|
+
meta_data_provider = session.meta_data_provider
|
26
|
+
request_headers = meta_data_provider.meta_data_headers
|
27
|
+
|
28
|
+
expect(communicator.marshaller).to be(Ingenico::Connect::SDK::DefaultImpl::DefaultMarshaller.INSTANCE)
|
29
|
+
expect(connection).to be_an_instance_of(Ingenico::Connect::SDK::DefaultImpl::DefaultConnection)
|
30
|
+
expect(authenticator).to be_an_instance_of(Ingenico::Connect::SDK::DefaultImpl::DefaultAuthenticator)
|
31
|
+
expect(meta_data_provider).to be_an_instance_of(Ingenico::Connect::SDK::MetaDataProvider)
|
32
|
+
|
33
|
+
expect(authenticator.instance_variable_get(:@authorization_type))
|
34
|
+
.to eq(Ingenico::Connect::SDK::DefaultImpl::AuthorizationType.get_authorization('v1HMAC'))
|
35
|
+
expect(authenticator.instance_variable_get(:@api_key_id)).to eq(API_KEY_ID)
|
36
|
+
expect(authenticator.instance_variable_get(:@secret_api_key)).to eq(SECRET_API_KEY)
|
37
|
+
|
38
|
+
expect(request_headers.length).to eq(1)
|
39
|
+
expect(request_headers[0].name).to eq('X-GCS-ServerMetaInfo')
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
HeaderObfuscator ||= Ingenico::Connect::SDK::Logging::HeaderObfuscator
|
4
|
+
ValueObfuscator ||= Ingenico::Connect::SDK::Logging::ValueObfuscator
|
5
|
+
|
6
|
+
describe HeaderObfuscator do
|
7
|
+
subject(:sample) { HeaderObfuscator.new(obsfs) }
|
8
|
+
context 'initialize' do
|
9
|
+
let(:obsfs) { { 'k1' => ValueObfuscator.fixed_length(5),
|
10
|
+
'k2' => ValueObfuscator.keep_start_count(2) } }
|
11
|
+
it 'is cass insensitive' do
|
12
|
+
obsfs_copy = sample.instance_variable_get(:@obfuscators)
|
13
|
+
expect(
|
14
|
+
obsfs_copy['k1']
|
15
|
+
).to equal(obsfs_copy['K1'])
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
it '.builder returns new Builder obj' do
|
20
|
+
expect(
|
21
|
+
HeaderObfuscator.builder.is_a? HeaderObfuscator::Builder
|
22
|
+
).to be(true)
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'Builder' do
|
26
|
+
it 'checks argument type' do
|
27
|
+
b = HeaderObfuscator.builder
|
28
|
+
expect {
|
29
|
+
b.with_all(123)
|
30
|
+
}.to raise_error(ArgumentError)
|
31
|
+
|
32
|
+
expect {
|
33
|
+
b.with_fixed_length(123)
|
34
|
+
}.to raise_error(ArgumentError)
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'inherits parent methods' do
|
38
|
+
b = HeaderObfuscator.builder
|
39
|
+
expect {
|
40
|
+
b.with_keep_start_count('k1', 123)
|
41
|
+
b.with_keep_end_count('k2', 123)
|
42
|
+
}.not_to raise_error
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'implements build method' do
|
46
|
+
expect(
|
47
|
+
HeaderObfuscator.builder.build.is_a? HeaderObfuscator
|
48
|
+
).to be(true)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|