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
@@ -1,365 +0,0 @@
|
|
1
|
-
require 'securerandom'
|
2
|
-
require 'uri'
|
3
|
-
require 'httpclient'
|
4
|
-
require 'onlinepayments/sdk/multipart_form_data_object'
|
5
|
-
require 'onlinepayments/sdk/pooled_connection'
|
6
|
-
require 'onlinepayments/sdk/communication_exception'
|
7
|
-
require 'onlinepayments/sdk/response_header'
|
8
|
-
|
9
|
-
# @private :nodoc: this is not our class
|
10
|
-
module RefineHTTPClient
|
11
|
-
refine HTTPClient do
|
12
|
-
# (monkey) patch to gain access to the session pool size in HTTPClient
|
13
|
-
def session_count
|
14
|
-
sess_pool = @session_manager.instance_variable_get(:@sess_pool)
|
15
|
-
sess_pool.size
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
module OnlinePayments::SDK
|
21
|
-
module DefaultImpl
|
22
|
-
class DefaultConnection < PooledConnection
|
23
|
-
using RefineHTTPClient
|
24
|
-
|
25
|
-
CONTENT_TYPE = 'Content-Type'.freeze
|
26
|
-
X_REQUEST_ID_HEADER = 'X-Request-Id'.freeze
|
27
|
-
JSON_CONTENT_TYPE = 'application/json'.freeze
|
28
|
-
|
29
|
-
# @param args [Hash] the parameters to initialize the connection with
|
30
|
-
# @option args [Integer] :connect_timeout connection timeout in seconds.
|
31
|
-
# Uses {CommunicatorConfiguration.default_connect_timeout} if not given.
|
32
|
-
# @option args [Integer] :socket_timeout socket timeout in seconds.
|
33
|
-
# Uses {CommunicatorConfiguration.default_socket_timeout} if not given.
|
34
|
-
# @option args [Integer] :max_connections number of connections kept alive in the thread pool.
|
35
|
-
# Uses {CommunicatorConfiguration.default_max_connections} if not given.
|
36
|
-
# @option args [Hash] :proxy_configuration object that stores the proxy to use.
|
37
|
-
# If not given the system default proxy is used;
|
38
|
-
# if there is no system default proxy set either, no proxy is used.
|
39
|
-
def initialize(args)
|
40
|
-
raise ArgumentError unless args.is_a? Hash
|
41
|
-
|
42
|
-
super()
|
43
|
-
|
44
|
-
# Set timeouts to nil if they are negative
|
45
|
-
@connect_timeout = args[:connect_timeout] || CommunicatorConfiguration.default_connect_timeout
|
46
|
-
@connect_timeout = nil unless @connect_timeout&.positive?
|
47
|
-
@socket_timeout = args[:socket_timeout] || CommunicatorConfiguration.default_socket_timeout
|
48
|
-
@socket_timeout = nil unless @socket_timeout&.positive?
|
49
|
-
@max_connections = args[:max_connections] || CommunicatorConfiguration.default_max_connections
|
50
|
-
@proxy_configuration = args[:proxy_configuration]
|
51
|
-
|
52
|
-
# HTTPClient provides the following features:
|
53
|
-
# 1) thread safe, an instance can be used by multiple threads without
|
54
|
-
# explicit synchronization
|
55
|
-
# 2) use persistent connection if HTTP 1.1 is supported. The connection
|
56
|
-
# will be left open until explicitly closed or keep_alive_timeout
|
57
|
-
# 3) a built-in connection pool with no limit for max connections
|
58
|
-
@http_client = create_http_client
|
59
|
-
@http_client.connect_timeout = @connect_timeout
|
60
|
-
@http_client.send_timeout = @socket_timeout
|
61
|
-
@http_client.receive_timeout = @socket_timeout
|
62
|
-
end
|
63
|
-
|
64
|
-
private
|
65
|
-
|
66
|
-
# Create a HTTPClient instance that uses @proxy_configuration or the system proxy if @proxy_configuration is not set
|
67
|
-
def create_http_client
|
68
|
-
if @proxy_configuration
|
69
|
-
httpclient = HTTPClient.new(@proxy_configuration.proxy_uri)
|
70
|
-
httpclient.set_proxy_auth(@proxy_configuration.username, @proxy_configuration.password)
|
71
|
-
httpclient.force_basic_auth = true if @proxy_configuration.username && @proxy_configuration.password
|
72
|
-
else
|
73
|
-
# use system settings
|
74
|
-
proxy_string = ENV['https_proxy'] || ENV['http_proxy']
|
75
|
-
# proxy string format = 'http://username:password@hostname:port'
|
76
|
-
proxy_string =~ %r{https?//(?<username>[^:]):(?<password>[^@])@.*}
|
77
|
-
username = Regexp.last_match(1)
|
78
|
-
password = Regexp.last_match(2)
|
79
|
-
httpclient = HTTPClient.new(proxy_string)
|
80
|
-
httpclient.set_proxy_auth(username, password) if username && password
|
81
|
-
httpclient.force_basic_auth = true if username && password
|
82
|
-
end
|
83
|
-
httpclient
|
84
|
-
end
|
85
|
-
|
86
|
-
public
|
87
|
-
|
88
|
-
# Closes all connections idle for longer than _idle_time_ seconds.
|
89
|
-
# In addition, the keep_alive_timeout is set to _idle_time_
|
90
|
-
# so any future connections idle for longer than _idle_time_ seconds will also be closed.
|
91
|
-
def close_idle_connections(idle_time)
|
92
|
-
# in sec
|
93
|
-
@http_client.keep_alive_timeout = idle_time # set timeout value
|
94
|
-
close_expired_connections
|
95
|
-
end
|
96
|
-
|
97
|
-
# HTTPClient automatically closes expired connections so _close_expired_connections_ is a no-operation.
|
98
|
-
def close_expired_connections
|
99
|
-
# By default the keep alive timeout is 15 sec, which is the HTTP 1.1
|
100
|
-
# standard. To change the value, use keep_alive_timeout= method
|
101
|
-
# do nothing, handled by HTTPClient
|
102
|
-
end
|
103
|
-
|
104
|
-
# Frees all networking resources used.
|
105
|
-
def close
|
106
|
-
@http_client.reset_all
|
107
|
-
end
|
108
|
-
|
109
|
-
# Returns the number of open connections
|
110
|
-
def session_count
|
111
|
-
@http_client.session_count
|
112
|
-
end
|
113
|
-
|
114
|
-
# Performs a GET request to the Online Payments platform
|
115
|
-
# @see request
|
116
|
-
def get(uri, request_headers)
|
117
|
-
request('get', uri, request_headers) do |response_status_code, response_headers, response_body|
|
118
|
-
yield response_status_code, response_headers, response_body
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
# Performs a DELETE request to the Online Payments platform
|
123
|
-
# @see request
|
124
|
-
def delete(uri, request_headers)
|
125
|
-
request('delete', uri, request_headers) do |response_status_code, response_headers, response_body|
|
126
|
-
yield response_status_code, response_headers, response_body
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
# Performs a POST request to the Online Payments platform
|
131
|
-
# @see request
|
132
|
-
def post(uri, request_headers, body)
|
133
|
-
request('post', uri, request_headers, body) do |response_status_code, response_headers, response_body|
|
134
|
-
yield response_status_code, response_headers, response_body
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
# Performs a PUT request to the Online Payments platform
|
139
|
-
# @see request
|
140
|
-
def put(uri, request_headers, body)
|
141
|
-
request('put', uri, request_headers, body) do |response_status_code, response_headers, response_body|
|
142
|
-
yield response_status_code, response_headers, response_body
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
# Performs a HTTP request and yields the response as the status code, headers and body.
|
147
|
-
# Also ensures the request is logged when sent and its response is logged when received.
|
148
|
-
#
|
149
|
-
# @param method [String] 'GET', 'DELETE', 'POST' or 'PUT' depending on the HTTP method being used.
|
150
|
-
# @param uri [URI::HTTP] full URI of the location the request is targeted at, including query parameters.
|
151
|
-
# @param request_headers [Array<OnlinePayments::SDK::RequestHeader>] list of headers that should be used as HTTP headers in the request.
|
152
|
-
# @param body [String, OnlinePayments::SDK::MultipartFormDataObject] request body.
|
153
|
-
# @yield (Integer, Array<OnlinePayments::SDK::ResponseHeader>, IO) The status code, headers and body of the response.
|
154
|
-
# @raise [OnlinePayments::SDK::CommunicationException] when communication with the Online Payments platform was not successful.
|
155
|
-
def request(method, uri, request_headers, body = nil)
|
156
|
-
request_headers = convert_from_headers(request_headers)
|
157
|
-
request_id = SecureRandom.uuid
|
158
|
-
|
159
|
-
# set X-Request-Id for better traceability
|
160
|
-
request_headers[X_REQUEST_ID_HEADER] = request_id
|
161
|
-
|
162
|
-
content_type = request_headers[CONTENT_TYPE]
|
163
|
-
|
164
|
-
info = { headers: request_headers, content_type: content_type }
|
165
|
-
info[:body] = body if body
|
166
|
-
|
167
|
-
log_request(request_id, method.upcase, uri, info)
|
168
|
-
|
169
|
-
start_time = Time.now
|
170
|
-
begin
|
171
|
-
response_headers = nil
|
172
|
-
response_status_code = nil
|
173
|
-
response_content_type = nil
|
174
|
-
response_body = ''
|
175
|
-
|
176
|
-
if body.is_a? OnlinePayments::SDK::MultipartFormDataObject
|
177
|
-
multipart_request(method, uri, request_headers, body) do |status_code, headers, r_content_type, r_body|
|
178
|
-
response_headers = headers
|
179
|
-
response_status_code = status_code
|
180
|
-
response_content_type = r_content_type
|
181
|
-
unless binary_content_type? response_content_type
|
182
|
-
response_body = r_body.read.force_encoding('UTF-8')
|
183
|
-
r_body = StringIO.new(response_body)
|
184
|
-
end
|
185
|
-
|
186
|
-
yield status_code, headers, r_body
|
187
|
-
end
|
188
|
-
else
|
189
|
-
raw_request(method, uri, request_headers, body) do |status_code, headers, r_content_type, r_body|
|
190
|
-
response_headers = headers
|
191
|
-
response_status_code = status_code
|
192
|
-
response_content_type = r_content_type
|
193
|
-
response_body = r_body.read.force_encoding('UTF-8')
|
194
|
-
r_body = StringIO.new(response_body)
|
195
|
-
|
196
|
-
yield status_code, headers, r_body
|
197
|
-
end
|
198
|
-
end
|
199
|
-
|
200
|
-
log_response(request_id, response_status_code, start_time,
|
201
|
-
headers: response_headers, body: response_body,
|
202
|
-
content_type: response_content_type)
|
203
|
-
rescue HTTPClient::TimeoutError => e
|
204
|
-
log_error(request_id, start_time, e)
|
205
|
-
raise OnlinePayments::SDK::CommunicationException, e
|
206
|
-
rescue HTTPClient::KeepAliveDisconnected, HTTPClient::RetryableResponse => e # retry these?
|
207
|
-
log_error(request_id, start_time, e)
|
208
|
-
raise OnlinePayments::SDK::CommunicationException, e
|
209
|
-
rescue StandardError => e
|
210
|
-
log_error(request_id, start_time, e)
|
211
|
-
raise OnlinePayments::SDK::CommunicationException, e
|
212
|
-
end
|
213
|
-
end
|
214
|
-
|
215
|
-
# logging code
|
216
|
-
|
217
|
-
# Enables logging outgoing requests and incoming responses by registering the _communicator_logger_.
|
218
|
-
# Note that only one logger can be registered at a time and calling _enable_logging_
|
219
|
-
# a second time will override the old logger instance with the new one.
|
220
|
-
#
|
221
|
-
# @param communicator_logger [OnlinePayments::SDK::Logging::CommunicatorLogger] the communicator logger the requests and responses are logged to
|
222
|
-
def enable_logging(communicator_logger)
|
223
|
-
raise ArgumentError, 'communicatorLogger is required' unless communicator_logger
|
224
|
-
|
225
|
-
@communicator_logger = communicator_logger
|
226
|
-
end
|
227
|
-
|
228
|
-
# Disables logging by unregistering any previous logger that might be registered.
|
229
|
-
def disable_logging
|
230
|
-
@communicator_logger = nil
|
231
|
-
end
|
232
|
-
|
233
|
-
private
|
234
|
-
|
235
|
-
# Converts a {OnlinePayments::SDK::RequestHeader} list headers to a hash
|
236
|
-
def convert_from_headers(headers)
|
237
|
-
headers.each_with_object({}) { |h, hash| hash[h.name] = h.value }
|
238
|
-
end
|
239
|
-
|
240
|
-
# Converts a hash to a {OnlinePayments::SDK::ResponseHeader} list
|
241
|
-
def convert_to_response_headers(headers)
|
242
|
-
arr ||= []
|
243
|
-
headers.each { |k, v| arr << OnlinePayments::SDK::ResponseHeader.new(k, v) }
|
244
|
-
arr
|
245
|
-
end
|
246
|
-
|
247
|
-
def log_request(request_id, method, uri, args = {})
|
248
|
-
return unless @communicator_logger
|
249
|
-
|
250
|
-
headers = args[:headers]
|
251
|
-
body = args[:body]
|
252
|
-
content_type = args[:content_type]
|
253
|
-
log_msg_builder = OnlinePayments::SDK::Logging::RequestLogMessageBuilder.new(request_id, method, uri)
|
254
|
-
headers.each { |k, v| log_msg_builder.add_headers(k, v) } if headers
|
255
|
-
|
256
|
-
log_msg_builder.set_body(body, content_type)
|
257
|
-
|
258
|
-
begin
|
259
|
-
@communicator_logger.log(log_msg_builder.get_message)
|
260
|
-
rescue StandardError => e
|
261
|
-
@communicator_logger.log("An error occurred trying to log request #{request_id}", e)
|
262
|
-
end
|
263
|
-
end
|
264
|
-
|
265
|
-
# Creates the log_response stream
|
266
|
-
def log_response(request_id, status_code, start_time, args = {})
|
267
|
-
return unless @communicator_logger
|
268
|
-
|
269
|
-
duration = (Time.now - start_time) * 1000 # in milliseconds
|
270
|
-
headers = args[:headers]
|
271
|
-
body = args[:body] if args[:body]
|
272
|
-
content_type = args[:content_type]
|
273
|
-
|
274
|
-
log_msg_builder = OnlinePayments::SDK::Logging::ResponseLogMessageBuilder.new(request_id, status_code, duration)
|
275
|
-
if headers
|
276
|
-
convert_from_headers(headers)
|
277
|
-
.each do |key, value|
|
278
|
-
log_msg_builder.add_headers(key, value)
|
279
|
-
end
|
280
|
-
end
|
281
|
-
|
282
|
-
log_msg_builder.set_body(body, content_type)
|
283
|
-
|
284
|
-
begin
|
285
|
-
@communicator_logger.log(log_msg_builder.get_message)
|
286
|
-
rescue StandardError => e
|
287
|
-
@communicator_logger.log("An error occurred trying to log response #{request_id}", e)
|
288
|
-
end
|
289
|
-
end
|
290
|
-
|
291
|
-
def log_error(request_id, start_time, thrown)
|
292
|
-
return unless @communicator_logger
|
293
|
-
|
294
|
-
duration = (Time.now - start_time) * 1000 # in millisecs
|
295
|
-
@communicator_logger.log("Error occurred for outgoing request (requestId='#{request_id}', #{duration} ms)", thrown)
|
296
|
-
end
|
297
|
-
|
298
|
-
# Makes a request using the specified method
|
299
|
-
#
|
300
|
-
# Yields a status code, an array of {OnlinePayments::SDK::ResponseHeader},
|
301
|
-
# the content_type and body
|
302
|
-
def raw_request(method, uri, headers, body = nil)
|
303
|
-
connection = body ?
|
304
|
-
@http_client.send("#{method}_async", uri, body: body, header: headers) :
|
305
|
-
@http_client.send("#{method}_async", uri, header: headers)
|
306
|
-
|
307
|
-
response = connection.pop
|
308
|
-
pipe = response.content
|
309
|
-
response_headers = convert_to_response_headers(response.headers)
|
310
|
-
|
311
|
-
begin
|
312
|
-
yield response.status_code, response_headers, response.content_type, pipe
|
313
|
-
ensure
|
314
|
-
pipe.close
|
315
|
-
end
|
316
|
-
end
|
317
|
-
|
318
|
-
# Makes a request using the specified method
|
319
|
-
#
|
320
|
-
# Yields a status code, an array of {OnlinePayments::SDK::ResponseHeader},
|
321
|
-
# the content_type and body
|
322
|
-
def multipart_request(method, uri, headers, body = nil)
|
323
|
-
unless body.is_a? OnlinePayments::SDK::MultipartFormDataObject
|
324
|
-
raise ArgumentError, 'body should be a MultipartFormDataObject'
|
325
|
-
end
|
326
|
-
|
327
|
-
if method != 'post' && method != 'put'
|
328
|
-
raise ArgumentError, "method #{method} is not supported"
|
329
|
-
end
|
330
|
-
|
331
|
-
connection = @http_client.send method + '_async',
|
332
|
-
uri,
|
333
|
-
body: multipart_request_body(body),
|
334
|
-
header: headers
|
335
|
-
|
336
|
-
response = connection.pop
|
337
|
-
pipe = response.content
|
338
|
-
response_headers = convert_to_sdk_response_headers(response.headers)
|
339
|
-
|
340
|
-
begin
|
341
|
-
yield response.status_code, response_headers, response.content_type, pipe
|
342
|
-
ensure
|
343
|
-
pipe.close
|
344
|
-
end
|
345
|
-
end
|
346
|
-
|
347
|
-
# Creates a request body for the multipart request
|
348
|
-
def multipart_request_body( body )
|
349
|
-
request_body = []
|
350
|
-
body.files.each do |k, v|
|
351
|
-
request_body.push :content => v.content,
|
352
|
-
'Content-Type' => v.content_type,
|
353
|
-
'Content-Disposition' => "form-data; name=\"#{k}\"; filename=\"#{v.file_name}\"",
|
354
|
-
'Content-Transfer-Encoding' => 'binary'
|
355
|
-
end
|
356
|
-
|
357
|
-
body.values.each do |k, v|
|
358
|
-
request_body << { :content => v,
|
359
|
-
'Content-Disposition' => "form-data; name=\"#{k}\"" }
|
360
|
-
end
|
361
|
-
request_body
|
362
|
-
end
|
363
|
-
end
|
364
|
-
end
|
365
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
require 'singleton'
|
3
|
-
|
4
|
-
module OnlinePayments::SDK
|
5
|
-
module DefaultImpl
|
6
|
-
# marshals objects to and from JSON format.
|
7
|
-
# Currently supports marshalling and unmarshalling of classes that support class.new_from_hash and class#to_h
|
8
|
-
class DefaultMarshaller < OnlinePayments::SDK::Marshaller
|
9
|
-
include Singleton
|
10
|
-
|
11
|
-
# NOTE: this alias is needed to not break existing method calls depending on old interface
|
12
|
-
class << self
|
13
|
-
alias_method :INSTANCE, :instance
|
14
|
-
end
|
15
|
-
|
16
|
-
# Marshals the _request_object_ to a JSON string using request_object#to_h
|
17
|
-
def marshal(request_object)
|
18
|
-
JSON.pretty_generate(request_object.to_h)
|
19
|
-
end
|
20
|
-
|
21
|
-
# Unmarshals a JSON string into an object of type _klass_ using klass.new_from_hash
|
22
|
-
# @param [String] json_string
|
23
|
-
def unmarshal(json_string, klass)
|
24
|
-
return nil unless json_string
|
25
|
-
return '' if json_string.empty?
|
26
|
-
return klass.new_from_hash(JSON.parse(json_string)) if klass.respond_to?(:new_from_hash)
|
27
|
-
|
28
|
-
raise NotImplementedError
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,127 +0,0 @@
|
|
1
|
-
require 'uri'
|
2
|
-
|
3
|
-
module OnlinePayments::SDK
|
4
|
-
|
5
|
-
# Base class for configuration classes in the SDK.
|
6
|
-
#
|
7
|
-
# @attr [String] api_endpoint The base URL to the Online Payments platform.
|
8
|
-
# @attr [Integer] connect_timeout The number of seconds before a connection attempt with the Online Payments platform times out.
|
9
|
-
# @attr [Integer] socket_timeout The number of seconds before a timeout occurs when transmitting data to or from the Online Payments platform.
|
10
|
-
# @attr [Integer] max_connections The number of connections with the Online Payments platform that are kept alive in the connection pool.
|
11
|
-
# These connections will be reused when possible.
|
12
|
-
# @attr [OnlinePayments::SDK::ProxyConfiguration] proxy_configuration Proxy settings.
|
13
|
-
# @attr [String] integrator Name of the integrator
|
14
|
-
# @attr [OnlinePayments::SDK::Domain::ShoppingCartExtension] shopping_cart_extension Shopping cart-related metadata.
|
15
|
-
class EndpointConfiguration
|
16
|
-
DEFAULT_CONNECT_TIMEOUT = 10
|
17
|
-
DEFAULT_SOCKET_TIMEOUT = 10
|
18
|
-
DEFAULT_MAX_CONNECTIONS = 10
|
19
|
-
|
20
|
-
# The default number of seconds before a connection attempt with the Online Payments platform times out.
|
21
|
-
# Used if _connectTimeout_ is not present in the properties.
|
22
|
-
def self.default_connect_timeout
|
23
|
-
DEFAULT_CONNECT_TIMEOUT
|
24
|
-
end
|
25
|
-
|
26
|
-
# The default number of seconds before a timeout occurs when transmitting data to or from the Online Payments platform.
|
27
|
-
# Used if _socketTimeout_ is not present in the properties.
|
28
|
-
def self.default_socket_timeout
|
29
|
-
DEFAULT_SOCKET_TIMEOUT
|
30
|
-
end
|
31
|
-
|
32
|
-
# The default number of connections that are kept alive in the connection pool.
|
33
|
-
# Used if _maxConnections_ is not present in the properties.
|
34
|
-
def self.default_max_connections
|
35
|
-
DEFAULT_MAX_CONNECTIONS
|
36
|
-
end
|
37
|
-
|
38
|
-
# Initializes a new EndpointConfiguration.
|
39
|
-
#
|
40
|
-
# The given _properties_ is searched for settings using properties[prefix + '.setting_name']
|
41
|
-
# The following settings are searched:
|
42
|
-
#
|
43
|
-
# endpoint:: This property is searched for *endpoint.host*, *endpoint.scheme* and *endpoint.port*.
|
44
|
-
# The found host, scheme and port are used to construct the base URL to the Online Payments platform.
|
45
|
-
# connectTimeout:: The number of seconds before a connection attempt with the Online Payments platform times out.
|
46
|
-
# socketTimeout:: The number of seconds before a timeout occurs when transmitting data to or from the Online Payments platform.
|
47
|
-
# maxConnections:: The number of connections with the Online Payments platform
|
48
|
-
# that are kept alive in the connection pool. These connections will be reused when possible.
|
49
|
-
# proxy:: This property is searched for *proxy.uri*, *proxy.username* and *proxy.password*.
|
50
|
-
# The found URI, username and password are used
|
51
|
-
# for connecting to the Online Payments platform using a proxy.
|
52
|
-
# integrator:: Name of the integrator
|
53
|
-
# shoppingCartExtension:: Will be used to initialize a {OnlinePayments::SDK::Domain::ShoppingCartExtension}.
|
54
|
-
def initialize(properties = nil, prefix = nil)
|
55
|
-
return unless properties
|
56
|
-
|
57
|
-
@api_endpoint = get_endpoint(properties, prefix)
|
58
|
-
@connect_timeout = get_property(properties, "#{prefix}.connectTimeout", DEFAULT_CONNECT_TIMEOUT)
|
59
|
-
@socket_timeout = get_property(properties, "#{prefix}.socketTimeout", DEFAULT_SOCKET_TIMEOUT)
|
60
|
-
@max_connections = get_property(properties, "#{prefix}.maxConnections", DEFAULT_MAX_CONNECTIONS)
|
61
|
-
|
62
|
-
proxy_uri = properties["#{prefix}.proxy.uri"]
|
63
|
-
if proxy_uri
|
64
|
-
proxy_user = properties["#{prefix}.proxy.username"]
|
65
|
-
proxy_pass = properties["#{prefix}.proxy.password"]
|
66
|
-
@proxy_configuration = ProxyConfiguration.new(address: URI(proxy_uri),
|
67
|
-
username: proxy_user,
|
68
|
-
password: proxy_pass)
|
69
|
-
end
|
70
|
-
@integrator = properties["#{prefix}.integrator"]
|
71
|
-
@shopping_cart_extension = get_shopping_cart_extension(properties, prefix)
|
72
|
-
end
|
73
|
-
|
74
|
-
protected
|
75
|
-
|
76
|
-
def set_endpoint(endpoint)
|
77
|
-
if endpoint
|
78
|
-
raise ArgumentError, 'endpoint should not contain a path' if endpoint.path
|
79
|
-
if endpoint.userinfo || endpoint.query || endpoint.fragment
|
80
|
-
raise ArgumentError('endpoint should not contain user info, query or fragment')
|
81
|
-
end
|
82
|
-
end
|
83
|
-
@api_endpoint = endpoint
|
84
|
-
end
|
85
|
-
|
86
|
-
private
|
87
|
-
|
88
|
-
def get_property(properties, key, default_value)
|
89
|
-
property_value = properties[key]
|
90
|
-
property_value.nil? ? default_value : property_value
|
91
|
-
end
|
92
|
-
|
93
|
-
def get_endpoint(properties, prefix)
|
94
|
-
host = properties["#{prefix}.endpoint.host"]
|
95
|
-
scheme = properties["#{prefix}.endpoint.scheme"] || 'https'
|
96
|
-
port = properties["#{prefix}.endpoint.port"] || -1
|
97
|
-
create_uri(scheme, host, port)
|
98
|
-
end
|
99
|
-
|
100
|
-
def create_uri(scheme, host, port)
|
101
|
-
port == -1 ? "#{scheme}://#{host}" : "#{scheme}://#{host}:#{port}"
|
102
|
-
end
|
103
|
-
|
104
|
-
def get_shopping_cart_extension(properties, prefix)
|
105
|
-
creator = properties["#{prefix}.shoppingCartExtension.creator"]
|
106
|
-
name = properties["#{prefix}.shoppingCartExtension.name"]
|
107
|
-
version = properties["#{prefix}.shoppingCartExtension.version"]
|
108
|
-
extension_id = properties["#{prefix}.shoppingCartExtension.extensionId"]
|
109
|
-
(creator || name || version || extension_id) ?
|
110
|
-
Domain::ShoppingCartExtension.new(creator, name, version, extension_id) :
|
111
|
-
nil
|
112
|
-
end
|
113
|
-
|
114
|
-
public
|
115
|
-
|
116
|
-
attr_reader :api_endpoint
|
117
|
-
|
118
|
-
attr_accessor :connect_timeout
|
119
|
-
attr_accessor :socket_timeout
|
120
|
-
attr_accessor :max_connections
|
121
|
-
|
122
|
-
attr_accessor :proxy_configuration
|
123
|
-
|
124
|
-
attr_accessor :integrator
|
125
|
-
attr_accessor :shopping_cart_extension
|
126
|
-
end
|
127
|
-
end
|
@@ -1,8 +0,0 @@
|
|
1
|
-
prefix = 'onlinepayments/sdk/'
|
2
|
-
suffix = '_exception'
|
3
|
-
exception_types = %w[api authorization communication declined_transaction
|
4
|
-
declined_payment declined_refund
|
5
|
-
payment_platform idempotence marshaller_syntax not_found
|
6
|
-
reference response validation]
|
7
|
-
|
8
|
-
exception_types.each { |type| require prefix + type + suffix }
|