onlinepayments-sdk-ruby 4.23.0 → 5.1.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 +142 -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 +127 -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 +42 -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 +54 -30
- 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 +81 -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/reattempt_instructions.rb +46 -0
- data/lib/onlinepayments/sdk/domain/reattempt_instructions_conditions.rb +37 -0
- data/lib/onlinepayments/sdk/domain/redirect_data.rb +27 -20
- data/lib/onlinepayments/sdk/domain/redirect_payment_method_specific_input.rb +166 -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_product3204_specific_input.rb +30 -0
- 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 +27 -16
- data/lib/onlinepayments/sdk/domain/redirect_payment_product5300_specific_input.rb +72 -0
- data/lib/onlinepayments/sdk/domain/redirect_payment_product5402_specific_input.rb +30 -0
- data/lib/onlinepayments/sdk/domain/redirect_payment_product5403_specific_input.rb +30 -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/show_instructions_data.rb +30 -0
- 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 +95 -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,135 +1,180 @@
|
|
1
1
|
require 'yaml'
|
2
|
+
require 'onlinepayments/sdk/client'
|
3
|
+
require 'onlinepayments/sdk/communicator'
|
4
|
+
require 'onlinepayments/sdk/communicator_configuration'
|
5
|
+
require 'onlinepayments/sdk/authentication/authorization_type'
|
6
|
+
require 'onlinepayments/sdk/authentication/v1hmac_authenticator'
|
7
|
+
require 'onlinepayments/sdk/communication/default_connection'
|
8
|
+
require 'onlinepayments/sdk/communication/metadata_provider'
|
9
|
+
require 'onlinepayments/sdk/json/default_marshaller'
|
2
10
|
|
3
|
-
module OnlinePayments
|
11
|
+
module OnlinePayments
|
12
|
+
module SDK
|
13
|
+
# Convenience class that constructs instances of several other classes in the SDK.
|
14
|
+
# Provides methods to construct
|
15
|
+
# {OnlinePayments::SDK::CommunicatorConfiguration}, {OnlinePayments::SDK::Communicator} and {OnlinePayments::SDK::Client} instances.
|
16
|
+
class Factory
|
4
17
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
18
|
+
# Creates and returns a {OnlinePayments::SDK::CommunicatorConfiguration} based on the configuration in the file
|
19
|
+
# located at _configuration_file_name_.
|
20
|
+
#
|
21
|
+
# @param configuration_file_name [String] Path to the configuration file to use, should be in YAML format.
|
22
|
+
# @param api_key_id [String] Key id for the Online Payments platform.
|
23
|
+
# @param secret_api_key [String] Secret key used for authentication to the Online Payments platform.
|
24
|
+
# @return [OnlinePayments::SDK::CommunicatorConfiguration] The created communicator configuration
|
25
|
+
def self.create_configuration(configuration_file_name, api_key_id, secret_api_key)
|
26
|
+
properties = YAML::load_file(configuration_file_name)
|
27
|
+
CommunicatorConfiguration.new(properties: properties,
|
28
|
+
api_key_id: api_key_id,
|
29
|
+
secret_api_key: secret_api_key)
|
30
|
+
end
|
9
31
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
32
|
+
# Creates and returns a {OnlinePayments::SDK::Communicator} from a {OnlinePayments::SDK::CommunicatorConfiguration},
|
33
|
+
# a {OnlinePayments::SDK::Communication::MetadataProvider}, a {OnlinePayments::SDK::Communication::Connection},
|
34
|
+
# an {OnlinePayments::SDK::Authentication::Authenticator} and a {OnlinePayments::SDK::JSON::Marshaller}.
|
35
|
+
#
|
36
|
+
# @param configuration [OnlinePayments::SDK::CommunicatorConfiguration] configuration settings to be used by the client.
|
37
|
+
# @param metadata_provider [OnlinePayments::SDK::Communication::MetadataProvider] stores the metadata for the communicating client.
|
38
|
+
# @param connection [OnlinePayments::SDK::Communication::Connection] connection that can be used to communicate with the Online Payments platform.
|
39
|
+
# @param authenticator [OnlinePayments::SDK::Authentication::Authenticator] authenticator that can authenticate messages sent to the Online Payments platform.
|
40
|
+
# @param marshaller [OnlinePayments::SDK::JSON::Marshaller] marshaller that can marshal and unmarshal objects to and from JSON.
|
41
|
+
# @return [OnlinePayments::SDK::Communicator] The created communicator
|
42
|
+
def self.create_communicator_from_configuration(configuration, metadata_provider: nil,
|
43
|
+
connection: nil, authenticator: nil, marshaller: nil)
|
44
|
+
unless metadata_provider
|
45
|
+
metadata_provider = Communication::MetadataProvider.new(configuration.integrator,
|
46
|
+
shopping_cart_extension: configuration.shopping_cart_extension)
|
47
|
+
end
|
48
|
+
unless connection
|
49
|
+
connection = Communication::DefaultConnection.new({ connect_timeout: configuration.connect_timeout,
|
50
|
+
socket_timeout: configuration.socket_timeout,
|
51
|
+
max_connections: configuration.max_connections,
|
52
|
+
proxy_configuration: configuration.proxy_configuration })
|
53
|
+
end
|
54
|
+
unless authenticator
|
55
|
+
authenticator = get_authenticator(configuration)
|
56
|
+
end
|
57
|
+
unless marshaller
|
58
|
+
marshaller = JSON::DefaultMarshaller.instance
|
59
|
+
end
|
60
|
+
Communicator.new(configuration.api_endpoint, connection, authenticator, metadata_provider, marshaller)
|
61
|
+
end
|
22
62
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
end
|
63
|
+
# Creates and returns a {OnlinePayments::SDK::Communicator} from a file containing the communicator configuration, api_key_id, secret_api_key,
|
64
|
+
# a {OnlinePayments::SDK::Communication::MetadataProvider}, a {OnlinePayments::SDK::Communication::Connection}.
|
65
|
+
# an {OnlinePayments::SDK::Authentication::Authenticator} and a {OnlinePayments::SDK::JSON::Marshaller}.
|
66
|
+
#
|
67
|
+
# @param configuration_file_name [String] Path to the configuration file to use, should be in YAML format.
|
68
|
+
# @param api_key_id [String] Key id for the Online Payments platform.
|
69
|
+
# @param secret_api_key [String] Secret key used for authentication to the Online Payments platform.
|
70
|
+
# @param metadata_provider [OnlinePayments::SDK::Communication::MetadataProvider] stores the metadata for the communicating client.
|
71
|
+
# @param connection [OnlinePayments::SDK::Communication::Connection] connection that can be used to communicate with the Online Payments platform.
|
72
|
+
# @param authenticator [OnlinePayments::SDK::Authentication::Authenticator] authenticator that can authenticate messages sent to the Online Payments platform.
|
73
|
+
# @param marshaller [OnlinePayments::SDK::JSON::Marshaller] marshaller that can marshal and unmarshal objects to and from JSON.
|
74
|
+
# @return [OnlinePayments::SDK::Communicator] The created communicator
|
75
|
+
def self.create_communicator_from_file(configuration_file_name, api_key_id, secret_api_key,
|
76
|
+
metadata_provider: nil, connection: nil, authenticator: nil, marshaller: nil)
|
77
|
+
configuration = create_configuration(configuration_file_name, api_key_id, secret_api_key)
|
78
|
+
create_communicator_from_configuration(configuration, metadata_provider: metadata_provider, connection: connection,
|
79
|
+
authenticator: authenticator, marshaller: marshaller)
|
80
|
+
end
|
42
81
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
82
|
+
# Creates and returns an {OnlinePayments::SDK::Client} that provides the a high-level interface with the Online Payments platform.
|
83
|
+
# If a code block is given, the created client is returned to the code block and closed afterwards.
|
84
|
+
#
|
85
|
+
# @example Providing a code block
|
86
|
+
# Factory.create_client_from_configuration(configuration) do |client|
|
87
|
+
# # use client as needed
|
88
|
+
# end
|
89
|
+
# # client is closed here
|
90
|
+
#
|
91
|
+
# @param configuration [OnlinePayments::SDK::CommunicatorConfiguration] contains configuration settings to be used by the client.
|
92
|
+
# @param metadata_provider [OnlinePayments::SDK::Communication::MetadataProvider] stores the metadata for the communicating client.
|
93
|
+
# @param connection [OnlinePayments::SDK::Communication::Connection] connection that can be used to communicate with the Online Payments platform.
|
94
|
+
# @param authenticator [OnlinePayments::SDK::Authentication::Authenticator] authenticator that can authenticate messages sent to the Online Payments platform.
|
95
|
+
# @param marshaller [OnlinePayments::SDK::JSON::Marshaller] marshaller that can marshal and unmarshal objects to and from JSON.
|
96
|
+
# @return [OnlinePayments::SDK::Client] The created client
|
97
|
+
def self.create_client_from_configuration(configuration, metadata_provider: nil, connection: nil, authenticator: nil, marshaller: nil)
|
98
|
+
communicator = create_communicator_from_configuration(configuration, metadata_provider: metadata_provider, connection: connection,
|
99
|
+
authenticator: authenticator, marshaller: marshaller)
|
100
|
+
client = Client.new(communicator)
|
101
|
+
if block_given?
|
102
|
+
begin
|
103
|
+
yield client
|
104
|
+
ensure
|
105
|
+
client.close
|
106
|
+
end
|
107
|
+
else
|
108
|
+
return client
|
109
|
+
end
|
110
|
+
end
|
59
111
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
112
|
+
# Creates and returns an {OnlinePayments::SDK::Client} that provides the a high-level interface with the Online Payments platform.
|
113
|
+
# If a code block is given, the created client is returned to the code block and closed afterwards.
|
114
|
+
#
|
115
|
+
# @example Providing a code block
|
116
|
+
# Factory.create_client_from_communicator(communicator) do |client|
|
117
|
+
# # use client as needed
|
118
|
+
# end
|
119
|
+
# # client is closed here
|
120
|
+
#
|
121
|
+
# @param communicator [OnlinePayments::SDK::Communicator] provides network communication service for the Client
|
122
|
+
# @return [OnlinePayments::SDK::Client] The created client
|
123
|
+
def self.create_client_from_communicator(communicator)
|
124
|
+
client = Client.new(communicator)
|
125
|
+
if block_given?
|
126
|
+
begin
|
127
|
+
yield client
|
128
|
+
ensure
|
129
|
+
client.close
|
130
|
+
end
|
131
|
+
else
|
132
|
+
return client
|
79
133
|
end
|
80
|
-
else
|
81
|
-
return client
|
82
134
|
end
|
83
|
-
end
|
84
135
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
136
|
+
# Creates and returns an {OnlinePayments::SDK::Client} that provides the a high-level interface with the Online Payments platform.
|
137
|
+
# If a code block is given, the created client is returned to the code block and closed afterwards.
|
138
|
+
#
|
139
|
+
# @example Providing a code block
|
140
|
+
# Factory.create_client_from_file(configuration_file_name, api_key_id, secret_api_key) do |client|
|
141
|
+
# # use client as needed
|
142
|
+
# end
|
143
|
+
# # client is closed here
|
144
|
+
#
|
145
|
+
# @param configuration_file_name [String] Path to the configuration file to use, should be in YAML format.
|
146
|
+
# @param api_key_id [String] Key id for the Online Payments platform.
|
147
|
+
# @param secret_api_key [String] Secret key used for authentication to the Online Payments platform.
|
148
|
+
# @param metadata_provider [OnlinePayments::SDK::Communication::MetadataProvider] stores the metadata for the communicating client.
|
149
|
+
# @param connection [OnlinePayments::SDK::Communication::Connection] connection that can be used to communicate with the Online Payments platform.
|
150
|
+
# @param authenticator [OnlinePayments::SDK::Authentication::Authenticator] authenticator that can authenticate messages sent to the Online Payments platform.
|
151
|
+
# @param marshaller [OnlinePayments::SDK::JSON::Marshaller] marshaller that can marshal and unmarshal objects to and from JSON.
|
152
|
+
# @return [OnlinePayments::SDK::Client] The created client
|
153
|
+
def self.create_client_from_file(configuration_file_name, api_key_id, secret_api_key,
|
154
|
+
metadata_provider: nil, connection: nil, authenticator: nil, marshaller: nil)
|
155
|
+
communicator = create_communicator_from_file(configuration_file_name, api_key_id, secret_api_key,
|
156
|
+
metadata_provider: metadata_provider, connection: connection,
|
157
|
+
authenticator: authenticator, marshaller: marshaller)
|
158
|
+
client = Client.new(communicator)
|
159
|
+
if block_given?
|
160
|
+
begin
|
161
|
+
yield client
|
162
|
+
ensure
|
163
|
+
client.close
|
164
|
+
end
|
165
|
+
else
|
166
|
+
return client
|
103
167
|
end
|
104
|
-
else
|
105
|
-
return client
|
106
168
|
end
|
107
|
-
end
|
108
169
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
# end
|
116
|
-
# # client is closed here
|
117
|
-
#
|
118
|
-
# @param config_file_name [String] Path to the configuration file to use, should be in YAML format.
|
119
|
-
# @param api_key_id [String] Key id for the OnlinePayments service.
|
120
|
-
# @param secret_api_key [String] Secret key used for authentication to the OnlinePayments service.
|
121
|
-
# @return [OnlinePayments::SDK::Client] The created client
|
122
|
-
def self.create_client_from_file(config_file_name, api_key_id, secret_api_key)
|
123
|
-
communicator = create_communicator_from_file(config_file_name, api_key_id, secret_api_key)
|
124
|
-
client = Client.new(communicator)
|
125
|
-
if block_given?
|
126
|
-
begin
|
127
|
-
yield client
|
128
|
-
ensure
|
129
|
-
client.close
|
170
|
+
private
|
171
|
+
|
172
|
+
# @param configuration [OnlinePayments::SDK::CommunicatorConfiguration]
|
173
|
+
def self.get_authenticator(configuration)
|
174
|
+
if configuration.authorization_type == Authentication::AuthorizationType::V1HMAC
|
175
|
+
return Authentication::V1HmacAuthenticator.new(configuration)
|
130
176
|
end
|
131
|
-
|
132
|
-
return client
|
177
|
+
raise RuntimeError.new("Unknown authorizationType #{configuration.authorization_type}")
|
133
178
|
end
|
134
179
|
end
|
135
180
|
end
|
@@ -1,24 +1,28 @@
|
|
1
|
-
|
1
|
+
#
|
2
|
+
# This file was automatically generated.
|
3
|
+
#
|
4
|
+
require_relative 'api_exception'
|
2
5
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
module OnlinePayments
|
7
|
+
module SDK
|
8
|
+
# Represents an error response from the payment platform when an idempotent request failed because the first request has not finished yet.
|
9
|
+
# The _idempotence_request_timestamp_ indicates the time when the first request with this _idempotence_key_ arrived.
|
10
|
+
#
|
11
|
+
# @attr_reader [String] idempotence_key The idempotence key used in the request.
|
12
|
+
# @attr_reader [Integer] idempotence_request_timestamp A timestamp indicating the arrival time of the request that conflicts with the request just sent.
|
13
|
+
class IdempotenceException < ApiException
|
10
14
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
15
|
+
# Create a new IdempotenceException.
|
16
|
+
# @see ApiException#initialize
|
17
|
+
def initialize(status_code, response_body, error_id, errors, idempotence_key, idempotence_request_timestamp,
|
18
|
+
message='the payment platform returned a duplicate request error response')
|
19
|
+
super(status_code, response_body, error_id, errors, message)
|
20
|
+
@idempotence_key = idempotence_key
|
21
|
+
@idempotence_request_timestamp = idempotence_request_timestamp
|
22
|
+
end
|
20
23
|
|
21
|
-
|
22
|
-
|
24
|
+
attr_reader :idempotence_key
|
25
|
+
attr_reader :idempotence_request_timestamp
|
26
|
+
end
|
23
27
|
end
|
24
28
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'singleton'
|
3
|
+
require 'onlinepayments/sdk/json/marshaller'
|
4
|
+
|
5
|
+
module OnlinePayments
|
6
|
+
module SDK
|
7
|
+
module JSON
|
8
|
+
# Marshals objects to and from JSON format.
|
9
|
+
# Currently supports marshalling and unmarshalling of classes that support class.new_from_hash and class#to_h
|
10
|
+
class DefaultMarshaller < Marshaller
|
11
|
+
include Singleton
|
12
|
+
|
13
|
+
# Marshals the _request_object_ to a JSON string using request_object#to_h
|
14
|
+
def marshal(request_object)
|
15
|
+
::JSON.pretty_generate(request_object.to_h)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Unmarshals a JSON string into an object of type _klass_ using klass.new_from_hash
|
19
|
+
def unmarshal(json_string, klass)
|
20
|
+
if json_string.nil?
|
21
|
+
return nil
|
22
|
+
elsif json_string.length == 0
|
23
|
+
return ''
|
24
|
+
end
|
25
|
+
if klass.respond_to?(:new_from_hash)
|
26
|
+
klass.new_from_hash(::JSON.load(json_string))
|
27
|
+
else
|
28
|
+
raise NotImplementedError
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module OnlinePayments
|
2
|
+
module SDK
|
3
|
+
module JSON
|
4
|
+
# Class responsible for marshalling and unmarshalling objects to and from JSON
|
5
|
+
class Marshaller
|
6
|
+
|
7
|
+
# Marshals _request_object_ to JSON format by calling #to_h on it.
|
8
|
+
#
|
9
|
+
# @param request_object [OnlinePayments::SDK::Domain::DataObject] the object to format
|
10
|
+
# @return [String] _request_object_ converted to JSON
|
11
|
+
def marshal(request_object)
|
12
|
+
raise NotImplementedError
|
13
|
+
end
|
14
|
+
|
15
|
+
# Unmarshals a JSON string into an object of type _type_.
|
16
|
+
# The new object is initialized by calling .new_from_hash with contents of the JSON as a Hash object.
|
17
|
+
#
|
18
|
+
# @param response_json [String] The JSON to unmarshal
|
19
|
+
# @param type [Type] The class of the object that will be instantiated using _type.new_from_hash_
|
20
|
+
# @return The JSON unmarshalled to the given type
|
21
|
+
def unmarshal(response_json, type)
|
22
|
+
raise NotImplementedError
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
Dir[File.join(__dir__, 'json', '*.rb')].each { |f| require f }
|
@@ -1,21 +1,23 @@
|
|
1
|
-
module OnlinePayments
|
2
|
-
module
|
1
|
+
module OnlinePayments
|
2
|
+
module SDK
|
3
|
+
module Logging
|
4
|
+
# Base logger class used in this SDK. This class is an interface and cannot be instantiated.
|
5
|
+
class CommunicatorLogger
|
3
6
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
raise NotImplementedError, "#{self.class.name} is not implemented."
|
11
|
-
end
|
7
|
+
# Interface, no instantiation
|
8
|
+
# @see OnlinePayments::SDK::Logging::StdoutCommunicatorLogger
|
9
|
+
# @see OnlinePayments::SDK::Logging::RubyCommunicatorLogger
|
10
|
+
def initialize
|
11
|
+
raise NotImplementedError.new("#{self.class.name} is not implemented.")
|
12
|
+
end
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
# Logs a message with or without exception
|
15
|
+
#
|
16
|
+
# @param message [String] the message to log
|
17
|
+
# @param thrown [Exception, nil] the exception to log, or nil to log no exception
|
18
|
+
def log(message, thrown = nil)
|
19
|
+
raise NotImplementedError.new("#{self.class.name}#log() is not implemented.")
|
20
|
+
end
|
19
21
|
end
|
20
22
|
end
|
21
23
|
end
|
@@ -1,56 +1,89 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
# Abstract class used to construct a message describing a request or response.
|
5
|
-
#
|
6
|
-
# @attr_reader [String] request_id An identifier assigned to the request and response
|
7
|
-
# @attr_reader [String] headers Request or response headers in string form
|
8
|
-
# @attr_reader [String] body Request or response body as a string
|
9
|
-
# @attr_reader [String] content_type Content type of the body, generally 'application/json' or 'text/html'
|
10
|
-
class LogMessageBuilder
|
11
|
-
|
12
|
-
attr_reader :request_id
|
13
|
-
attr_reader :headers
|
14
|
-
attr_reader :body
|
15
|
-
attr_reader :content_type
|
16
|
-
|
17
|
-
# Create a new LogMessageBuilder
|
18
|
-
def initialize(request_id)
|
19
|
-
raise ArgumentError if request_id.nil? || request_id.empty?
|
20
|
-
@request_id = request_id
|
21
|
-
@headers = ''
|
22
|
-
end
|
1
|
+
require 'onlinepayments/sdk/logging/obfuscation/body_obfuscator'
|
2
|
+
require 'onlinepayments/sdk/logging/obfuscation/header_obfuscator'
|
23
3
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
4
|
+
module OnlinePayments
|
5
|
+
module SDK
|
6
|
+
module Logging
|
7
|
+
# Abstract class used to construct a message describing a request or response.
|
8
|
+
#
|
9
|
+
# @attr_reader [String] request_id An identifier assigned to the request and response
|
10
|
+
# @attr_reader [String] headers Request or response headers in string form
|
11
|
+
# @attr_reader [String] body Request or response body as a string
|
12
|
+
# @attr_reader [String] content_type Content type of the body, generally 'application/json' or 'text/html'
|
13
|
+
# @attr_reader [OnlinePayments::SDK::Logging::Obfuscation::BodyObfuscator] body_obfuscator
|
14
|
+
# @attr_reader [OnlinePayments::SDK::Logging::Obfuscation::HeaderObfuscator] header_obfuscator
|
15
|
+
class LogMessageBuilder
|
29
16
|
|
30
|
-
|
17
|
+
attr_reader :request_id
|
18
|
+
attr_reader :headers
|
19
|
+
attr_reader :body
|
20
|
+
attr_reader :content_type
|
21
|
+
attr_reader :body_obfuscator
|
22
|
+
attr_reader :header_obfuscator
|
31
23
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
24
|
+
# Create a new LogMessageBuilder
|
25
|
+
def initialize(request_id,
|
26
|
+
body_obfuscator = Obfuscation::BodyObfuscator.default_obfuscator,
|
27
|
+
header_obfuscator = Obfuscation::HeaderObfuscator.default_obfuscator)
|
28
|
+
raise ArgumentError if request_id.nil? or request_id.empty?
|
29
|
+
raise ArgumentError if body_obfuscator.nil?
|
30
|
+
raise ArgumentError if header_obfuscator.nil?
|
31
|
+
@request_id = request_id
|
32
|
+
@headers = ''
|
33
|
+
@body_obfuscator = body_obfuscator
|
34
|
+
@header_obfuscator = header_obfuscator
|
35
|
+
end
|
38
36
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
37
|
+
# Adds a single header to the #headers string
|
38
|
+
def add_headers(name, value)
|
39
|
+
@headers += ', ' if @headers.length > 0
|
40
|
+
@headers += name + '="'
|
41
|
+
@headers += @header_obfuscator.obfuscate_header(name, value) unless value.nil?
|
42
|
+
@headers += '"'
|
43
|
+
end
|
43
44
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
45
|
+
# Sets the body of this message to the parameter body.
|
46
|
+
|
47
|
+
# @param body [String] the message body
|
48
|
+
# @param content_type [String] the content type of the body
|
49
|
+
def set_body(body, content_type)
|
50
|
+
if is_binary(content_type)
|
51
|
+
@body = "<binary content>"
|
52
|
+
else
|
53
|
+
@body = @body_obfuscator.obfuscate_body(body)
|
54
|
+
end
|
55
|
+
@content_type = content_type
|
56
|
+
end
|
57
|
+
|
58
|
+
# Constructs and returns the log message as a string.
|
59
|
+
# @return [String]
|
60
|
+
def get_message
|
61
|
+
raise NotImplementedError.new("#{self.class.name}#get_message() is not implemented.")
|
62
|
+
end
|
63
|
+
|
64
|
+
def to_s
|
65
|
+
if self.class == LogMessageBuilder
|
66
|
+
super.to_s
|
67
|
+
else
|
68
|
+
get_message
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
# Returns an empty string if the parameter is nil, and returns the parameter itself otherwise
|
73
|
+
protected def empty_if_null(value)
|
74
|
+
value.nil? ? '' : value
|
75
|
+
end
|
49
76
|
|
50
|
-
|
51
|
-
|
52
|
-
|
77
|
+
# Returns whether or not the content type is binary
|
78
|
+
def is_binary(content_type)
|
79
|
+
if content_type.nil?
|
80
|
+
false
|
81
|
+
else
|
82
|
+
content_type = content_type.downcase
|
83
|
+
!(content_type.start_with?("text/") || content_type.include?("json") || content_type.include?("xml"))
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
53
87
|
end
|
54
|
-
end
|
55
88
|
end
|
56
89
|
end
|