onlinepayments-sdk-ruby 4.23.0 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +0 -0
- data/LICENSE.txt +0 -0
- data/README.md +5 -6
- data/Rakefile +0 -0
- data/lib/onlinepayments/sdk/api_exception.rb +47 -35
- data/lib/onlinepayments/sdk/api_resource.rb +49 -97
- data/lib/onlinepayments/sdk/authentication/authenticator.rb +19 -0
- data/lib/onlinepayments/sdk/authentication/authorization_type.rb +15 -0
- data/lib/onlinepayments/sdk/authentication/v1hmac_authenticator.rb +109 -0
- data/lib/onlinepayments/sdk/authentication.rb +1 -0
- data/lib/onlinepayments/sdk/authorization_exception.rb +14 -8
- data/lib/onlinepayments/sdk/call_context.rb +30 -21
- data/lib/onlinepayments/sdk/client.rb +36 -18
- data/lib/onlinepayments/sdk/communication/communication_exception.rb +19 -0
- data/lib/onlinepayments/sdk/communication/connection.rb +48 -0
- data/lib/onlinepayments/sdk/communication/default_connection.rb +427 -0
- data/lib/onlinepayments/sdk/communication/metadata_provider.rb +160 -0
- data/lib/onlinepayments/sdk/communication/multipart_form_data_object.rb +52 -0
- data/lib/onlinepayments/sdk/communication/multipart_form_data_request.rb +13 -0
- data/lib/onlinepayments/sdk/communication/not_found_exception.rb +19 -0
- data/lib/onlinepayments/sdk/communication/param_request.rb +14 -0
- data/lib/onlinepayments/sdk/communication/pooled_connection.rb +26 -0
- data/lib/onlinepayments/sdk/communication/request_header.rb +62 -0
- data/lib/onlinepayments/sdk/communication/request_param.rb +28 -0
- data/lib/onlinepayments/sdk/communication/response_exception.rb +56 -0
- data/lib/onlinepayments/sdk/communication/response_header.rb +78 -0
- data/lib/onlinepayments/sdk/communication.rb +1 -0
- data/lib/onlinepayments/sdk/communicator.rb +475 -268
- data/lib/onlinepayments/sdk/communicator_configuration.rb +162 -53
- data/lib/onlinepayments/sdk/declined_payment_exception.rb +28 -21
- data/lib/onlinepayments/sdk/declined_payout_exception.rb +28 -23
- data/lib/onlinepayments/sdk/declined_refund_exception.rb +28 -23
- data/lib/onlinepayments/sdk/declined_transaction_exception.rb +16 -10
- data/lib/onlinepayments/sdk/domain/account_on_file.rb +44 -35
- data/lib/onlinepayments/sdk/domain/account_on_file_attribute.rb +42 -28
- data/lib/onlinepayments/sdk/domain/account_on_file_display_hints.rb +29 -24
- data/lib/onlinepayments/sdk/domain/acquirer_information.rb +27 -22
- data/lib/onlinepayments/sdk/domain/acquirer_selection_information.rb +34 -24
- data/lib/onlinepayments/sdk/domain/additional_order_input.rb +43 -38
- data/lib/onlinepayments/sdk/domain/address.rb +65 -43
- data/lib/onlinepayments/sdk/domain/address_personal.rb +78 -52
- data/lib/onlinepayments/sdk/domain/airline_data.rb +204 -123
- data/lib/onlinepayments/sdk/domain/airline_flight_leg.rb +158 -95
- data/lib/onlinepayments/sdk/domain/airline_passenger.rb +59 -39
- data/lib/onlinepayments/sdk/domain/amount_breakdown.rb +27 -20
- data/lib/onlinepayments/sdk/domain/amount_of_money.rb +27 -20
- data/lib/onlinepayments/sdk/domain/api_error.rb +73 -47
- data/lib/onlinepayments/sdk/domain/apple_pay_line_item.rb +72 -0
- data/lib/onlinepayments/sdk/domain/apple_pay_recurring_payment_request.rb +61 -0
- data/lib/onlinepayments/sdk/domain/bank_account_iban.rb +20 -16
- data/lib/onlinepayments/sdk/domain/browser_data.rb +51 -35
- data/lib/onlinepayments/sdk/domain/calculate_surcharge_request.rb +27 -24
- data/lib/onlinepayments/sdk/domain/calculate_surcharge_response.rb +22 -20
- data/lib/onlinepayments/sdk/domain/cancel_payment_request.rb +27 -22
- data/lib/onlinepayments/sdk/domain/cancel_payment_response.rb +20 -18
- data/lib/onlinepayments/sdk/domain/capture.rb +41 -32
- data/lib/onlinepayments/sdk/domain/capture_output.rb +106 -78
- data/lib/onlinepayments/sdk/domain/capture_payment_request.rb +43 -26
- data/lib/onlinepayments/sdk/domain/capture_response.rb +41 -32
- data/lib/onlinepayments/sdk/domain/capture_status_output.rb +20 -16
- data/lib/onlinepayments/sdk/domain/captures_response.rb +22 -20
- data/lib/onlinepayments/sdk/domain/card.rb +41 -28
- data/lib/onlinepayments/sdk/domain/card_essentials.rb +41 -28
- data/lib/onlinepayments/sdk/domain/card_fraud_results.rb +34 -24
- data/lib/onlinepayments/sdk/domain/card_info.rb +27 -20
- data/lib/onlinepayments/sdk/domain/card_payment_method_specific_input.rb +199 -128
- data/lib/onlinepayments/sdk/domain/card_payment_method_specific_input_base.rb +149 -104
- data/lib/onlinepayments/sdk/domain/card_payment_method_specific_input_for_hosted_checkout.rb +36 -28
- data/lib/onlinepayments/sdk/domain/card_payment_method_specific_output.rb +133 -100
- data/lib/onlinepayments/sdk/domain/card_payout_method_specific_input.rb +41 -30
- data/lib/onlinepayments/sdk/domain/card_recurrence_details.rb +20 -16
- data/lib/onlinepayments/sdk/domain/card_source.rb +41 -30
- data/lib/onlinepayments/sdk/domain/card_without_cvv.rb +34 -24
- data/lib/onlinepayments/sdk/domain/company_information.rb +20 -16
- data/lib/onlinepayments/sdk/domain/complete_payment_card_payment_method_specific_input.rb +20 -18
- data/lib/onlinepayments/sdk/domain/complete_payment_request.rb +27 -24
- data/lib/onlinepayments/sdk/domain/complete_payment_response.rb +35 -31
- data/lib/onlinepayments/sdk/domain/contact_details.rb +51 -35
- data/lib/onlinepayments/sdk/domain/create_hosted_checkout_request.rb +76 -59
- data/lib/onlinepayments/sdk/domain/create_hosted_checkout_response.rb +60 -43
- data/lib/onlinepayments/sdk/domain/create_hosted_tokenization_request.rb +57 -42
- data/lib/onlinepayments/sdk/domain/create_hosted_tokenization_response.rb +57 -44
- data/lib/onlinepayments/sdk/domain/create_mandate_request.rb +71 -48
- data/lib/onlinepayments/sdk/domain/create_mandate_response.rb +27 -24
- data/lib/onlinepayments/sdk/domain/create_mandate_with_return_url.rb +71 -48
- data/lib/onlinepayments/sdk/domain/create_payment_link_request.rb +120 -87
- data/lib/onlinepayments/sdk/domain/create_payment_request.rb +82 -60
- data/lib/onlinepayments/sdk/domain/create_payment_response.rb +35 -31
- data/lib/onlinepayments/sdk/domain/create_payout_request.rb +61 -40
- data/lib/onlinepayments/sdk/domain/create_token_request.rb +27 -22
- data/lib/onlinepayments/sdk/domain/created_payment_output.rb +27 -22
- data/lib/onlinepayments/sdk/domain/created_token_response.rb +50 -38
- data/lib/onlinepayments/sdk/domain/credit_card_specific_input_hosted_tokenization.rb +29 -26
- data/lib/onlinepayments/sdk/domain/credit_card_validation_rules_hosted_tokenization.rb +27 -20
- data/lib/onlinepayments/sdk/domain/currency_conversion.rb +27 -22
- data/lib/onlinepayments/sdk/domain/currency_conversion_input.rb +27 -20
- data/lib/onlinepayments/sdk/domain/currency_conversion_request.rb +27 -24
- data/lib/onlinepayments/sdk/domain/currency_conversion_response.rb +34 -28
- data/lib/onlinepayments/sdk/domain/currency_conversion_result.rb +27 -20
- data/lib/onlinepayments/sdk/domain/currency_conversion_specific_input.rb +20 -16
- data/lib/onlinepayments/sdk/domain/customer.rb +87 -68
- data/lib/onlinepayments/sdk/domain/customer_account.rb +77 -55
- data/lib/onlinepayments/sdk/domain/customer_account_authentication.rb +34 -20
- data/lib/onlinepayments/sdk/domain/customer_bank_account.rb +34 -24
- data/lib/onlinepayments/sdk/domain/customer_device.rb +64 -44
- data/lib/onlinepayments/sdk/domain/customer_device_output.rb +20 -16
- data/lib/onlinepayments/sdk/domain/customer_output.rb +20 -18
- data/lib/onlinepayments/sdk/domain/customer_payment_activity.rb +34 -24
- data/lib/onlinepayments/sdk/domain/customer_token.rb +35 -31
- data/lib/onlinepayments/sdk/domain/data_object.rb +32 -0
- data/lib/onlinepayments/sdk/domain/dcc_card_source.rb +41 -30
- data/lib/onlinepayments/sdk/domain/dcc_proposal.rb +51 -41
- data/lib/onlinepayments/sdk/domain/decrypted_payment_data.rb +51 -35
- data/lib/onlinepayments/sdk/domain/directory_entry.rb +34 -24
- data/lib/onlinepayments/sdk/domain/discount.rb +20 -16
- data/lib/onlinepayments/sdk/domain/empty_validator.rb +7 -6
- data/lib/onlinepayments/sdk/domain/error_response.rb +29 -24
- data/lib/onlinepayments/sdk/domain/external_cardholder_authentication_data.rb +86 -55
- data/lib/onlinepayments/sdk/domain/external_token_linked.rb +35 -24
- data/lib/onlinepayments/sdk/domain/feedbacks.rb +30 -0
- data/lib/onlinepayments/sdk/domain/fixed_list_validator.rb +22 -20
- data/lib/onlinepayments/sdk/domain/fraud_fields.rb +37 -28
- data/lib/onlinepayments/sdk/domain/fraud_results.rb +20 -16
- data/lib/onlinepayments/sdk/domain/g_pay_three_d_secure.rb +50 -36
- data/lib/onlinepayments/sdk/domain/get_hosted_checkout_response.rb +27 -22
- data/lib/onlinepayments/sdk/domain/get_hosted_tokenization_response.rb +27 -22
- data/lib/onlinepayments/sdk/domain/get_iin_details_request.rb +27 -22
- data/lib/onlinepayments/sdk/domain/get_iin_details_response.rb +52 -38
- data/lib/onlinepayments/sdk/domain/get_mandate_response.rb +20 -18
- data/lib/onlinepayments/sdk/domain/get_payment_product_groups_response.rb +22 -20
- data/lib/onlinepayments/sdk/domain/get_payment_products_response.rb +22 -20
- data/lib/onlinepayments/sdk/domain/get_privacy_policy_response.rb +20 -16
- data/lib/onlinepayments/sdk/domain/gift_card_purchase.rb +27 -22
- data/lib/onlinepayments/sdk/domain/hosted_checkout_specific_input.rb +83 -56
- data/lib/onlinepayments/sdk/domain/hosted_checkout_specific_output.rb +27 -20
- data/lib/onlinepayments/sdk/domain/iin_detail.rb +34 -24
- data/lib/onlinepayments/sdk/domain/label_template_element.rb +27 -20
- data/lib/onlinepayments/sdk/domain/length_validator.rb +27 -20
- data/lib/onlinepayments/sdk/domain/line_item.rb +44 -31
- data/lib/onlinepayments/sdk/domain/line_item_invoice_data.rb +20 -16
- data/lib/onlinepayments/sdk/domain/loan_recipient.rb +51 -35
- data/lib/onlinepayments/sdk/domain/lodging_data.rb +20 -16
- data/lib/onlinepayments/sdk/domain/mandate_address.rb +51 -35
- data/lib/onlinepayments/sdk/domain/mandate_address_response.rb +51 -35
- data/lib/onlinepayments/sdk/domain/mandate_contact_details.rb +20 -16
- data/lib/onlinepayments/sdk/domain/mandate_customer.rb +52 -44
- data/lib/onlinepayments/sdk/domain/mandate_customer_response.rb +52 -44
- data/lib/onlinepayments/sdk/domain/mandate_merchant_action.rb +27 -22
- data/lib/onlinepayments/sdk/domain/mandate_personal_information.rb +27 -22
- data/lib/onlinepayments/sdk/domain/mandate_personal_information_response.rb +27 -22
- data/lib/onlinepayments/sdk/domain/mandate_personal_name.rb +27 -20
- data/lib/onlinepayments/sdk/domain/mandate_personal_name_response.rb +27 -20
- data/lib/onlinepayments/sdk/domain/mandate_redirect_data.rb +27 -20
- data/lib/onlinepayments/sdk/domain/mandate_response.rb +64 -44
- data/lib/onlinepayments/sdk/domain/merchant_action.rb +43 -28
- data/lib/onlinepayments/sdk/domain/mobile_payment_data.rb +27 -20
- data/lib/onlinepayments/sdk/domain/mobile_payment_method_hosted_checkout_specific_input.rb +43 -26
- data/lib/onlinepayments/sdk/domain/mobile_payment_method_specific_input.rb +71 -50
- data/lib/onlinepayments/sdk/domain/mobile_payment_method_specific_output.rb +58 -45
- data/lib/onlinepayments/sdk/domain/mobile_payment_product302_specific_input.rb +32 -0
- data/lib/onlinepayments/sdk/domain/mobile_payment_product320_specific_input.rb +20 -18
- data/lib/onlinepayments/sdk/domain/mobile_three_d_secure_challenge_parameters.rb +51 -0
- data/lib/onlinepayments/sdk/domain/multiple_payment_information.rb +27 -20
- data/lib/onlinepayments/sdk/domain/omnichannel_payout_specific_input.rb +20 -16
- data/lib/onlinepayments/sdk/domain/operation_output.rb +67 -45
- data/lib/onlinepayments/sdk/domain/operation_payment_references.rb +30 -0
- data/lib/onlinepayments/sdk/domain/order.rb +75 -66
- data/lib/onlinepayments/sdk/domain/order_line_details.rb +79 -47
- data/lib/onlinepayments/sdk/domain/order_references.rb +34 -24
- data/lib/onlinepayments/sdk/domain/order_status_output.rb +52 -38
- data/lib/onlinepayments/sdk/domain/order_type_information.rb +27 -20
- data/lib/onlinepayments/sdk/domain/other_details.rb +37 -0
- data/lib/onlinepayments/sdk/domain/payment_account_on_file.rb +27 -20
- data/lib/onlinepayments/sdk/domain/payment_context.rb +34 -26
- data/lib/onlinepayments/sdk/domain/payment_creation_output.rb +41 -28
- data/lib/onlinepayments/sdk/domain/payment_details_response.rb +60 -49
- data/lib/onlinepayments/sdk/domain/payment_error_response.rb +37 -31
- data/lib/onlinepayments/sdk/domain/payment_link_event.rb +34 -24
- data/lib/onlinepayments/sdk/domain/payment_link_order_input.rb +34 -28
- data/lib/onlinepayments/sdk/domain/payment_link_order_output.rb +34 -28
- data/lib/onlinepayments/sdk/domain/payment_link_response.rb +74 -51
- data/lib/onlinepayments/sdk/domain/payment_link_specific_input.rb +36 -24
- data/lib/onlinepayments/sdk/domain/payment_output.rb +115 -94
- data/lib/onlinepayments/sdk/domain/payment_product.rb +117 -85
- data/lib/onlinepayments/sdk/domain/payment_product130_specific_input.rb +20 -18
- data/lib/onlinepayments/sdk/domain/payment_product130_specific_three_d_secure.rb +41 -28
- data/lib/onlinepayments/sdk/domain/payment_product3012.rb +27 -20
- data/lib/onlinepayments/sdk/domain/payment_product3012_specific_input.rb +51 -0
- data/lib/onlinepayments/sdk/domain/payment_product302_specific_data.rb +22 -20
- data/lib/onlinepayments/sdk/domain/payment_product3203_specific_output.rb +27 -24
- data/lib/onlinepayments/sdk/domain/payment_product3208_specific_input.rb +20 -16
- data/lib/onlinepayments/sdk/domain/payment_product3208_specific_output.rb +20 -16
- data/lib/onlinepayments/sdk/domain/payment_product3209_specific_input.rb +20 -16
- data/lib/onlinepayments/sdk/domain/payment_product3209_specific_output.rb +20 -16
- data/lib/onlinepayments/sdk/domain/payment_product320_specific_data.rb +29 -24
- data/lib/onlinepayments/sdk/domain/payment_product5001_specific_output.rb +48 -16
- data/lib/onlinepayments/sdk/domain/payment_product5100_specific_input.rb +20 -16
- data/lib/onlinepayments/sdk/domain/payment_product5402_specific_output.rb +20 -16
- data/lib/onlinepayments/sdk/domain/payment_product5404.rb +27 -20
- data/lib/onlinepayments/sdk/domain/payment_product5407.rb +27 -20
- data/lib/onlinepayments/sdk/domain/payment_product5500_specific_output.rb +41 -24
- data/lib/onlinepayments/sdk/domain/payment_product771_specific_output.rb +20 -16
- data/lib/onlinepayments/sdk/domain/payment_product840_customer_account.rb +72 -47
- data/lib/onlinepayments/sdk/domain/payment_product840_specific_output.rb +43 -38
- data/lib/onlinepayments/sdk/domain/payment_product_display_hints.rb +34 -24
- data/lib/onlinepayments/sdk/domain/payment_product_field.rb +41 -32
- data/lib/onlinepayments/sdk/domain/payment_product_field_data_restrictions.rb +27 -22
- data/lib/onlinepayments/sdk/domain/payment_product_field_display_element.rb +41 -28
- data/lib/onlinepayments/sdk/domain/payment_product_field_display_hints.rb +84 -56
- data/lib/onlinepayments/sdk/domain/payment_product_field_form_element.rb +30 -24
- data/lib/onlinepayments/sdk/domain/payment_product_field_tooltip.rb +28 -20
- data/lib/onlinepayments/sdk/domain/payment_product_field_validators.rb +83 -73
- data/lib/onlinepayments/sdk/domain/payment_product_filter.rb +32 -29
- data/lib/onlinepayments/sdk/domain/payment_product_filter_hosted_tokenization.rb +22 -20
- data/lib/onlinepayments/sdk/domain/payment_product_filters_hosted_checkout.rb +27 -24
- data/lib/onlinepayments/sdk/domain/payment_product_filters_hosted_tokenization.rb +27 -24
- data/lib/onlinepayments/sdk/domain/payment_product_group.rb +44 -37
- data/lib/onlinepayments/sdk/domain/payment_product_networks_response.rb +22 -20
- data/lib/onlinepayments/sdk/domain/payment_references.rb +27 -20
- data/lib/onlinepayments/sdk/domain/payment_response.rb +51 -41
- data/lib/onlinepayments/sdk/domain/payment_status_output.rb +66 -46
- data/lib/onlinepayments/sdk/domain/payout_error_response.rb +37 -31
- data/lib/onlinepayments/sdk/domain/payout_output.rb +27 -22
- data/lib/onlinepayments/sdk/domain/payout_response.rb +41 -32
- data/lib/onlinepayments/sdk/domain/payout_result.rb +41 -32
- data/lib/onlinepayments/sdk/domain/payout_status_output.rb +34 -24
- data/lib/onlinepayments/sdk/domain/personal_information.rb +34 -26
- data/lib/onlinepayments/sdk/domain/personal_information_token.rb +20 -18
- data/lib/onlinepayments/sdk/domain/personal_name.rb +34 -24
- data/lib/onlinepayments/sdk/domain/personal_name_token.rb +27 -20
- data/lib/onlinepayments/sdk/domain/product_directory.rb +22 -20
- data/lib/onlinepayments/sdk/domain/protection_eligibility.rb +27 -20
- data/lib/onlinepayments/sdk/domain/range_validator.rb +27 -20
- data/lib/onlinepayments/sdk/domain/rate_details.rb +51 -35
- data/lib/onlinepayments/sdk/domain/redirect_data.rb +27 -20
- data/lib/onlinepayments/sdk/domain/redirect_payment_method_specific_input.rb +139 -88
- data/lib/onlinepayments/sdk/domain/redirect_payment_method_specific_output.rb +95 -75
- data/lib/onlinepayments/sdk/domain/redirect_payment_product3203_specific_input.rb +20 -16
- data/lib/onlinepayments/sdk/domain/redirect_payment_product3302_specific_input.rb +44 -0
- data/lib/onlinepayments/sdk/domain/redirect_payment_product3306_specific_input.rb +20 -16
- data/lib/onlinepayments/sdk/domain/redirect_payment_product5001_specific_input.rb +20 -16
- data/lib/onlinepayments/sdk/domain/redirect_payment_product5300_specific_input.rb +74 -0
- data/lib/onlinepayments/sdk/domain/redirect_payment_product5406_specific_input.rb +20 -18
- data/lib/onlinepayments/sdk/domain/redirect_payment_product5408_specific_input.rb +27 -22
- data/lib/onlinepayments/sdk/domain/redirect_payment_product5410_specific_input.rb +32 -0
- data/lib/onlinepayments/sdk/domain/redirect_payment_product809_specific_input.rb +20 -16
- data/lib/onlinepayments/sdk/domain/redirect_payment_product840_specific_input.rb +41 -20
- data/lib/onlinepayments/sdk/domain/redirection_data.rb +20 -16
- data/lib/onlinepayments/sdk/domain/refund_card_method_specific_output.rb +34 -26
- data/lib/onlinepayments/sdk/domain/refund_e_wallet_method_specific_output.rb +34 -26
- data/lib/onlinepayments/sdk/domain/refund_error_response.rb +37 -31
- data/lib/onlinepayments/sdk/domain/refund_mobile_method_specific_output.rb +34 -24
- data/lib/onlinepayments/sdk/domain/refund_output.rb +89 -64
- data/lib/onlinepayments/sdk/domain/refund_payment_product840_customer_account.rb +34 -24
- data/lib/onlinepayments/sdk/domain/refund_payment_product840_specific_output.rb +20 -18
- data/lib/onlinepayments/sdk/domain/refund_redirect_method_specific_output.rb +27 -20
- data/lib/onlinepayments/sdk/domain/refund_request.rb +43 -24
- data/lib/onlinepayments/sdk/domain/refund_response.rb +41 -32
- data/lib/onlinepayments/sdk/domain/refunds_response.rb +22 -20
- data/lib/onlinepayments/sdk/domain/regular_expression_validator.rb +20 -16
- data/lib/onlinepayments/sdk/domain/send_test_request.rb +30 -0
- data/lib/onlinepayments/sdk/domain/sepa_direct_debit_payment_method_specific_input.rb +27 -22
- data/lib/onlinepayments/sdk/domain/sepa_direct_debit_payment_method_specific_input_base.rb +27 -22
- data/lib/onlinepayments/sdk/domain/sepa_direct_debit_payment_method_specific_output.rb +34 -28
- data/lib/onlinepayments/sdk/domain/sepa_direct_debit_payment_product771_specific_input.rb +27 -22
- data/lib/onlinepayments/sdk/domain/sepa_direct_debit_payment_product771_specific_input_base.rb +27 -22
- data/lib/onlinepayments/sdk/domain/session_request.rb +22 -20
- data/lib/onlinepayments/sdk/domain/session_response.rb +53 -39
- data/lib/onlinepayments/sdk/domain/shipping.rb +76 -52
- data/lib/onlinepayments/sdk/domain/shipping_method.rb +41 -28
- data/lib/onlinepayments/sdk/domain/shopping_cart.rb +62 -48
- data/lib/onlinepayments/sdk/domain/shopping_cart_extension.rb +51 -43
- data/lib/onlinepayments/sdk/domain/show_form_data.rb +35 -31
- data/lib/onlinepayments/sdk/domain/subsequent_card_payment_method_specific_input.rb +60 -39
- data/lib/onlinepayments/sdk/domain/subsequent_payment_product5001_specific_input.rb +20 -16
- data/lib/onlinepayments/sdk/domain/subsequent_payment_request.rb +35 -31
- data/lib/onlinepayments/sdk/domain/subsequent_payment_response.rb +20 -18
- data/lib/onlinepayments/sdk/domain/surcharge.rb +59 -48
- data/lib/onlinepayments/sdk/domain/surcharge_calculation_card.rb +27 -20
- data/lib/onlinepayments/sdk/domain/surcharge_for_payment_link.rb +20 -16
- data/lib/onlinepayments/sdk/domain/surcharge_rate.rb +41 -28
- data/lib/onlinepayments/sdk/domain/surcharge_specific_input.rb +27 -22
- data/lib/onlinepayments/sdk/domain/surcharge_specific_output.rb +34 -28
- data/lib/onlinepayments/sdk/domain/test_connection.rb +20 -16
- data/lib/onlinepayments/sdk/domain/three_d_secure.rb +98 -63
- data/lib/onlinepayments/sdk/domain/three_d_secure_base.rb +78 -52
- data/lib/onlinepayments/sdk/domain/three_d_secure_data.rb +34 -24
- data/lib/onlinepayments/sdk/domain/three_d_secure_results.rb +107 -67
- data/lib/onlinepayments/sdk/domain/token_card.rb +27 -22
- data/lib/onlinepayments/sdk/domain/token_card_data.rb +27 -18
- data/lib/onlinepayments/sdk/domain/token_card_specific_input.rb +20 -18
- data/lib/onlinepayments/sdk/domain/token_data.rb +27 -18
- data/lib/onlinepayments/sdk/domain/token_e_wallet.rb +28 -22
- data/lib/onlinepayments/sdk/domain/token_response.rb +58 -45
- data/lib/onlinepayments/sdk/domain/transaction.rb +20 -18
- data/lib/onlinepayments/sdk/domain/uploadable_file.rb +33 -0
- data/lib/onlinepayments/sdk/domain/validate_credentials_request.rb +37 -0
- data/lib/onlinepayments/sdk/domain/validate_credentials_response.rb +30 -0
- data/lib/onlinepayments/sdk/domain/value_mapping_element.rb +29 -24
- data/lib/onlinepayments/sdk/domain.rb +4 -0
- data/lib/onlinepayments/sdk/exception_factory.rb +76 -0
- data/lib/onlinepayments/sdk/factory.rb +163 -118
- data/lib/onlinepayments/sdk/idempotence_exception.rb +23 -19
- data/lib/onlinepayments/sdk/json/default_marshaller.rb +34 -0
- data/lib/onlinepayments/sdk/json/marshaller.rb +27 -0
- data/lib/onlinepayments/sdk/json/marshaller_syntax_exception.rb +9 -0
- data/lib/onlinepayments/sdk/json.rb +1 -0
- data/lib/onlinepayments/sdk/logging/communicator_logger.rb +18 -16
- data/lib/onlinepayments/sdk/logging/log_message_builder.rb +80 -47
- data/lib/onlinepayments/sdk/logging/logging_capable.rb +1 -1
- data/lib/onlinepayments/sdk/logging/obfuscation/body_obfuscator.rb +113 -0
- data/lib/onlinepayments/sdk/logging/obfuscation/header_obfuscator.rb +54 -0
- data/lib/onlinepayments/sdk/logging/obfuscation/obfuscation_capable.rb +21 -0
- data/lib/onlinepayments/sdk/logging/obfuscation/obfuscation_rule.rb +47 -0
- data/lib/onlinepayments/sdk/logging/obfuscation.rb +1 -0
- data/lib/onlinepayments/sdk/logging/request_log_message_builder.rb +40 -29
- data/lib/onlinepayments/sdk/logging/response_log_message_builder.rb +30 -23
- data/lib/onlinepayments/sdk/logging/ruby_communicator_logger.rb +49 -45
- data/lib/onlinepayments/sdk/logging/stdout_communicator_logger.rb +20 -23
- data/lib/onlinepayments/sdk/logging.rb +1 -10
- data/lib/onlinepayments/sdk/merchant/captures/captures_client.rb +57 -0
- data/lib/onlinepayments/sdk/merchant/captures.rb +4 -0
- data/lib/onlinepayments/sdk/merchant/complete/complete_client.rb +60 -0
- data/lib/onlinepayments/sdk/merchant/complete.rb +4 -0
- data/lib/onlinepayments/sdk/merchant/hostedcheckout/hosted_checkout_client.rb +72 -71
- data/lib/onlinepayments/sdk/merchant/hostedcheckout.rb +4 -0
- data/lib/onlinepayments/sdk/merchant/hostedtokenization/hosted_tokenization_client.rb +72 -71
- data/lib/onlinepayments/sdk/merchant/hostedtokenization.rb +4 -0
- data/lib/onlinepayments/sdk/merchant/mandates/mandates_client.rb +165 -164
- data/lib/onlinepayments/sdk/merchant/mandates.rb +4 -0
- data/lib/onlinepayments/sdk/merchant/merchant_client.rb +116 -64
- data/lib/onlinepayments/sdk/merchant/paymentlinks/payment_links_client.rb +102 -101
- data/lib/onlinepayments/sdk/merchant/paymentlinks.rb +4 -0
- data/lib/onlinepayments/sdk/merchant/payments/payments_client.rb +233 -332
- data/lib/onlinepayments/sdk/merchant/payments.rb +4 -0
- data/lib/onlinepayments/sdk/merchant/payouts/payouts_client.rb +73 -71
- data/lib/onlinepayments/sdk/merchant/payouts.rb +4 -0
- data/lib/onlinepayments/sdk/merchant/privacypolicy/get_privacy_policy_params.rb +32 -0
- data/lib/onlinepayments/sdk/merchant/privacypolicy/privacy_policy_client.rb +54 -0
- data/lib/onlinepayments/sdk/merchant/privacypolicy.rb +4 -0
- data/lib/onlinepayments/sdk/merchant/productgroups/get_product_group_params.rb +50 -47
- data/lib/onlinepayments/sdk/merchant/productgroups/get_product_groups_params.rb +50 -47
- data/lib/onlinepayments/sdk/merchant/productgroups/product_groups_client.rb +72 -72
- data/lib/onlinepayments/sdk/merchant/productgroups.rb +4 -0
- data/lib/onlinepayments/sdk/merchant/products/get_payment_product_networks_params.rb +27 -25
- data/lib/onlinepayments/sdk/merchant/products/get_payment_product_params.rb +50 -47
- data/lib/onlinepayments/sdk/merchant/products/get_payment_products_params.rb +50 -47
- data/lib/onlinepayments/sdk/merchant/products/get_product_directory_params.rb +21 -19
- data/lib/onlinepayments/sdk/merchant/products/products_client.rb +134 -136
- data/lib/onlinepayments/sdk/merchant/products.rb +4 -0
- data/lib/onlinepayments/sdk/merchant/refunds/refunds_client.rb +57 -0
- data/lib/onlinepayments/sdk/merchant/refunds.rb +4 -0
- data/lib/onlinepayments/sdk/merchant/services/services_client.rb +124 -155
- data/lib/onlinepayments/sdk/merchant/services.rb +4 -0
- data/lib/onlinepayments/sdk/merchant/sessions/sessions_client.rb +42 -41
- data/lib/onlinepayments/sdk/merchant/sessions.rb +4 -0
- data/lib/onlinepayments/sdk/merchant/tokens/tokens_client.rb +101 -100
- data/lib/onlinepayments/sdk/merchant/tokens.rb +4 -0
- data/lib/onlinepayments/sdk/merchant/webhooks/webhooks_client.rb +83 -0
- data/lib/onlinepayments/sdk/merchant/webhooks.rb +4 -0
- data/lib/onlinepayments/sdk/merchant.rb +4 -0
- data/lib/onlinepayments/sdk/platform_exception.rb +19 -0
- data/lib/onlinepayments/sdk/proxy_configuration.rb +60 -60
- data/lib/onlinepayments/sdk/reference_exception.rb +14 -9
- data/lib/onlinepayments/sdk/validation_exception.rb +14 -9
- data/lib/onlinepayments/sdk/webhooks/api_version_mismatch_exception.rb +17 -15
- data/lib/onlinepayments/sdk/webhooks/in_memory_secret_key_store.rb +46 -43
- data/lib/onlinepayments/sdk/webhooks/secret_key_not_available_exception.rb +16 -12
- data/lib/onlinepayments/sdk/webhooks/secret_key_store.rb +13 -11
- data/lib/onlinepayments/sdk/webhooks/signature_validation_exception.rb +15 -14
- data/lib/onlinepayments/sdk/webhooks/signature_validator.rb +81 -0
- data/lib/onlinepayments/sdk/webhooks/webhooks_event.rb +84 -53
- data/lib/onlinepayments/sdk/webhooks/webhooks_helper.rb +28 -90
- data/lib/onlinepayments/sdk/webhooks.rb +1 -11
- data/lib/onlinepayments/sdk.rb +4 -26
- data/onlinepayments-sdk-ruby.gemspec +3 -2
- metadata +89 -35
- data/lib/onlinepayments/sdk/authenticator.rb +0 -16
- data/lib/onlinepayments/sdk/communication_exception.rb +0 -16
- data/lib/onlinepayments/sdk/connection.rb +0 -41
- data/lib/onlinepayments/sdk/data_object.rb +0 -31
- data/lib/onlinepayments/sdk/defaultimpl/authorization_type.rb +0 -24
- data/lib/onlinepayments/sdk/defaultimpl/default_authenticator.rb +0 -108
- data/lib/onlinepayments/sdk/defaultimpl/default_connection.rb +0 -365
- data/lib/onlinepayments/sdk/defaultimpl/default_marshaller.rb +0 -32
- data/lib/onlinepayments/sdk/defaultimpl.rb +0 -6
- data/lib/onlinepayments/sdk/endpoint_configuration.rb +0 -127
- data/lib/onlinepayments/sdk/exceptions.rb +0 -8
- data/lib/onlinepayments/sdk/logging/logging_util.rb +0 -286
- data/lib/onlinepayments/sdk/marshaller.rb +0 -24
- data/lib/onlinepayments/sdk/marshaller_syntax_exception.rb +0 -6
- data/lib/onlinepayments/sdk/merchant/services/get_privacy_policy_params.rb +0 -30
- data/lib/onlinepayments/sdk/meta_data_provider.rb +0 -150
- data/lib/onlinepayments/sdk/modules.rb +0 -62
- data/lib/onlinepayments/sdk/multipart_form_data_object.rb +0 -44
- data/lib/onlinepayments/sdk/multipart_form_data_request.rb +0 -9
- data/lib/onlinepayments/sdk/not_found_exception.rb +0 -16
- data/lib/onlinepayments/sdk/param_request.rb +0 -11
- data/lib/onlinepayments/sdk/payment_platform_exception.rb +0 -15
- data/lib/onlinepayments/sdk/pooled_connection.rb +0 -21
- data/lib/onlinepayments/sdk/request_header.rb +0 -50
- data/lib/onlinepayments/sdk/request_param.rb +0 -23
- data/lib/onlinepayments/sdk/response_exception.rb +0 -47
- data/lib/onlinepayments/sdk/response_header.rb +0 -42
- data/lib/onlinepayments/sdk/uploadable_file.rb +0 -30
- data/lib/onlinepayments/sdk/webhooks/webhooks.rb +0 -22
- data/lib/onlinepayments/sdk/webhooks/webhooks_helper_builder.rb +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6dc4e740cbc9653b392253ba2f6266a6ca88f5b2721c029dfc2e11b08c3bea93
|
4
|
+
data.tar.gz: 1d7f251e223133008f132baac2d771a4349744868ce381ab8d294333014beaa9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 206a8aec1a179fb3b3918f20c5e4aad8ff5737087de7194fffa7bc6ee6eaf09d44c5f87ee98f2436dd3b290359518678822367a1b09ef3d76cf1d674e739b4b1
|
7
|
+
data.tar.gz: 93c319108e40291f2f5ae50acbe6df67e1000f77214008b70a81e5c7e1bc030e7286cd4b7139942bae39249139b6bdf398b57b7d526cc81bdad5ff5e014a2143
|
data/Gemfile
CHANGED
File without changes
|
data/LICENSE.txt
CHANGED
File without changes
|
data/README.md
CHANGED
@@ -8,7 +8,7 @@ The Ruby SDK helps you to communicate with the payment platform server API. Its
|
|
8
8
|
* marshalls Ruby request objects to HTTP requests
|
9
9
|
* unmarshalls HTTP responses to Ruby response objects or Ruby exceptions
|
10
10
|
* handling of all the details concerning authentication
|
11
|
-
* handling of required
|
11
|
+
* handling of required metadata
|
12
12
|
|
13
13
|
Its use is demonstrated by an example for each possible call. The examples execute a call using the provided API keys.
|
14
14
|
|
@@ -80,11 +80,9 @@ After the Ruby SDK has been installed, it can be required in Ruby program as fol
|
|
80
80
|
|
81
81
|
There are two types of tests: unit tests and integration tests. The unit tests will work out-of-the-box; for the integration tests some configuration is required.
|
82
82
|
First, some environment variables need to be set:
|
83
|
-
|
84
|
-
* `
|
85
|
-
* `onlinePayments_api_secretApiKey` for the secret API key to use. This can be retrieved from the Configuration Center.
|
83
|
+
* `onlinePayments_api_v1hmac_apiKeyId` for the API key id to use. This can be retrieved from the Configuration Center.
|
84
|
+
* `onlinePayments_api_v1hmac_secretApiKey` for the secret API key to use. This can be retrieved from the Configuration Center.
|
86
85
|
* `onlinePayments_api_merchantId` for your merchant ID.
|
87
|
-
|
88
86
|
In addition, to run the proxy integration tests, the proxy URI, username and password should be set in the `spec/fixtures/resources/properties.proxy.yml` file.
|
89
87
|
|
90
88
|
In order to run the unit and integration tests, some additional dependencies are required:
|
@@ -92,7 +90,8 @@ In order to run the unit and integration tests, some additional dependencies are
|
|
92
90
|
* [rake](https://ruby.github.io/rake/) 12.3.3 or higher
|
93
91
|
* [rspec](https://github.com/rspec/rspec) 3.5 or higher
|
94
92
|
* [webmock](https://github.com/bblimke/webmock) 2.1 or higher
|
95
|
-
* [sinatra](https://github.com/sinatra/sinatra) 1
|
93
|
+
* [sinatra](https://github.com/sinatra/sinatra) 2.1 or higher
|
94
|
+
* [webrick](https://github.com/ruby/webrick) 1.7 or higher
|
96
95
|
|
97
96
|
They can be installed using the following command:
|
98
97
|
|
data/Rakefile
CHANGED
File without changes
|
@@ -1,42 +1,54 @@
|
|
1
|
-
|
1
|
+
#
|
2
|
+
# This file was automatically generated.
|
3
|
+
#
|
4
|
+
require 'onlinepayments/sdk/domain/api_error'
|
2
5
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
#
|
7
|
-
# @attr_reader [Integer] status_code HTTP status code of the returned response.
|
8
|
-
# @attr_reader [String] response_body Message body of the returned response.
|
9
|
-
# @attr_reader [String] error_id An error id corresponding to the error that occurred, if available.
|
10
|
-
# @attr_reader [Array<OnlinePayments::SDK::Domain::APIError>] errors A list of errors received from the Online Payments platform;
|
11
|
-
# may be empty but never _nil_
|
12
|
-
class ApiException < RuntimeError
|
13
|
-
|
14
|
-
# Creates a new ApiException that reports an error response from the Online Payments platform.
|
6
|
+
module OnlinePayments
|
7
|
+
module SDK
|
8
|
+
# Represents an error response from the payment platform which contains an ID and a list of errors.
|
15
9
|
#
|
16
|
-
# @
|
17
|
-
# @
|
18
|
-
# @
|
19
|
-
# @
|
20
|
-
#
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
@
|
26
|
-
@
|
27
|
-
@
|
28
|
-
|
10
|
+
# @attr_reader [Integer] status_code HTTP status code of the returned response.
|
11
|
+
# @attr_reader [String] response_body Message body of the returned response.
|
12
|
+
# @attr_reader [String] error_id The _errorId_ received from the Payment platform if available.
|
13
|
+
# @attr_reader [Array<OnlinePayments::SDK::Domain::APIError>] errors The _errors_ received from the Payment platform if available;
|
14
|
+
# may be empty but never _nil_
|
15
|
+
class ApiException < RuntimeError
|
16
|
+
|
17
|
+
# Creates a new ApiException that reports an error response from the Payment platform.
|
18
|
+
#
|
19
|
+
# @param status_code (Integer) HTTP status code the response
|
20
|
+
# @param response_body (String) HTTP response body
|
21
|
+
# @param error_id (String) The _errorId_ received from the Payment platform
|
22
|
+
# @param errors (Array<OnlinePayments::SDK::Domain::APIError>) The _errors_ received from the Payment platform
|
23
|
+
# @param message (String) error message to include
|
24
|
+
def initialize(status_code, response_body, error_id, errors,
|
25
|
+
message='the payment platform returned an error response')
|
26
|
+
super(message)
|
27
|
+
@status_code = status_code
|
28
|
+
@response_body = response_body
|
29
|
+
@error_id = error_id
|
30
|
+
if errors.nil?
|
31
|
+
@errors = [].freeze
|
32
|
+
else
|
33
|
+
@errors = errors
|
34
|
+
end
|
35
|
+
end
|
29
36
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
37
|
+
attr_reader :status_code
|
38
|
+
attr_reader :response_body
|
39
|
+
attr_reader :error_id
|
40
|
+
attr_reader :errors
|
34
41
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
42
|
+
def to_s
|
43
|
+
str = super.to_s
|
44
|
+
if @status_code > 0
|
45
|
+
str += '; status_code=' + @status_code.to_s
|
46
|
+
end
|
47
|
+
if !@response_body.nil? && @response_body.length > 0
|
48
|
+
str += "; response_body='" + @response_body + "'"
|
49
|
+
end
|
50
|
+
str.to_s
|
51
|
+
end
|
40
52
|
end
|
41
53
|
end
|
42
54
|
end
|
@@ -1,115 +1,67 @@
|
|
1
|
-
require 'onlinepayments/sdk/
|
1
|
+
require 'onlinepayments/sdk/communication/request_header'
|
2
2
|
|
3
|
-
module OnlinePayments
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
#
|
8
|
-
# @attr_reader [OnlinePayments::SDK::Communicator] communicator Communicator instance that provides communication with the Online Payments platform.
|
9
|
-
# @attr_reader [String] client_meta_info JSON string containing client info specific to the current client.
|
10
|
-
class ApiResource
|
11
|
-
|
12
|
-
# Creates a new ApiResource.
|
3
|
+
module OnlinePayments
|
4
|
+
module SDK
|
5
|
+
# Base class of all Online Payments platform API resources.
|
6
|
+
# Provides shared functionality to facilitate communication with the Online Payments platform.
|
13
7
|
#
|
14
|
-
# @
|
15
|
-
#
|
16
|
-
|
17
|
-
# This hash will be used to instantiate a concrete URL used to access specific resources.
|
18
|
-
# For example in the URL https://payment.preprod.online-payments.com/!{version}/!{merchantId}/payments
|
19
|
-
# !{version} and !{merchantId} can be instantiated using the hash
|
20
|
-
# !{'version' => 'v2', 'merchantId' => '1'}. The final URL in this case will be
|
21
|
-
# https://payment.preprod.online-payments.com/v2/1/payments.
|
22
|
-
# @param client_meta_info [String, nil] JSON string containing the meta data for the client.
|
23
|
-
def initialize(arg, path_context = nil, client_meta_info = false)
|
24
|
-
if client_meta_info == false
|
25
|
-
raise ArgumentError, 'parent is required' unless arg
|
8
|
+
# @attr_reader [OnlinePayments::SDK::Communicator] communicator Communicator instance that provides communication with the Online Payments platform.
|
9
|
+
# @attr_reader [String] client_meta_info JSON string containing client info specific to the current client.
|
10
|
+
class ApiResource
|
26
11
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
12
|
+
# Creates a new ApiResource.
|
13
|
+
#
|
14
|
+
# @param parent [OnlinePayments::SDK::ApiResource] parent resource instance.
|
15
|
+
# @param communicator [OnlinePayments::SDK::Communicator] Communicator instance.
|
16
|
+
# @param path_context [Hash] hash that contains substitutions for generic locations in the URL path.
|
17
|
+
# This hash will be used to instantiate a concrete URL used to access specific resources.
|
18
|
+
# @param client_meta_info [String] JSON string containing the metadata for the client.
|
19
|
+
def initialize(parent: nil, communicator: nil, path_context: nil, client_meta_info: nil)
|
20
|
+
raise ArgumentError.new('parent and/or communicator is required') if parent.nil? and communicator.nil?
|
21
|
+
@parent = parent
|
22
|
+
@communicator = communicator.nil? ? parent.communicator : communicator
|
23
|
+
@path_context = path_context
|
24
|
+
@client_meta_info = client_meta_info || parent.nil? ? client_meta_info : parent.client_meta_info
|
36
25
|
end
|
37
|
-
@path_context = path_context
|
38
|
-
end
|
39
26
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
protected
|
44
|
-
|
45
|
-
# @return [Array<OnlinePayments::SDK::RequestHeader>, nil] the X-GCS-ClientMetaInfo header.
|
46
|
-
def client_headers
|
47
|
-
@client_meta_info ?
|
48
|
-
[RequestHeader.new('X-GCS-ClientMetaInfo', @client_meta_info)] :
|
49
|
-
nil
|
50
|
-
end
|
27
|
+
attr_reader :communicator
|
28
|
+
attr_reader :client_meta_info
|
51
29
|
|
52
|
-
|
53
|
-
uri = replace_all(uri, path_context) if path_context
|
54
|
-
uri = replace_all(uri, @path_context)
|
55
|
-
@parent ? @parent.instantiate_uri(uri) : uri
|
56
|
-
end
|
30
|
+
protected
|
57
31
|
|
58
|
-
|
59
|
-
if
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
elsif error_object.is_a?(OnlinePayments::SDK::Domain::RefundErrorResponse) && error_object.refund_result
|
67
|
-
return DeclinedRefundException.new(status_code, response_body, error_object)
|
68
|
-
elsif error_object.is_a?(OnlinePayments::SDK::Domain::PaymentErrorResponse) ||
|
69
|
-
error_object.is_a?(OnlinePayments::SDK::Domain::PayoutErrorResponse) ||
|
70
|
-
error_object.is_a?(OnlinePayments::SDK::Domain::RefundErrorResponse) ||
|
71
|
-
error_object.is_a?(OnlinePayments::SDK::Domain::ErrorResponse)
|
72
|
-
error_id = error_object.error_id
|
73
|
-
errors = error_object.errors
|
74
|
-
else
|
75
|
-
raise ArgumentError, "unsupported error object type: #{error_object.class.name}"
|
32
|
+
# @return [Array<OnlinePayments::SDK::Communication::RequestHeader>, nil] the client headers,
|
33
|
+
# including the X-GCS-ClientMetaInfo header if metadata for the client is available
|
34
|
+
def client_headers
|
35
|
+
if @client_meta_info.nil?
|
36
|
+
nil
|
37
|
+
else
|
38
|
+
[Communication::RequestHeader.new('X-GCS-ClientMetaInfo', @client_meta_info)]
|
39
|
+
end
|
76
40
|
end
|
77
41
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
return AuthorizationException.new(status_code, response_body, error_id, errors)
|
83
|
-
when 404, 410
|
84
|
-
return ReferenceException.new(status_code, response_body, error_id, errors)
|
85
|
-
when 409
|
86
|
-
if is_idempotence_error(errors, context)
|
87
|
-
idempotence_key = context.idempotence_key
|
88
|
-
idempotence_request_timestamp = context.idempotence_request_timestamp
|
89
|
-
return IdempotenceException.new(status_code, response_body, error_id,
|
90
|
-
errors, idempotence_key,
|
91
|
-
idempotence_request_timestamp)
|
42
|
+
def instantiate_uri(uri, path_context = nil)
|
43
|
+
if path_context
|
44
|
+
uri = replace_all(uri, path_context)
|
45
|
+
instantiate_uri(uri)
|
92
46
|
else
|
93
|
-
|
47
|
+
uri = replace_all(uri, @path_context)
|
48
|
+
unless @parent.nil?
|
49
|
+
uri = @parent.instantiate_uri(uri)
|
50
|
+
end
|
51
|
+
uri
|
94
52
|
end
|
95
|
-
when 500, 502, 503
|
96
|
-
return PaymentPlatformException.new(status_code, response_body, error_id, errors)
|
97
|
-
else
|
98
|
-
return ApiException.new(status_code, response_body, error_id, errors)
|
99
53
|
end
|
100
|
-
end
|
101
54
|
|
102
|
-
|
55
|
+
private
|
103
56
|
|
104
|
-
|
105
|
-
|
106
|
-
|
57
|
+
def replace_all(uri, path_context)
|
58
|
+
if path_context
|
59
|
+
path_context.each do |key, value|
|
60
|
+
uri = uri.gsub('{' + key + '}', value)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
uri
|
107
64
|
end
|
108
|
-
uri
|
109
|
-
end
|
110
|
-
|
111
|
-
def is_idempotence_error(errors, context)
|
112
|
-
context&.idempotence_key && errors.length == 1 && errors[0].code == '1409'
|
113
65
|
end
|
114
66
|
end
|
115
67
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module OnlinePayments
|
2
|
+
module SDK
|
3
|
+
module Authentication
|
4
|
+
# Abstract class that is responsible for authenticating requests sent to the Online Payments platform.
|
5
|
+
class Authenticator
|
6
|
+
|
7
|
+
# Returns a value that can be used for the "Authorization" header.
|
8
|
+
#
|
9
|
+
# @param http_method [String] 'GET', 'PUT', 'POST' or 'DELETE' indicating which HTTP method will be used with the request
|
10
|
+
# @param resource_uri [URI::HTTP] URI object that includes #path and #query of the URL that will be used, #query may be *nil*
|
11
|
+
# @param request_headers [Array<OnlinePayments::SDK::Communication::RequestHeader>] all headers used by the request
|
12
|
+
# @return [String] the "Authorization" header value
|
13
|
+
def get_authorization(http_method, resource_uri, request_headers)
|
14
|
+
raise NotImplementedError
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module OnlinePayments
|
2
|
+
module SDK
|
3
|
+
module Authentication
|
4
|
+
# Contains all authentication schemes supported by the Online Payments platform.
|
5
|
+
class AuthorizationType
|
6
|
+
V1HMAC = "v1HMAC".freeze
|
7
|
+
|
8
|
+
# @return [String] the authorization string that belongs to the parameter _authorization_, or _nil_ if not found.
|
9
|
+
def self.get_authorization(authorization)
|
10
|
+
authorization if authorization == 'v1HMAC'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
require 'openssl'
|
2
|
+
require 'base64'
|
3
|
+
|
4
|
+
require 'onlinepayments/sdk/authentication/authenticator'
|
5
|
+
require 'onlinepayments/sdk/communication/default_connection'
|
6
|
+
require 'onlinepayments/sdk/communication/request_header'
|
7
|
+
|
8
|
+
module OnlinePayments
|
9
|
+
module SDK
|
10
|
+
module Authentication
|
11
|
+
# Authenticates requests made to the Online Payments platform using V1Hmac.
|
12
|
+
class V1HmacAuthenticator < Authenticator
|
13
|
+
|
14
|
+
# HMAC algorithm used to generate the signature
|
15
|
+
HMAC_ALGOR = 'SHA256'.freeze
|
16
|
+
CONTENT_TYPE = 'Content-Type'.freeze
|
17
|
+
DATE = 'Date'.freeze
|
18
|
+
XGCS = 'x-gcs'.freeze
|
19
|
+
|
20
|
+
# Constructs a new V1HmacAuthenticator instance using the provided CommunicatorConfiguration.
|
21
|
+
#
|
22
|
+
# @param communicator_configuration [OnlinePayments::SDK::CommunicatorConfiguration] The configuration object
|
23
|
+
# containing the V1Hmac authorization id and authorization secret,
|
24
|
+
# connection timeout, and socket timeout. None of these can be _nil_ or empty,
|
25
|
+
# and the timeout values must be positive.
|
26
|
+
def initialize(communicator_configuration)
|
27
|
+
raise ArgumentError unless communicator_configuration.api_key_id and not communicator_configuration.api_key_id.strip.empty?
|
28
|
+
raise ArgumentError unless communicator_configuration.secret_api_key and not communicator_configuration.secret_api_key.strip.empty?
|
29
|
+
|
30
|
+
@api_key_id = communicator_configuration.api_key_id
|
31
|
+
@secret_api_key = communicator_configuration.secret_api_key
|
32
|
+
@authorization_type = communicator_configuration.authorization_type
|
33
|
+
end
|
34
|
+
|
35
|
+
# @param http_method [String, nil] 'GET', 'PUT', 'POST' or 'DELETE' indicating which HTTP method will be used with the request
|
36
|
+
# @param resource_uri [URI::HTTP, nil] URI object that includes #path and #query of the URL that will be used, #query may be *nil*
|
37
|
+
# @param request_headers [Array<OnlinePayments::SDK::Communication::RequestHeader>, nil] all headers used by the request
|
38
|
+
def get_authorization(http_method, resource_uri, request_headers)
|
39
|
+
raise ArgumentError unless http_method && !http_method.strip.empty?
|
40
|
+
raise ArgumentError unless resource_uri
|
41
|
+
|
42
|
+
data_to_sign = to_data_to_sign(http_method, resource_uri, request_headers)
|
43
|
+
"GCS #{@authorization_type}:#{@api_key_id}:#{create_auth_signature(data_to_sign)}"
|
44
|
+
end
|
45
|
+
|
46
|
+
protected
|
47
|
+
|
48
|
+
# Canonizes the _http_method_, _resource_uri_ and _http_headers_ so a unique signature can be generated.
|
49
|
+
# Canonical form is as follows:
|
50
|
+
# * _http_method_ in upper case
|
51
|
+
# * Content-Type
|
52
|
+
# * Date header
|
53
|
+
# * X-GCS headers sorted alphabetically. Names are in lowercase and values are stripped of excess whitespace
|
54
|
+
# * path and query portion of the uri, separated by a question mark
|
55
|
+
def to_data_to_sign(http_method, resource_uri, http_headers)
|
56
|
+
content_type = ''
|
57
|
+
date = ''
|
58
|
+
canonical_resource = to_canonical_resource(resource_uri)
|
59
|
+
xgc_http_headers = []
|
60
|
+
|
61
|
+
http_headers&.each do |header|
|
62
|
+
name = header.name
|
63
|
+
value = header.value
|
64
|
+
case
|
65
|
+
when name.casecmp(CONTENT_TYPE).zero?
|
66
|
+
content_type = value
|
67
|
+
when name.casecmp(DATE).zero?
|
68
|
+
date = value
|
69
|
+
when to_canonical_header_name(name).start_with?("x-gcs")
|
70
|
+
xgc_http_headers << [to_canonical_header_name(name), to_canonical_header_value(value)]
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
xgc_http_headers.sort! { |(h1, v1), (h2, v2)| h1 <=> h2 } unless xgc_http_headers.empty?
|
75
|
+
|
76
|
+
data = "#{http_method.upcase}\n#{content_type}\n#{date}\n"
|
77
|
+
data << xgc_http_headers.inject('') { |s, (k, v)| "#{s}#{k}:#{v}\n" } unless xgc_http_headers.empty?
|
78
|
+
data << "#{canonical_resource}\n" if canonical_resource
|
79
|
+
end
|
80
|
+
|
81
|
+
# Applies the HMAC algorithm to the canonicalized data to obtain an HMAC digest.
|
82
|
+
# Afterwards the HMAC digest is encoded using base64 encoding.
|
83
|
+
def create_auth_signature(data_to_sign)
|
84
|
+
digest = OpenSSL::Digest.new(HMAC_ALGOR)
|
85
|
+
hmac = OpenSSL::HMAC.digest(digest, @secret_api_key, data_to_sign)
|
86
|
+
Base64.strict_encode64(hmac).strip
|
87
|
+
end
|
88
|
+
|
89
|
+
private
|
90
|
+
|
91
|
+
# Returns the encoded URI path without the HTTP method and including all decoded query parameters.
|
92
|
+
def to_canonical_resource(resource_uri)
|
93
|
+
return "#{resource_uri.path}?#{resource_uri.query}" if resource_uri.query
|
94
|
+
resource_uri.path
|
95
|
+
end
|
96
|
+
|
97
|
+
def to_canonical_header_name(original_name)
|
98
|
+
original_name ? original_name.downcase : original_name
|
99
|
+
end
|
100
|
+
|
101
|
+
# Strips a header value of excess whitespace to produce a canonical value
|
102
|
+
def to_canonical_header_value(original_value)
|
103
|
+
return '' unless original_value
|
104
|
+
original_value.gsub(/\r?\n[\s&&[^\r\n]]*/, ' ').strip
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
Dir[File.join(__dir__, 'authentication', '*.rb')].each { |f| require f }
|
@@ -1,13 +1,19 @@
|
|
1
|
-
|
1
|
+
#
|
2
|
+
# This file was automatically generated.
|
3
|
+
#
|
4
|
+
require_relative 'api_exception'
|
2
5
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
6
|
+
module OnlinePayments
|
7
|
+
module SDK
|
8
|
+
# Represents an error response from the payment platform when authorization failed.
|
9
|
+
class AuthorizationException < ApiException
|
7
10
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
+
# Create a new AuthorizationException.
|
12
|
+
# @see ApiException#initialize
|
13
|
+
def initialize(status_code, response_body, error_id, errors,
|
14
|
+
message='the payment platform returned an authorization error response')
|
15
|
+
super(status_code, response_body, error_id, errors, message)
|
16
|
+
end
|
11
17
|
end
|
12
18
|
end
|
13
19
|
end
|
@@ -1,26 +1,35 @@
|
|
1
|
-
|
1
|
+
require 'date'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
@
|
3
|
+
module OnlinePayments
|
4
|
+
module SDK
|
5
|
+
# A CallContext is used to identify requests and manage idempotent requests.
|
6
|
+
# A CallContext contains the following:
|
7
|
+
#
|
8
|
+
# idempotence_key:: A randomly generated key used to identify requests
|
9
|
+
# idempotence_request_timestamp:: If a previous request arrived with the same idempotence key,
|
10
|
+
# this value will be set to a timestamp of that request.
|
11
|
+
# idempotence_response_date_time:: If a previous request arrived with the same idempotence key,
|
12
|
+
# this value will be set to the date/time of the first response.
|
13
|
+
#
|
14
|
+
# @attr_reader [String] idempotence_key The idempotence key used to identify this request.
|
15
|
+
# If two requests share the same _idempotence_key_, they are considered to be the same request
|
16
|
+
# and only the first request will be processed.
|
17
|
+
# @attr [Integer] idempotence_request_timestamp If two or more requests arrive at the Online Payments platform with the same _idempotence_key_,
|
18
|
+
# the _idempotence_request_timestamp_ will be set to the arrival time of the first of these requests.
|
19
|
+
# @attr [DateTime] idempotence_response_date_time If two or more requests arrive at the Online Payments platform with the same _idempotence_key_,
|
20
|
+
# the _idempotence_response_date_time_ will be set to the response date/time of the first response.
|
21
|
+
class CallContext
|
22
|
+
@idempotence_key = nil
|
23
|
+
@idempotence_request_timestamp = nil
|
24
|
+
@idempotence_response_date_time = nil
|
18
25
|
|
19
|
-
|
20
|
-
|
21
|
-
|
26
|
+
def initialize(idempotence_key = nil)
|
27
|
+
@idempotence_key = idempotence_key
|
28
|
+
end
|
22
29
|
|
23
|
-
|
24
|
-
|
30
|
+
attr_reader :idempotence_key
|
31
|
+
attr_accessor :idempotence_request_timestamp
|
32
|
+
attr_accessor :idempotence_response_date_time
|
33
|
+
end
|
25
34
|
end
|
26
35
|
end
|
@@ -1,15 +1,17 @@
|
|
1
1
|
#
|
2
|
-
# This
|
2
|
+
# This file was automatically generated.
|
3
3
|
#
|
4
|
+
require 'base64'
|
5
|
+
|
4
6
|
require 'onlinepayments/sdk/api_resource'
|
5
|
-
require 'onlinepayments/sdk/data_object'
|
7
|
+
require 'onlinepayments/sdk/domain/data_object'
|
6
8
|
require 'onlinepayments/sdk/logging/logging_capable'
|
9
|
+
require 'onlinepayments/sdk/logging/obfuscation/obfuscation_capable'
|
7
10
|
require 'onlinepayments/sdk/merchant/merchant_client'
|
8
|
-
require 'base64'
|
9
11
|
|
10
12
|
module OnlinePayments
|
11
13
|
module SDK
|
12
|
-
#
|
14
|
+
# Payment platform client.
|
13
15
|
#
|
14
16
|
# This client and all its child clients are bound to one specific value for the X-GCS-ClientMetaInfo header.
|
15
17
|
#
|
@@ -18,29 +20,32 @@ module OnlinePayments
|
|
18
20
|
# Thread safe.
|
19
21
|
class Client < ApiResource
|
20
22
|
include Logging::LoggingCapable
|
21
|
-
|
22
|
-
# @return [String]
|
23
|
-
def self.API_VERSION
|
24
|
-
'v2'
|
25
|
-
end
|
23
|
+
include Logging::Obfuscation::ObfuscationCapable
|
26
24
|
|
27
25
|
# @param communicator [OnlinePayments::SDK::Communicator]
|
28
26
|
# @param client_meta_info [String, nil]
|
29
27
|
def initialize(communicator, client_meta_info = nil)
|
30
|
-
super(communicator
|
28
|
+
super(communicator: communicator, client_meta_info: client_meta_info)
|
31
29
|
end
|
32
30
|
|
33
|
-
# @param client_meta_info [String
|
34
|
-
# @return [OnlinePayments::SDK::Client] a Client which uses the passed
|
35
|
-
# @raise [OnlinePayments::SDK::MarshallerSyntaxException] if the given clientMetaInfo is not a valid JSON string
|
31
|
+
# @param client_meta_info [String] JSON string containing the metadata for the client
|
32
|
+
# @return [OnlinePayments::SDK::Client] a Client which uses the passed metadata for the X-GCS-ClientMetaInfo header.
|
33
|
+
# @raise [OnlinePayments::SDK::JSON::MarshallerSyntaxException] if the given clientMetaInfo is not a valid JSON string
|
36
34
|
def with_client_meta_info(client_meta_info)
|
37
|
-
if client_meta_info
|
35
|
+
if @client_meta_info.nil? && client_meta_info.nil?
|
36
|
+
self
|
37
|
+
elsif client_meta_info.nil?
|
38
|
+
return Client.new(@communicator, nil)
|
39
|
+
else
|
38
40
|
# Checking to see if this is valid JSON (no JSON parse exceptions)
|
39
41
|
@communicator.marshaller.unmarshal(client_meta_info, DataObject)
|
40
42
|
client_meta_info = Base64.strict_encode64(client_meta_info)
|
41
|
-
|
43
|
+
if @client_meta_info == client_meta_info
|
44
|
+
self
|
45
|
+
else
|
46
|
+
return Client.new(@communicator, client_meta_info)
|
47
|
+
end
|
42
48
|
end
|
43
|
-
@client_meta_info ? Client.new(@communicator) : self
|
44
49
|
end
|
45
50
|
|
46
51
|
# Utility method that delegates the call to this client's communicator.
|
@@ -53,6 +58,18 @@ module OnlinePayments
|
|
53
58
|
@communicator.close_expired_connections
|
54
59
|
end
|
55
60
|
|
61
|
+
# Sets the current body obfuscator to use.
|
62
|
+
# @param body_obfuscator [OnlinePayments::SDK::Logging::Obfuscation::BodyObfuscator]
|
63
|
+
def set_body_obfuscator(body_obfuscator)
|
64
|
+
@communicator.set_body_obfuscator(body_obfuscator)
|
65
|
+
end
|
66
|
+
|
67
|
+
# Sets the current header obfuscator to use.
|
68
|
+
# @param header_obfuscator [OnlinePayments::SDK::Logging::Obfuscation::HeaderObfuscator]
|
69
|
+
def set_header_obfuscator(header_obfuscator)
|
70
|
+
@communicator.set_header_obfuscator(header_obfuscator)
|
71
|
+
end
|
72
|
+
|
56
73
|
# Turns on logging using the given communicator logger.
|
57
74
|
# @param communicator_logger [OnlinePayments::SDK::Logging::CommunicatorLogger]
|
58
75
|
def enable_logging(communicator_logger)
|
@@ -69,12 +86,13 @@ module OnlinePayments
|
|
69
86
|
@communicator.close
|
70
87
|
end
|
71
88
|
|
72
|
-
# Resource /v2
|
89
|
+
# Resource /v2/{merchantId}
|
90
|
+
#
|
73
91
|
# @param merchant_id [String]
|
74
92
|
# @return [OnlinePayments::SDK::Merchant::MerchantClient]
|
75
93
|
def merchant(merchant_id)
|
76
94
|
OnlinePayments::SDK::Merchant::MerchantClient.new(self, {
|
77
|
-
'merchantId'.freeze => merchant_id
|
95
|
+
'merchantId'.freeze => merchant_id,
|
78
96
|
})
|
79
97
|
end
|
80
98
|
end
|