onlinepayments-sdk-ruby 11.0.0 → 12.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/AGENTS.md +25 -0
- data/README.md +152 -44
- data/Rakefile +8 -0
- data/lib/onlinepayments/sdk/api_exception.rb +5 -2
- data/lib/onlinepayments/sdk/api_resource.rb +19 -12
- data/lib/onlinepayments/sdk/authentication/authenticator.rb +2 -1
- data/lib/onlinepayments/sdk/authentication/authorization_type.rb +3 -1
- data/lib/onlinepayments/sdk/authentication/v1hmac_authenticator.rb +23 -19
- data/lib/onlinepayments/sdk/authentication.rb +2 -0
- data/lib/onlinepayments/sdk/authorization_exception.rb +2 -0
- data/lib/onlinepayments/sdk/call_context.rb +3 -7
- data/lib/onlinepayments/sdk/client.rb +4 -1
- data/lib/onlinepayments/sdk/communication/communication_exception.rb +2 -1
- data/lib/onlinepayments/sdk/communication/connection.rb +2 -0
- data/lib/onlinepayments/sdk/communication/default_connection.rb +187 -206
- data/lib/onlinepayments/sdk/communication/metadata_provider.rb +37 -47
- data/lib/onlinepayments/sdk/communication/multipart_form_data_object.rb +8 -17
- data/lib/onlinepayments/sdk/communication/multipart_form_data_request.rb +2 -0
- data/lib/onlinepayments/sdk/communication/not_found_exception.rb +2 -1
- data/lib/onlinepayments/sdk/communication/param_request.rb +2 -0
- data/lib/onlinepayments/sdk/communication/pooled_connection.rb +5 -5
- data/lib/onlinepayments/sdk/communication/request_header.rb +11 -15
- data/lib/onlinepayments/sdk/communication/request_param.rb +5 -6
- data/lib/onlinepayments/sdk/communication/response_exception.rb +7 -11
- data/lib/onlinepayments/sdk/communication/response_header.rb +17 -24
- data/lib/onlinepayments/sdk/communication.rb +2 -0
- data/lib/onlinepayments/sdk/communicator.rb +100 -175
- data/lib/onlinepayments/sdk/communicator_configuration.rb +71 -53
- data/lib/onlinepayments/sdk/declined_payment_exception.rb +2 -0
- data/lib/onlinepayments/sdk/declined_payout_exception.rb +2 -0
- data/lib/onlinepayments/sdk/declined_refund_exception.rb +2 -0
- data/lib/onlinepayments/sdk/declined_transaction_exception.rb +2 -0
- data/lib/onlinepayments/sdk/domain/acceptance.rb +13 -3
- data/lib/onlinepayments/sdk/domain/account_on_file.rb +17 -6
- data/lib/onlinepayments/sdk/domain/account_on_file_attribute.rb +15 -4
- data/lib/onlinepayments/sdk/domain/account_on_file_display_hints.rb +12 -3
- data/lib/onlinepayments/sdk/domain/acquirer_information.rb +12 -3
- data/lib/onlinepayments/sdk/domain/acquirer_selection_information.rb +13 -3
- data/lib/onlinepayments/sdk/domain/add_authorization_details_response.rb +10 -2
- data/lib/onlinepayments/sdk/domain/additional_order_input.rb +19 -8
- data/lib/onlinepayments/sdk/domain/address.rb +21 -7
- data/lib/onlinepayments/sdk/domain/address_personal.rb +26 -10
- data/lib/onlinepayments/sdk/domain/airline_data.rb +83 -27
- data/lib/onlinepayments/sdk/domain/airline_flight_leg.rb +69 -21
- data/lib/onlinepayments/sdk/domain/airline_passenger.rb +30 -8
- data/lib/onlinepayments/sdk/domain/amex.rb +15 -5
- data/lib/onlinepayments/sdk/domain/amount_breakdown.rb +11 -2
- data/lib/onlinepayments/sdk/domain/amount_of_money.rb +11 -2
- data/lib/onlinepayments/sdk/domain/api_error.rb +23 -8
- data/lib/onlinepayments/sdk/domain/api_parameters.rb +22 -10
- data/lib/onlinepayments/sdk/domain/apple_pay_line_item.rb +27 -7
- data/lib/onlinepayments/sdk/domain/apple_pay_recurring_payment_request.rb +19 -7
- data/lib/onlinepayments/sdk/domain/authentication_options.rb +15 -4
- data/lib/onlinepayments/sdk/domain/auto_capture.rb +9 -1
- data/lib/onlinepayments/sdk/domain/bank_account_iban.rb +9 -1
- data/lib/onlinepayments/sdk/domain/batch_metadata.rb +13 -3
- data/lib/onlinepayments/sdk/domain/browser_data.rb +17 -5
- data/lib/onlinepayments/sdk/domain/calculate_surcharge_request.rb +13 -4
- data/lib/onlinepayments/sdk/domain/calculate_surcharge_response.rb +10 -2
- data/lib/onlinepayments/sdk/domain/cancel_payment_batch_request.rb +12 -3
- data/lib/onlinepayments/sdk/domain/cancel_payment_request.rb +21 -9
- data/lib/onlinepayments/sdk/domain/cancel_payment_response.rb +10 -2
- data/lib/onlinepayments/sdk/domain/capture.rb +17 -6
- data/lib/onlinepayments/sdk/domain/capture_output.rb +57 -23
- data/lib/onlinepayments/sdk/domain/capture_payment_batch_request.rb +12 -3
- data/lib/onlinepayments/sdk/domain/capture_payment_request.rb +23 -10
- data/lib/onlinepayments/sdk/domain/capture_response.rb +17 -6
- data/lib/onlinepayments/sdk/domain/capture_status_output.rb +9 -1
- data/lib/onlinepayments/sdk/domain/captures_response.rb +10 -2
- data/lib/onlinepayments/sdk/domain/car_rental_data.rb +57 -19
- data/lib/onlinepayments/sdk/domain/car_rental_pickup_return_data.rb +21 -7
- data/lib/onlinepayments/sdk/domain/car_rental_vehicle_data.rb +11 -2
- data/lib/onlinepayments/sdk/domain/card.rb +15 -4
- data/lib/onlinepayments/sdk/domain/card_bin_details.rb +66 -20
- data/lib/onlinepayments/sdk/domain/card_data_without_cvv.rb +13 -3
- data/lib/onlinepayments/sdk/domain/card_essentials.rb +75 -23
- data/lib/onlinepayments/sdk/domain/card_fraud_results.rb +13 -3
- data/lib/onlinepayments/sdk/domain/card_info.rb +11 -2
- data/lib/onlinepayments/sdk/domain/card_installment_details.rb +6 -1
- data/lib/onlinepayments/sdk/domain/card_payment_method_specific_input.rb +122 -50
- data/lib/onlinepayments/sdk/domain/card_payment_method_specific_input_base.rb +93 -39
- data/lib/onlinepayments/sdk/domain/card_payment_method_specific_input_for_hosted_checkout.rb +16 -5
- data/lib/onlinepayments/sdk/domain/card_payment_method_specific_output.rb +88 -36
- data/lib/onlinepayments/sdk/domain/card_payment_method_specific_output_summary.rb +12 -3
- data/lib/onlinepayments/sdk/domain/card_payment_method_specific_output_summary_card.rb +9 -1
- data/lib/onlinepayments/sdk/domain/card_payout_method_specific_input.rb +18 -6
- data/lib/onlinepayments/sdk/domain/card_recurrence_details.rb +9 -1
- data/lib/onlinepayments/sdk/domain/card_source.rb +16 -5
- data/lib/onlinepayments/sdk/domain/card_token.rb +21 -7
- data/lib/onlinepayments/sdk/domain/card_without_cvv.rb +13 -3
- data/lib/onlinepayments/sdk/domain/click_to_pay.rb +9 -1
- data/lib/onlinepayments/sdk/domain/company_information.rb +9 -1
- data/lib/onlinepayments/sdk/domain/complete_payment_card_payment_method_specific_input.rb +10 -2
- data/lib/onlinepayments/sdk/domain/complete_payment_request.rb +13 -4
- data/lib/onlinepayments/sdk/domain/complete_payment_response.rb +16 -6
- data/lib/onlinepayments/sdk/domain/contact_details.rb +17 -5
- data/lib/onlinepayments/sdk/domain/create_certificate_response.rb +11 -2
- data/lib/onlinepayments/sdk/domain/create_hosted_checkout_request.rb +38 -16
- data/lib/onlinepayments/sdk/domain/create_hosted_checkout_response.rb +20 -7
- data/lib/onlinepayments/sdk/domain/create_hosted_fields_session_request.rb +17 -6
- data/lib/onlinepayments/sdk/domain/create_hosted_fields_session_response.rb +22 -9
- data/lib/onlinepayments/sdk/domain/create_hosted_tokenization_request.rb +23 -9
- data/lib/onlinepayments/sdk/domain/create_hosted_tokenization_response.rb +26 -8
- data/lib/onlinepayments/sdk/domain/create_mandate_request.rb +31 -9
- data/lib/onlinepayments/sdk/domain/create_mandate_response.rb +13 -4
- data/lib/onlinepayments/sdk/domain/create_mandate_with_return_url.rb +31 -9
- data/lib/onlinepayments/sdk/domain/create_payment_link_request.rb +61 -25
- data/lib/onlinepayments/sdk/domain/create_payment_request.rb +47 -19
- data/lib/onlinepayments/sdk/domain/create_payment_response.rb +16 -6
- data/lib/onlinepayments/sdk/domain/create_payout_request.rb +29 -11
- data/lib/onlinepayments/sdk/domain/create_token_request.rb +14 -4
- data/lib/onlinepayments/sdk/domain/created_payment_output.rb +12 -3
- data/lib/onlinepayments/sdk/domain/created_token_response.rb +22 -9
- data/lib/onlinepayments/sdk/domain/credit_card_specific_input_hosted_tokenization.rb +13 -4
- data/lib/onlinepayments/sdk/domain/credit_card_validation_rules.rb +11 -2
- data/lib/onlinepayments/sdk/domain/crm_token.rb +11 -2
- data/lib/onlinepayments/sdk/domain/csr_request.rb +9 -1
- data/lib/onlinepayments/sdk/domain/currency_conversion.rb +12 -3
- data/lib/onlinepayments/sdk/domain/currency_conversion_input.rb +11 -2
- data/lib/onlinepayments/sdk/domain/currency_conversion_request.rb +13 -4
- data/lib/onlinepayments/sdk/domain/currency_conversion_response.rb +15 -5
- data/lib/onlinepayments/sdk/domain/currency_conversion_result.rb +11 -2
- data/lib/onlinepayments/sdk/domain/currency_conversion_specific_input.rb +9 -1
- data/lib/onlinepayments/sdk/domain/cursor_pagination_info.rb +11 -2
- data/lib/onlinepayments/sdk/domain/customer.rb +42 -16
- data/lib/onlinepayments/sdk/domain/customer_account.rb +36 -12
- data/lib/onlinepayments/sdk/domain/customer_account_authentication.rb +13 -3
- data/lib/onlinepayments/sdk/domain/customer_bank_account.rb +13 -3
- data/lib/onlinepayments/sdk/domain/customer_device.rb +28 -8
- data/lib/onlinepayments/sdk/domain/customer_device_output.rb +9 -1
- data/lib/onlinepayments/sdk/domain/customer_output.rb +10 -2
- data/lib/onlinepayments/sdk/domain/customer_payment_activity.rb +13 -3
- data/lib/onlinepayments/sdk/domain/customer_token.rb +16 -6
- data/lib/onlinepayments/sdk/domain/data_object.rb +19 -2
- data/lib/onlinepayments/sdk/domain/dcc_card_source.rb +16 -5
- data/lib/onlinepayments/sdk/domain/dcc_proposal.rb +20 -8
- data/lib/onlinepayments/sdk/domain/decrypted_payment_data.rb +17 -5
- data/lib/onlinepayments/sdk/domain/detokenization_response.rb +10 -2
- data/lib/onlinepayments/sdk/domain/detokenized_token_response.rb +27 -7
- data/lib/onlinepayments/sdk/domain/directory_entry.rb +13 -3
- data/lib/onlinepayments/sdk/domain/discount.rb +9 -1
- data/lib/onlinepayments/sdk/domain/dpa_data.rb +9 -1
- data/lib/onlinepayments/sdk/domain/dpa_transaction_options.rb +10 -2
- data/lib/onlinepayments/sdk/domain/empty_validator.rb +2 -0
- data/lib/onlinepayments/sdk/domain/error_response.rb +12 -3
- data/lib/onlinepayments/sdk/domain/external_cardholder_authentication_data.rb +36 -10
- data/lib/onlinepayments/sdk/domain/external_token_linked.rb +13 -3
- data/lib/onlinepayments/sdk/domain/feedbacks.rb +12 -3
- data/lib/onlinepayments/sdk/domain/fixed_list_validator.rb +10 -2
- data/lib/onlinepayments/sdk/domain/fraud_fields.rb +14 -4
- data/lib/onlinepayments/sdk/domain/fraud_results.rb +9 -1
- data/lib/onlinepayments/sdk/domain/g_pay_three_d_secure.rb +25 -7
- data/lib/onlinepayments/sdk/domain/get_batch_status_response.rb +15 -4
- data/lib/onlinepayments/sdk/domain/get_hosted_checkout_response.rb +12 -3
- data/lib/onlinepayments/sdk/domain/get_hosted_fields_session_response.rb +12 -3
- data/lib/onlinepayments/sdk/domain/get_hosted_tokenization_response.rb +12 -3
- data/lib/onlinepayments/sdk/domain/get_iin_details_request.rb +12 -3
- data/lib/onlinepayments/sdk/domain/get_iin_details_response.rb +76 -24
- data/lib/onlinepayments/sdk/domain/get_mandate_response.rb +10 -2
- data/lib/onlinepayments/sdk/domain/get_payment_links_by_merchant_group_request.rb +16 -6
- data/lib/onlinepayments/sdk/domain/get_payment_product_groups_response.rb +10 -2
- data/lib/onlinepayments/sdk/domain/get_payment_products_response.rb +10 -2
- data/lib/onlinepayments/sdk/domain/get_privacy_policy_response.rb +9 -1
- data/lib/onlinepayments/sdk/domain/gift_card_purchase.rb +12 -3
- data/lib/onlinepayments/sdk/domain/hosted_checkout_specific_input.rb +48 -16
- data/lib/onlinepayments/sdk/domain/hosted_checkout_specific_output.rb +11 -2
- data/lib/onlinepayments/sdk/domain/iin_detail.rb +72 -22
- data/lib/onlinepayments/sdk/domain/import_cof_series_request.rb +33 -11
- data/lib/onlinepayments/sdk/domain/import_cof_series_response.rb +9 -1
- data/lib/onlinepayments/sdk/domain/increment_authorization_request.rb +10 -2
- data/lib/onlinepayments/sdk/domain/increment_authorization_response.rb +10 -2
- data/lib/onlinepayments/sdk/domain/label_template_element.rb +11 -2
- data/lib/onlinepayments/sdk/domain/length_validator.rb +11 -2
- data/lib/onlinepayments/sdk/domain/line_item.rb +19 -8
- data/lib/onlinepayments/sdk/domain/line_item_detail.rb +13 -3
- data/lib/onlinepayments/sdk/domain/line_item_invoice_data.rb +9 -1
- data/lib/onlinepayments/sdk/domain/loan_recipient.rb +17 -5
- data/lib/onlinepayments/sdk/domain/lodging_data.rb +9 -1
- data/lib/onlinepayments/sdk/domain/mandate_address.rb +17 -5
- data/lib/onlinepayments/sdk/domain/mandate_address_response.rb +17 -5
- data/lib/onlinepayments/sdk/domain/mandate_contact_details.rb +11 -2
- data/lib/onlinepayments/sdk/domain/mandate_customer.rb +21 -9
- data/lib/onlinepayments/sdk/domain/mandate_customer_response.rb +21 -9
- data/lib/onlinepayments/sdk/domain/mandate_merchant_action.rb +12 -3
- data/lib/onlinepayments/sdk/domain/mandate_personal_information.rb +12 -3
- data/lib/onlinepayments/sdk/domain/mandate_personal_information_response.rb +12 -3
- data/lib/onlinepayments/sdk/domain/mandate_personal_name.rb +11 -2
- data/lib/onlinepayments/sdk/domain/mandate_personal_name_response.rb +11 -2
- data/lib/onlinepayments/sdk/domain/mandate_redirect_data.rb +11 -2
- data/lib/onlinepayments/sdk/domain/mandate_response.rb +22 -8
- data/lib/onlinepayments/sdk/domain/market_place.rb +11 -2
- data/lib/onlinepayments/sdk/domain/mastercard.rb +14 -4
- data/lib/onlinepayments/sdk/domain/merchant_action.rb +21 -9
- data/lib/onlinepayments/sdk/domain/mobile_payment_data.rb +11 -2
- data/lib/onlinepayments/sdk/domain/mobile_payment_method_hosted_checkout_specific_input.rb +17 -6
- data/lib/onlinepayments/sdk/domain/mobile_payment_method_specific_input.rb +40 -14
- data/lib/onlinepayments/sdk/domain/mobile_payment_method_specific_output.rb +22 -9
- data/lib/onlinepayments/sdk/domain/mobile_payment_product302_specific_input.rb +17 -6
- data/lib/onlinepayments/sdk/domain/mobile_payment_product320_specific_input.rb +17 -6
- data/lib/onlinepayments/sdk/domain/mobile_three_d_secure_challenge_parameters.rb +15 -4
- data/lib/onlinepayments/sdk/domain/multiple_payment_information.rb +11 -2
- data/lib/onlinepayments/sdk/domain/network_token_data.rb +19 -6
- data/lib/onlinepayments/sdk/domain/network_token_essentials.rb +19 -6
- data/lib/onlinepayments/sdk/domain/network_token_linked.rb +13 -3
- data/lib/onlinepayments/sdk/domain/omnichannel_payment_specific_input.rb +9 -1
- data/lib/onlinepayments/sdk/domain/omnichannel_payout_specific_input.rb +11 -2
- data/lib/onlinepayments/sdk/domain/omnichannel_refund_specific_input.rb +9 -1
- data/lib/onlinepayments/sdk/domain/omnichannel_subsequent_specific_input.rb +9 -1
- data/lib/onlinepayments/sdk/domain/operation_output.rb +34 -12
- data/lib/onlinepayments/sdk/domain/operation_payment_references.rb +24 -6
- data/lib/onlinepayments/sdk/domain/order.rb +44 -18
- data/lib/onlinepayments/sdk/domain/order_line_details.rb +36 -10
- data/lib/onlinepayments/sdk/domain/order_references.rb +30 -8
- data/lib/onlinepayments/sdk/domain/order_status_output.rb +18 -6
- data/lib/onlinepayments/sdk/domain/order_type_information.rb +11 -2
- data/lib/onlinepayments/sdk/domain/other_details.rb +11 -2
- data/lib/onlinepayments/sdk/domain/pagination.rb +11 -2
- data/lib/onlinepayments/sdk/domain/payment_account_on_file.rb +11 -2
- data/lib/onlinepayments/sdk/domain/payment_context.rb +14 -4
- data/lib/onlinepayments/sdk/domain/payment_creation_output.rb +15 -4
- data/lib/onlinepayments/sdk/domain/payment_details_response.rb +23 -10
- data/lib/onlinepayments/sdk/domain/payment_error_response.rb +15 -5
- data/lib/onlinepayments/sdk/domain/payment_link_event.rb +13 -3
- data/lib/onlinepayments/sdk/domain/payment_link_order_input.rb +15 -5
- data/lib/onlinepayments/sdk/domain/payment_link_order_output.rb +15 -5
- data/lib/onlinepayments/sdk/domain/payment_link_overview_entry.rb +37 -11
- data/lib/onlinepayments/sdk/domain/payment_link_overview_filtering.rb +13 -4
- data/lib/onlinepayments/sdk/domain/payment_link_overview_response.rb +15 -5
- data/lib/onlinepayments/sdk/domain/payment_link_overview_sorting.rb +11 -2
- data/lib/onlinepayments/sdk/domain/payment_link_response.rb +38 -12
- data/lib/onlinepayments/sdk/domain/payment_link_specific_input.rb +13 -3
- data/lib/onlinepayments/sdk/domain/payment_output.rb +61 -25
- data/lib/onlinepayments/sdk/domain/payment_output_summary.rb +18 -7
- data/lib/onlinepayments/sdk/domain/payment_product.rb +55 -21
- data/lib/onlinepayments/sdk/domain/payment_product11.rb +17 -5
- data/lib/onlinepayments/sdk/domain/payment_product130_specific_input.rb +10 -2
- data/lib/onlinepayments/sdk/domain/payment_product130_specific_three_d_secure.rb +15 -4
- data/lib/onlinepayments/sdk/domain/payment_product3012.rb +11 -2
- data/lib/onlinepayments/sdk/domain/payment_product3012_specific_input.rb +15 -4
- data/lib/onlinepayments/sdk/domain/payment_product3013_specific_input.rb +13 -3
- data/lib/onlinepayments/sdk/domain/payment_product302_specific_data.rb +10 -2
- data/lib/onlinepayments/sdk/domain/payment_product3203_specific_output.rb +13 -4
- data/lib/onlinepayments/sdk/domain/payment_product3204_specific_output.rb +9 -1
- data/lib/onlinepayments/sdk/domain/payment_product3208_specific_input.rb +9 -1
- data/lib/onlinepayments/sdk/domain/payment_product3208_specific_output.rb +9 -1
- data/lib/onlinepayments/sdk/domain/payment_product3209_specific_input.rb +9 -1
- data/lib/onlinepayments/sdk/domain/payment_product3209_specific_output.rb +9 -1
- data/lib/onlinepayments/sdk/domain/payment_product320_specific_data.rb +12 -3
- data/lib/onlinepayments/sdk/domain/payment_product350.rb +11 -2
- data/lib/onlinepayments/sdk/domain/payment_product5001.rb +11 -2
- data/lib/onlinepayments/sdk/domain/payment_product5001_specific_output.rb +17 -5
- data/lib/onlinepayments/sdk/domain/payment_product5002_specific_data.rb +10 -2
- data/lib/onlinepayments/sdk/domain/payment_product5002_specific_input.rb +11 -2
- data/lib/onlinepayments/sdk/domain/payment_product5002default_brand_parameters.rb +11 -2
- data/lib/onlinepayments/sdk/domain/payment_product5100_specific_input.rb +9 -1
- data/lib/onlinepayments/sdk/domain/payment_product5402_specific_output.rb +9 -1
- data/lib/onlinepayments/sdk/domain/payment_product5404.rb +11 -2
- data/lib/onlinepayments/sdk/domain/payment_product5407.rb +11 -2
- data/lib/onlinepayments/sdk/domain/payment_product5407_auto_capture.rb +6 -1
- data/lib/onlinepayments/sdk/domain/payment_product5412.rb +13 -3
- data/lib/onlinepayments/sdk/domain/payment_product5500_specific_output.rb +15 -4
- data/lib/onlinepayments/sdk/domain/payment_product5704_auto_capture.rb +9 -1
- data/lib/onlinepayments/sdk/domain/payment_product771_specific_output.rb +9 -1
- data/lib/onlinepayments/sdk/domain/payment_product840.rb +9 -1
- data/lib/onlinepayments/sdk/domain/payment_product840_customer_account.rb +30 -8
- data/lib/onlinepayments/sdk/domain/payment_product840_specific_output.rb +33 -13
- data/lib/onlinepayments/sdk/domain/payment_product_display_hints.rb +13 -3
- data/lib/onlinepayments/sdk/domain/payment_product_field.rb +17 -6
- data/lib/onlinepayments/sdk/domain/payment_product_field_data_restrictions.rb +12 -3
- data/lib/onlinepayments/sdk/domain/payment_product_field_display_element.rb +15 -4
- data/lib/onlinepayments/sdk/domain/payment_product_field_display_hints.rb +38 -12
- data/lib/onlinepayments/sdk/domain/payment_product_field_form_element.rb +12 -3
- data/lib/onlinepayments/sdk/domain/payment_product_field_tooltip.rb +11 -2
- data/lib/onlinepayments/sdk/domain/payment_product_field_validators.rb +42 -18
- data/lib/onlinepayments/sdk/domain/payment_product_filter.rb +13 -4
- data/lib/onlinepayments/sdk/domain/payment_product_filter_hosted_tokenization.rb +10 -2
- data/lib/onlinepayments/sdk/domain/payment_product_filters_hosted_checkout.rb +13 -4
- data/lib/onlinepayments/sdk/domain/payment_product_filters_hosted_fields.rb +13 -4
- data/lib/onlinepayments/sdk/domain/payment_product_filters_hosted_tokenization.rb +13 -4
- data/lib/onlinepayments/sdk/domain/payment_product_group.rb +18 -7
- data/lib/onlinepayments/sdk/domain/payment_product_networks_response.rb +10 -2
- data/lib/onlinepayments/sdk/domain/payment_product_session302_specific_input.rb +11 -2
- data/lib/onlinepayments/sdk/domain/payment_product_session302_specific_output.rb +9 -1
- data/lib/onlinepayments/sdk/domain/payment_product_session_request.rb +10 -2
- data/lib/onlinepayments/sdk/domain/payment_product_session_response.rb +10 -2
- data/lib/onlinepayments/sdk/domain/payment_references.rb +27 -7
- data/lib/onlinepayments/sdk/domain/payment_response.rb +32 -12
- data/lib/onlinepayments/sdk/domain/payment_status_output.rb +28 -8
- data/lib/onlinepayments/sdk/domain/payment_status_output_summary.rb +16 -5
- data/lib/onlinepayments/sdk/domain/payment_summary.rb +17 -6
- data/lib/onlinepayments/sdk/domain/payments_report_response.rb +13 -4
- data/lib/onlinepayments/sdk/domain/payout_card_payment_method_specific_output.rb +17 -6
- data/lib/onlinepayments/sdk/domain/payout_error_response.rb +15 -5
- data/lib/onlinepayments/sdk/domain/payout_output.rb +27 -9
- data/lib/onlinepayments/sdk/domain/payout_response.rb +17 -6
- data/lib/onlinepayments/sdk/domain/payout_result.rb +17 -6
- data/lib/onlinepayments/sdk/domain/payout_status_output.rb +13 -3
- data/lib/onlinepayments/sdk/domain/pending_authentication.rb +9 -1
- data/lib/onlinepayments/sdk/domain/personal_information.rb +14 -4
- data/lib/onlinepayments/sdk/domain/personal_information_token.rb +10 -2
- data/lib/onlinepayments/sdk/domain/personal_name.rb +13 -3
- data/lib/onlinepayments/sdk/domain/personal_name_token.rb +11 -2
- data/lib/onlinepayments/sdk/domain/problem_details_response.rb +17 -5
- data/lib/onlinepayments/sdk/domain/product302_recurring.rb +9 -1
- data/lib/onlinepayments/sdk/domain/product320_recurring.rb +9 -1
- data/lib/onlinepayments/sdk/domain/product_directory.rb +10 -2
- data/lib/onlinepayments/sdk/domain/protection_eligibility.rb +11 -2
- data/lib/onlinepayments/sdk/domain/range_validator.rb +11 -2
- data/lib/onlinepayments/sdk/domain/rate_details.rb +17 -5
- data/lib/onlinepayments/sdk/domain/reattempt_instructions.rb +14 -4
- data/lib/onlinepayments/sdk/domain/reattempt_instructions_conditions.rb +11 -2
- data/lib/onlinepayments/sdk/domain/redirect_data.rb +11 -2
- data/lib/onlinepayments/sdk/domain/redirect_payment_method_specific_input.rb +117 -53
- data/lib/onlinepayments/sdk/domain/redirect_payment_method_specific_output.rb +50 -20
- data/lib/onlinepayments/sdk/domain/redirect_payment_product11_specific_input.rb +9 -1
- data/lib/onlinepayments/sdk/domain/redirect_payment_product3103_specific_input.rb +9 -1
- data/lib/onlinepayments/sdk/domain/redirect_payment_product3112_specific_input.rb +9 -1
- data/lib/onlinepayments/sdk/domain/redirect_payment_product3116_specific_input.rb +9 -1
- data/lib/onlinepayments/sdk/domain/redirect_payment_product3203_specific_input.rb +9 -1
- data/lib/onlinepayments/sdk/domain/redirect_payment_product3204_specific_input.rb +11 -2
- data/lib/onlinepayments/sdk/domain/redirect_payment_product3302_specific_input.rb +13 -3
- data/lib/onlinepayments/sdk/domain/redirect_payment_product3306_specific_input.rb +9 -1
- data/lib/onlinepayments/sdk/domain/redirect_payment_product3307_specific_input.rb +2 -0
- data/lib/onlinepayments/sdk/domain/redirect_payment_product5001_specific_input.rb +11 -2
- data/lib/onlinepayments/sdk/domain/redirect_payment_product5300_specific_input.rb +33 -9
- data/lib/onlinepayments/sdk/domain/redirect_payment_product5301_specific_input.rb +9 -1
- data/lib/onlinepayments/sdk/domain/redirect_payment_product5402_specific_input.rb +9 -1
- data/lib/onlinepayments/sdk/domain/redirect_payment_product5403_specific_input.rb +9 -1
- data/lib/onlinepayments/sdk/domain/redirect_payment_product5406_specific_input.rb +10 -2
- data/lib/onlinepayments/sdk/domain/redirect_payment_product5407_specific_input.rb +10 -2
- data/lib/onlinepayments/sdk/domain/redirect_payment_product5408_specific_input.rb +12 -3
- data/lib/onlinepayments/sdk/domain/redirect_payment_product5410_specific_input.rb +9 -1
- data/lib/onlinepayments/sdk/domain/redirect_payment_product5412_specific_input.rb +11 -2
- data/lib/onlinepayments/sdk/domain/redirect_payment_product5601_specific_input.rb +9 -1
- data/lib/onlinepayments/sdk/domain/redirect_payment_product809_specific_input.rb +9 -1
- data/lib/onlinepayments/sdk/domain/redirect_payment_product840_specific_input.rb +15 -4
- data/lib/onlinepayments/sdk/domain/redirect_payment_product900_specific_input.rb +9 -1
- data/lib/onlinepayments/sdk/domain/redirection_data.rb +9 -1
- data/lib/onlinepayments/sdk/domain/refund_card_method_specific_output.rb +27 -9
- data/lib/onlinepayments/sdk/domain/refund_e_wallet_method_specific_output.rb +14 -4
- data/lib/onlinepayments/sdk/domain/refund_error_response.rb +15 -5
- data/lib/onlinepayments/sdk/domain/refund_mobile_method_specific_output.rb +13 -3
- data/lib/onlinepayments/sdk/domain/refund_output.rb +49 -19
- data/lib/onlinepayments/sdk/domain/refund_payment_batch_request.rb +12 -3
- data/lib/onlinepayments/sdk/domain/refund_payment_product840_customer_account.rb +13 -3
- data/lib/onlinepayments/sdk/domain/refund_payment_product840_specific_output.rb +10 -2
- data/lib/onlinepayments/sdk/domain/refund_redirect_method_specific_output.rb +11 -2
- data/lib/onlinepayments/sdk/domain/refund_redirect_payment_method_specific_input.rb +10 -2
- data/lib/onlinepayments/sdk/domain/refund_redirect_payment_product900_specific_input.rb +9 -1
- data/lib/onlinepayments/sdk/domain/refund_request.rb +39 -15
- data/lib/onlinepayments/sdk/domain/refund_response.rb +17 -6
- data/lib/onlinepayments/sdk/domain/refunds_response.rb +10 -2
- data/lib/onlinepayments/sdk/domain/regular_expression_validator.rb +9 -1
- data/lib/onlinepayments/sdk/domain/revoke_mandate_request.rb +9 -1
- data/lib/onlinepayments/sdk/domain/send_test_request.rb +9 -1
- data/lib/onlinepayments/sdk/domain/sepa_direct_debit_payment_method_specific_input.rb +12 -3
- data/lib/onlinepayments/sdk/domain/sepa_direct_debit_payment_method_specific_input_base.rb +12 -3
- data/lib/onlinepayments/sdk/domain/sepa_direct_debit_payment_method_specific_output.rb +15 -5
- data/lib/onlinepayments/sdk/domain/sepa_direct_debit_payment_product771_specific_input.rb +12 -3
- data/lib/onlinepayments/sdk/domain/sepa_direct_debit_payment_product771_specific_input_base.rb +12 -3
- data/lib/onlinepayments/sdk/domain/session_data.rb +18 -6
- data/lib/onlinepayments/sdk/domain/session_details.rb +11 -2
- data/lib/onlinepayments/sdk/domain/session_request.rb +10 -2
- data/lib/onlinepayments/sdk/domain/session_response.rb +18 -6
- data/lib/onlinepayments/sdk/domain/share_payment_link_request.rb +13 -3
- data/lib/onlinepayments/sdk/domain/shipping.rb +35 -11
- data/lib/onlinepayments/sdk/domain/shipping_detail.rb +11 -2
- data/lib/onlinepayments/sdk/domain/shipping_method.rb +15 -4
- data/lib/onlinepayments/sdk/domain/shopping_cart.rb +27 -9
- data/lib/onlinepayments/sdk/domain/shopping_cart_extension.rb +16 -13
- data/lib/onlinepayments/sdk/domain/show_form_data.rb +42 -18
- data/lib/onlinepayments/sdk/domain/show_instructions_data.rb +9 -1
- data/lib/onlinepayments/sdk/domain/split_payment_product_filter.rb +10 -2
- data/lib/onlinepayments/sdk/domain/split_payment_product_filters_hosted_checkout.rb +13 -4
- data/lib/onlinepayments/sdk/domain/sub_merchant.rb +20 -7
- data/lib/onlinepayments/sdk/domain/submit_batch_request_body.rb +38 -16
- data/lib/onlinepayments/sdk/domain/submit_batch_response.rb +11 -2
- data/lib/onlinepayments/sdk/domain/subsequent_card_payment_method_specific_input.rb +32 -10
- data/lib/onlinepayments/sdk/domain/subsequent_payment_batch_request.rb +12 -3
- data/lib/onlinepayments/sdk/domain/subsequent_payment_product5001_specific_input.rb +9 -1
- data/lib/onlinepayments/sdk/domain/subsequent_payment_request.rb +22 -8
- data/lib/onlinepayments/sdk/domain/subsequent_payment_response.rb +10 -2
- data/lib/onlinepayments/sdk/domain/surcharge.rb +23 -10
- data/lib/onlinepayments/sdk/domain/surcharge_calculation_card.rb +11 -2
- data/lib/onlinepayments/sdk/domain/surcharge_for_payment_link.rb +9 -1
- data/lib/onlinepayments/sdk/domain/surcharge_rate.rb +15 -4
- data/lib/onlinepayments/sdk/domain/surcharge_specific_input.rb +12 -3
- data/lib/onlinepayments/sdk/domain/surcharge_specific_output.rb +15 -5
- data/lib/onlinepayments/sdk/domain/test_connection.rb +9 -1
- data/lib/onlinepayments/sdk/domain/three_d_secure.rb +45 -15
- data/lib/onlinepayments/sdk/domain/three_d_secure_base.rb +34 -10
- data/lib/onlinepayments/sdk/domain/three_d_secure_data.rb +13 -3
- data/lib/onlinepayments/sdk/domain/three_d_secure_results.rb +45 -13
- data/lib/onlinepayments/sdk/domain/three_ds_input_data.rb +13 -3
- data/lib/onlinepayments/sdk/domain/token_card.rb +12 -3
- data/lib/onlinepayments/sdk/domain/token_card_data.rb +15 -5
- data/lib/onlinepayments/sdk/domain/token_card_specific_input.rb +10 -2
- data/lib/onlinepayments/sdk/domain/token_data.rb +12 -3
- data/lib/onlinepayments/sdk/domain/token_e_wallet.rb +12 -3
- data/lib/onlinepayments/sdk/domain/token_info.rb +15 -4
- data/lib/onlinepayments/sdk/domain/token_response.rb +35 -13
- data/lib/onlinepayments/sdk/domain/transaction.rb +10 -2
- data/lib/onlinepayments/sdk/domain/update_authorization_additional_data_request.rb +10 -2
- data/lib/onlinepayments/sdk/domain/uploadable_file.rb +6 -8
- data/lib/onlinepayments/sdk/domain/validate_credentials_request.rb +11 -2
- data/lib/onlinepayments/sdk/domain/validate_credentials_response.rb +9 -1
- data/lib/onlinepayments/sdk/domain/value_mapping_element.rb +12 -3
- data/lib/onlinepayments/sdk/domain/visa.rb +18 -6
- data/lib/onlinepayments/sdk/domain/visa_authentication_options.rb +13 -3
- data/lib/onlinepayments/sdk/domain.rb +2 -0
- data/lib/onlinepayments/sdk/exception_factory.rb +3 -1
- data/lib/onlinepayments/sdk/factory.rb +131 -52
- data/lib/onlinepayments/sdk/idempotence_exception.rb +2 -0
- data/lib/onlinepayments/sdk/json/default_marshaller.rb +7 -5
- data/lib/onlinepayments/sdk/json/marshaller.rb +2 -1
- data/lib/onlinepayments/sdk/json/marshaller_syntax_exception.rb +2 -0
- data/lib/onlinepayments/sdk/json.rb +2 -0
- data/lib/onlinepayments/sdk/logging/communicator_logger.rb +4 -3
- data/lib/onlinepayments/sdk/logging/log_message_builder.rb +76 -69
- data/lib/onlinepayments/sdk/logging/logging_capable.rb +2 -1
- data/lib/onlinepayments/sdk/logging/obfuscation/body_obfuscator.rb +50 -49
- data/lib/onlinepayments/sdk/logging/obfuscation/header_obfuscator.rb +12 -15
- data/lib/onlinepayments/sdk/logging/obfuscation/obfuscation_capable.rb +27 -5
- data/lib/onlinepayments/sdk/logging/obfuscation/obfuscation_rule.rb +14 -16
- data/lib/onlinepayments/sdk/logging/obfuscation.rb +2 -0
- data/lib/onlinepayments/sdk/logging/request_log_message_builder.rb +18 -14
- data/lib/onlinepayments/sdk/logging/response_log_message_builder.rb +15 -13
- data/lib/onlinepayments/sdk/logging/ruby_communicator_logger.rb +12 -13
- data/lib/onlinepayments/sdk/logging/stdout_communicator_logger.rb +7 -5
- data/lib/onlinepayments/sdk/logging.rb +2 -0
- data/lib/onlinepayments/sdk/merchant/captures/captures_client.rb +2 -0
- data/lib/onlinepayments/sdk/merchant/captures.rb +2 -0
- data/lib/onlinepayments/sdk/merchant/cofseries/cof_series_client.rb +2 -0
- data/lib/onlinepayments/sdk/merchant/cofseries.rb +2 -0
- data/lib/onlinepayments/sdk/merchant/complete/complete_client.rb +2 -0
- data/lib/onlinepayments/sdk/merchant/complete.rb +2 -0
- data/lib/onlinepayments/sdk/merchant/hostedcheckout/hosted_checkout_client.rb +2 -0
- data/lib/onlinepayments/sdk/merchant/hostedcheckout.rb +2 -0
- data/lib/onlinepayments/sdk/merchant/hostedfields/hosted_fields_client.rb +2 -0
- data/lib/onlinepayments/sdk/merchant/hostedfields.rb +2 -0
- data/lib/onlinepayments/sdk/merchant/hostedtokenization/hosted_tokenization_client.rb +2 -0
- data/lib/onlinepayments/sdk/merchant/hostedtokenization.rb +2 -0
- data/lib/onlinepayments/sdk/merchant/mandates/mandates_client.rb +2 -0
- data/lib/onlinepayments/sdk/merchant/mandates.rb +2 -0
- data/lib/onlinepayments/sdk/merchant/merchant_client.rb +6 -0
- data/lib/onlinepayments/sdk/merchant/merchantbatch/get_payments_report_params.rb +9 -0
- data/lib/onlinepayments/sdk/merchant/merchantbatch/merchant_batch_client.rb +2 -0
- data/lib/onlinepayments/sdk/merchant/merchantbatch.rb +2 -0
- data/lib/onlinepayments/sdk/merchant/paymentlinks/payment_links_client.rb +2 -0
- data/lib/onlinepayments/sdk/merchant/paymentlinks.rb +2 -0
- data/lib/onlinepayments/sdk/merchant/payments/payments_client.rb +2 -0
- data/lib/onlinepayments/sdk/merchant/payments.rb +2 -0
- data/lib/onlinepayments/sdk/merchant/payouts/payouts_client.rb +2 -0
- data/lib/onlinepayments/sdk/merchant/payouts.rb +2 -0
- data/lib/onlinepayments/sdk/merchant/preauthorization/pre_authorization_client.rb +2 -0
- data/lib/onlinepayments/sdk/merchant/preauthorization.rb +2 -0
- data/lib/onlinepayments/sdk/merchant/privacypolicy/get_privacy_policy_params.rb +9 -0
- data/lib/onlinepayments/sdk/merchant/privacypolicy/privacy_policy_client.rb +2 -0
- data/lib/onlinepayments/sdk/merchant/privacypolicy.rb +2 -0
- data/lib/onlinepayments/sdk/merchant/productgroups/get_product_group_params.rb +13 -0
- data/lib/onlinepayments/sdk/merchant/productgroups/get_product_groups_params.rb +13 -0
- data/lib/onlinepayments/sdk/merchant/productgroups/product_groups_client.rb +2 -0
- data/lib/onlinepayments/sdk/merchant/productgroups.rb +2 -0
- data/lib/onlinepayments/sdk/merchant/products/get_payment_product_networks_params.rb +11 -0
- data/lib/onlinepayments/sdk/merchant/products/get_payment_product_params.rb +14 -0
- data/lib/onlinepayments/sdk/merchant/products/get_payment_products_params.rb +14 -0
- data/lib/onlinepayments/sdk/merchant/products/get_product_directory_params.rb +9 -0
- data/lib/onlinepayments/sdk/merchant/products/products_client.rb +2 -0
- data/lib/onlinepayments/sdk/merchant/products.rb +2 -0
- data/lib/onlinepayments/sdk/merchant/refunds/refunds_client.rb +2 -0
- data/lib/onlinepayments/sdk/merchant/refunds.rb +2 -0
- data/lib/onlinepayments/sdk/merchant/services/services_client.rb +2 -0
- data/lib/onlinepayments/sdk/merchant/services.rb +2 -0
- data/lib/onlinepayments/sdk/merchant/sessions/sessions_client.rb +2 -0
- data/lib/onlinepayments/sdk/merchant/sessions.rb +2 -0
- data/lib/onlinepayments/sdk/merchant/subsequent/subsequent_client.rb +2 -0
- data/lib/onlinepayments/sdk/merchant/subsequent.rb +2 -0
- data/lib/onlinepayments/sdk/merchant/tokenization/get_card_data_by_payments_params.rb +8 -0
- data/lib/onlinepayments/sdk/merchant/tokenization/get_card_data_by_tokens_params.rb +8 -0
- data/lib/onlinepayments/sdk/merchant/tokenization/tokenization_client.rb +2 -0
- data/lib/onlinepayments/sdk/merchant/tokenization.rb +2 -0
- data/lib/onlinepayments/sdk/merchant/tokens/tokens_client.rb +2 -0
- data/lib/onlinepayments/sdk/merchant/tokens.rb +2 -0
- data/lib/onlinepayments/sdk/merchant/webhooks/webhooks_client.rb +2 -0
- data/lib/onlinepayments/sdk/merchant/webhooks.rb +2 -0
- data/lib/onlinepayments/sdk/merchant.rb +2 -0
- data/lib/onlinepayments/sdk/platform_exception.rb +2 -0
- data/lib/onlinepayments/sdk/problem_details_exception.rb +2 -0
- data/lib/onlinepayments/sdk/proxy_configuration.rb +22 -18
- data/lib/onlinepayments/sdk/reference_exception.rb +2 -0
- data/lib/onlinepayments/sdk/validation_exception.rb +2 -0
- data/lib/onlinepayments/sdk/version.rb +8 -0
- data/lib/onlinepayments/sdk/webhooks/api_version_mismatch_exception.rb +3 -3
- data/lib/onlinepayments/sdk/webhooks/in_memory_secret_key_store.rb +7 -4
- data/lib/onlinepayments/sdk/webhooks/secret_key_not_available_exception.rb +4 -2
- data/lib/onlinepayments/sdk/webhooks/secret_key_store.rb +2 -1
- data/lib/onlinepayments/sdk/webhooks/signature_validation_exception.rb +2 -1
- data/lib/onlinepayments/sdk/webhooks/signature_validator.rb +13 -10
- data/lib/onlinepayments/sdk/webhooks/webhooks_event.rb +38 -62
- data/lib/onlinepayments/sdk/webhooks/webhooks_helper.rb +3 -1
- data/lib/onlinepayments/sdk/webhooks.rb +2 -0
- data/lib/onlinepayments/sdk.rb +2 -0
- data/onlinepayments-sdk-ruby.gemspec +13 -8
- data/skills/worldline-direct/SKILL.md +85 -0
- data/skills/worldline-direct/examples/after_payment_operations_example.rb +75 -0
- data/skills/worldline-direct/examples/app_types.rb +170 -0
- data/skills/worldline-direct/examples/client_integration_example.rb +76 -0
- data/skills/worldline-direct/examples/client_setup.rb +57 -0
- data/skills/worldline-direct/examples/create_payment_response_handler.rb +32 -0
- data/skills/worldline-direct/examples/customer_device.rb +32 -0
- data/skills/worldline-direct/examples/error_handling_example.rb +99 -0
- data/skills/worldline-direct/examples/hosted_checkout_example.rb +181 -0
- data/skills/worldline-direct/examples/hosted_fields_example.rb +82 -0
- data/skills/worldline-direct/examples/hosted_tokenization_example.rb +79 -0
- data/skills/worldline-direct/examples/payment_attempt.rb +30 -0
- data/skills/worldline-direct/examples/payment_links_example.rb +52 -0
- data/skills/worldline-direct/examples/payment_status_example.rb +62 -0
- data/skills/worldline-direct/examples/recurring_payments_example.rb +127 -0
- data/skills/worldline-direct/examples/server_to_server_example.rb +81 -0
- data/skills/worldline-direct/examples/webhook_event_processor.rb +40 -0
- data/skills/worldline-direct/examples/webhooks_endpoint.rb +73 -0
- data/skills/worldline-direct/examples/webhooks_setup.rb +41 -0
- data/skills/worldline-direct/references/errors.md +113 -0
- data/skills/worldline-direct/references/flows.md +966 -0
- data/skills/worldline-direct/references/ruby.md +209 -0
- data/skills/worldline-direct/references/webhooks.md +167 -0
- metadata +100 -23
- data/lib/onlinepayments/sdk/domain/credit_card_validation_rules_hosted_tokenization.rb +0 -37
- data/lib/onlinepayments/sdk/domain/payment_links_response.rb +0 -35
- data/lib/onlinepayments/sdk/domain/shopping_cart_output.rb +0 -35
- data/lib/onlinepayments/sdk/merchant/paymentlinks/get_payment_links_in_bulk_params.rb +0 -28
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module OnlinePayments
|
|
2
4
|
module SDK
|
|
3
5
|
module Webhooks
|
|
4
6
|
# Raised when an error occurred when validating Webhooks signatures
|
|
5
7
|
class SignatureValidationException < RuntimeError
|
|
6
|
-
|
|
7
8
|
# Creates a new SignatureValidationException
|
|
8
9
|
#
|
|
9
10
|
# @param [Hash] args the options to create the Exception with
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'base64'
|
|
2
4
|
require 'openssl'
|
|
3
5
|
require 'onlinepayments/sdk/webhooks/signature_validation_exception'
|
|
@@ -5,11 +7,11 @@ require 'onlinepayments/sdk/webhooks/signature_validation_exception'
|
|
|
5
7
|
module OnlinePayments
|
|
6
8
|
module SDK
|
|
7
9
|
module Webhooks
|
|
8
|
-
|
|
9
10
|
# Validator for webhooks signatures. Thread-safe.
|
|
10
11
|
class SignatureValidator
|
|
11
12
|
def initialize(secret_key_store)
|
|
12
13
|
raise ArgumentError if secret_key_store.nil?
|
|
14
|
+
|
|
13
15
|
@secret_key_store = secret_key_store
|
|
14
16
|
end
|
|
15
17
|
|
|
@@ -21,11 +23,12 @@ module OnlinePayments
|
|
|
21
23
|
validate_body(body, request_headers)
|
|
22
24
|
end
|
|
23
25
|
|
|
24
|
-
|
|
26
|
+
HEADER_SIGNATURE = 'X-GCS-Signature'
|
|
27
|
+
HEADER_KEY_ID = 'X-GCS-KeyId'
|
|
28
|
+
HMAC_SCHEME = 'SHA256'
|
|
29
|
+
private_constant :HEADER_SIGNATURE, :HEADER_KEY_ID, :HMAC_SCHEME
|
|
25
30
|
|
|
26
|
-
|
|
27
|
-
HEADER_KEY_ID = 'X-GCS-KeyId'.freeze
|
|
28
|
-
HMAC_SCHEME = 'SHA256'.freeze
|
|
31
|
+
private
|
|
29
32
|
|
|
30
33
|
# Validates the body using given request headers
|
|
31
34
|
#
|
|
@@ -39,10 +42,10 @@ module OnlinePayments
|
|
|
39
42
|
hmac = OpenSSL::HMAC.digest(digest, secret_key, body)
|
|
40
43
|
expected_signature = Base64.strict_encode64(hmac).strip
|
|
41
44
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
return if equal_signatures?(signature, expected_signature)
|
|
46
|
+
|
|
47
|
+
msg = "failed to validate signature '#{signature}'"
|
|
48
|
+
raise SignatureValidationException.new(message: msg)
|
|
46
49
|
end
|
|
47
50
|
|
|
48
51
|
# Checks two signatures
|
|
@@ -57,7 +60,7 @@ module OnlinePayments
|
|
|
57
60
|
limit = [signature.length, expected_signature.length, 256].max
|
|
58
61
|
limit.times.inject(true) do |flag, idx|
|
|
59
62
|
# NOTE: this block is constructed to take constant time to run
|
|
60
|
-
flag
|
|
63
|
+
flag & (signature[idx] == expected_signature[idx])
|
|
61
64
|
# [] returns nil if idx >= the length of the String
|
|
62
65
|
end
|
|
63
66
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'onlinepayments/sdk/domain/data_object'
|
|
2
4
|
require 'onlinepayments/sdk/domain/get_batch_status_response'
|
|
3
5
|
require 'onlinepayments/sdk/domain/payment_link_response'
|
|
@@ -14,37 +16,31 @@ module OnlinePayments
|
|
|
14
16
|
# @attr [String] id
|
|
15
17
|
# @attr [String] merchant_id
|
|
16
18
|
# @attr [String] type
|
|
17
|
-
# @attr [OnlinePayments::SDK::
|
|
18
|
-
# @attr [OnlinePayments::SDK::
|
|
19
|
-
# @attr [OnlinePayments::SDK::
|
|
20
|
-
# @attr [OnlinePayments::SDK::
|
|
21
|
-
# @attr [OnlinePayments::SDK::
|
|
22
|
-
# @attr [OnlinePayments::SDK::
|
|
19
|
+
# @attr [OnlinePayments::SDK::Domain::GetBatchStatusResponse] direct_batch
|
|
20
|
+
# @attr [OnlinePayments::SDK::Domain::PaymentLinkResponse] payment_link
|
|
21
|
+
# @attr [OnlinePayments::SDK::Domain::PaymentResponse] payment
|
|
22
|
+
# @attr [OnlinePayments::SDK::Domain::PayoutResponse] payout
|
|
23
|
+
# @attr [OnlinePayments::SDK::Domain::RefundResponse] refund
|
|
24
|
+
# @attr [OnlinePayments::SDK::Domain::TokenResponse] token
|
|
23
25
|
class WebhooksEvent < OnlinePayments::SDK::Domain::DataObject
|
|
26
|
+
attr_accessor :api_version, :created, :id, :merchant_id, :type, :direct_batch, :payment_link, :payment, :payout, :refund, :token
|
|
24
27
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
attr_accessor :payment
|
|
42
|
-
|
|
43
|
-
attr_accessor :payout
|
|
44
|
-
|
|
45
|
-
attr_accessor :refund
|
|
46
|
-
|
|
47
|
-
attr_accessor :token
|
|
28
|
+
# Creates a new instance; every attribute can be given as a keyword argument.
|
|
29
|
+
def initialize(api_version: nil, created: nil, id: nil, merchant_id: nil, type: nil, direct_batch: nil,
|
|
30
|
+
payment_link: nil, payment: nil, payout: nil, refund: nil, token: nil)
|
|
31
|
+
super()
|
|
32
|
+
@api_version = api_version
|
|
33
|
+
@created = created
|
|
34
|
+
@id = id
|
|
35
|
+
@merchant_id = merchant_id
|
|
36
|
+
@type = type
|
|
37
|
+
@direct_batch = direct_batch
|
|
38
|
+
@payment_link = payment_link
|
|
39
|
+
@payment = payment
|
|
40
|
+
@payout = payout
|
|
41
|
+
@refund = refund
|
|
42
|
+
@token = token
|
|
43
|
+
end
|
|
48
44
|
|
|
49
45
|
# @return (Hash)
|
|
50
46
|
def to_h
|
|
@@ -65,39 +61,19 @@ module OnlinePayments
|
|
|
65
61
|
|
|
66
62
|
def from_hash(hash)
|
|
67
63
|
super
|
|
68
|
-
if hash.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if hash.
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if hash.
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if hash.
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
@type = hash['type']
|
|
82
|
-
end
|
|
83
|
-
if hash.has_key? 'directBatch'
|
|
84
|
-
@direct_batch = OnlinePayments::SDK::Domain::GetBatchStatusResponse.new_from_hash(hash['directBatch'])
|
|
85
|
-
end
|
|
86
|
-
if hash.has_key? 'paymentLink'
|
|
87
|
-
@payment_link = OnlinePayments::SDK::Domain::PaymentLinkResponse.new_from_hash(hash['paymentLink'])
|
|
88
|
-
end
|
|
89
|
-
if hash.has_key? 'payment'
|
|
90
|
-
@payment = OnlinePayments::SDK::Domain::PaymentResponse.new_from_hash(hash['payment'])
|
|
91
|
-
end
|
|
92
|
-
if hash.has_key? 'payout'
|
|
93
|
-
@payout = OnlinePayments::SDK::Domain::PayoutResponse.new_from_hash(hash['payout'])
|
|
94
|
-
end
|
|
95
|
-
if hash.has_key? 'refund'
|
|
96
|
-
@refund = OnlinePayments::SDK::Domain::RefundResponse.new_from_hash(hash['refund'])
|
|
97
|
-
end
|
|
98
|
-
if hash.has_key? 'token'
|
|
99
|
-
@token = OnlinePayments::SDK::Domain::TokenResponse.new_from_hash(hash['token'])
|
|
100
|
-
end
|
|
64
|
+
@api_version = hash['apiVersion'] if hash.key? 'apiVersion'
|
|
65
|
+
@created = hash['created'] if hash.key? 'created'
|
|
66
|
+
@id = hash['id'] if hash.key? 'id'
|
|
67
|
+
@merchant_id = hash['merchantId'] if hash.key? 'merchantId'
|
|
68
|
+
@type = hash['type'] if hash.key? 'type'
|
|
69
|
+
@direct_batch = OnlinePayments::SDK::Domain::GetBatchStatusResponse.new_from_hash(hash['directBatch']) if hash.key? 'directBatch'
|
|
70
|
+
@payment_link = OnlinePayments::SDK::Domain::PaymentLinkResponse.new_from_hash(hash['paymentLink']) if hash.key? 'paymentLink'
|
|
71
|
+
@payment = OnlinePayments::SDK::Domain::PaymentResponse.new_from_hash(hash['payment']) if hash.key? 'payment'
|
|
72
|
+
@payout = OnlinePayments::SDK::Domain::PayoutResponse.new_from_hash(hash['payout']) if hash.key? 'payout'
|
|
73
|
+
@refund = OnlinePayments::SDK::Domain::RefundResponse.new_from_hash(hash['refund']) if hash.key? 'refund'
|
|
74
|
+
return unless hash.key? 'token'
|
|
75
|
+
|
|
76
|
+
@token = OnlinePayments::SDK::Domain::TokenResponse.new_from_hash(hash['token'])
|
|
101
77
|
end
|
|
102
78
|
end
|
|
103
79
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'onlinepayments/sdk/webhooks/webhooks_event'
|
|
2
4
|
require 'onlinepayments/sdk/webhooks/api_version_mismatch_exception'
|
|
3
5
|
require 'onlinepayments/sdk/webhooks/signature_validator'
|
|
@@ -9,6 +11,7 @@ module OnlinePayments
|
|
|
9
11
|
class WebhooksHelper
|
|
10
12
|
def initialize(marshaller, secret_key_store)
|
|
11
13
|
raise ArgumentError if marshaller.nil?
|
|
14
|
+
|
|
12
15
|
@marshaller = marshaller
|
|
13
16
|
@signature_validator = OnlinePayments::SDK::Webhooks::SignatureValidator.new(secret_key_store)
|
|
14
17
|
end
|
|
@@ -33,6 +36,5 @@ module OnlinePayments
|
|
|
33
36
|
end
|
|
34
37
|
end
|
|
35
38
|
end
|
|
36
|
-
|
|
37
39
|
end
|
|
38
40
|
end
|
data/lib/onlinepayments/sdk.rb
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
require_relative 'lib/onlinepayments/sdk/version'
|
|
2
|
+
|
|
1
3
|
Gem::Specification.new do |spec|
|
|
2
4
|
spec.name = 'onlinepayments-sdk-ruby'
|
|
3
|
-
spec.version =
|
|
5
|
+
spec.version = OnlinePayments::SDK::VERSION
|
|
4
6
|
spec.authors = ['Worldline Direct support team']
|
|
5
7
|
spec.email = ['82139942+worldline-direct-support-team@users.noreply.github.com']
|
|
6
8
|
spec.summary = %q{SDK to communicate with the Online Payments platform using the Online Payments Server API}
|
|
@@ -9,22 +11,25 @@ Gem::Specification.new do |spec|
|
|
|
9
11
|
spec.license = 'MIT'
|
|
10
12
|
|
|
11
13
|
# exclude hidden files like .gitignore
|
|
12
|
-
spec.files = Dir['lib/**/*'] + %w[onlinepayments-sdk-ruby.gemspec Gemfile LICENSE.txt Rakefile README.md]
|
|
14
|
+
spec.files = Dir['lib/**/*'] + Dir['skills/**/*'] + %w[onlinepayments-sdk-ruby.gemspec Gemfile LICENSE.txt Rakefile README.md AGENTS.md]
|
|
13
15
|
spec.executables = spec.files.grep(%r{^bin\/}) { |f| File.basename(f) }
|
|
14
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)\/})
|
|
15
16
|
spec.require_paths = ['lib']
|
|
16
17
|
|
|
17
|
-
spec.required_ruby_version = '>=
|
|
18
|
+
spec.required_ruby_version = '>= 3.4'
|
|
18
19
|
|
|
19
|
-
spec.add_dependency '
|
|
20
|
+
spec.add_dependency 'net-http-persistent', '~> 4.0'
|
|
20
21
|
spec.add_dependency 'concurrent-ruby', '~> 1.3'
|
|
22
|
+
spec.add_dependency 'base64', '~> 0.2'
|
|
21
23
|
|
|
22
|
-
spec.add_development_dependency 'base64'
|
|
23
24
|
spec.add_development_dependency 'yard', '~> 0.9'
|
|
24
25
|
spec.add_development_dependency 'rspec', '~> 3.13'
|
|
26
|
+
spec.add_development_dependency 'rspec_junit_formatter', '~> 0.6'
|
|
27
|
+
spec.add_development_dependency 'simplecov', '~> 0.22'
|
|
25
28
|
spec.add_development_dependency 'webmock', '~> 3.0'
|
|
26
|
-
spec.add_development_dependency '
|
|
27
|
-
spec.add_development_dependency 'webrick', '~> 1.8'
|
|
29
|
+
spec.add_development_dependency 'puma', '~> 8.0'
|
|
28
30
|
spec.add_development_dependency 'rake', '~> 13.0'
|
|
31
|
+
spec.add_development_dependency 'rubocop', '~> 1.92.0'
|
|
32
|
+
spec.add_development_dependency 'logger', '~> 1.6'
|
|
33
|
+
spec.add_development_dependency 'dotenv', '~> 3.1'
|
|
29
34
|
# spec.metadata['yard.run'] = 'yri' # compiles yard doc on install
|
|
30
35
|
end
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: worldline-direct
|
|
3
|
+
description: Write and review integrations with the Worldline Direct payment platform that use the Ruby server SDK (onlinepayments-sdk-ruby). Use when code creates or changes payments, Hosted Checkout, Hosted Tokenization or Hosted Fields sessions, client SDK sessions, payment links, captures, refunds, cancellations, recurring or card-on-file payments, reads payment status, receives webhooks, or handles SDK errors.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Worldline Direct integration with the Ruby SDK
|
|
7
|
+
|
|
8
|
+
Follow this skill whenever you write or change code that calls the Worldline Direct platform through
|
|
9
|
+
`onlinepayments-sdk-ruby`.
|
|
10
|
+
|
|
11
|
+
## How to work
|
|
12
|
+
|
|
13
|
+
1. Choose the integration method with the table below. If the user has not chosen one, propose Hosted Checkout.
|
|
14
|
+
2. Open `references/flows.md` and follow the steps for that method. Use the code shown there; it is copied from
|
|
15
|
+
examples that are compiled against this SDK. Do not write SDK calls from memory.
|
|
16
|
+
3. Read `references/ruby.md` for installation, client setup and the SDK call for each API operation.
|
|
17
|
+
4. Every integration also needs webhook handling (`references/webhooks.md`) and error handling
|
|
18
|
+
(`references/errors.md`).
|
|
19
|
+
5. For fields and operations not shown in the references, check the installed SDK classes and the API reference:
|
|
20
|
+
https://docs.direct.worldline-solutions.com/en/api-reference. Property names in the SDK match the API reference.
|
|
21
|
+
|
|
22
|
+
The `examples/` folder has the complete source files the snippets come from, including the `using`/`import` lines.
|
|
23
|
+
|
|
24
|
+
## Choose an integration method
|
|
25
|
+
|
|
26
|
+
| Method | Use when | Card data on your server |
|
|
27
|
+
|---|---|---|
|
|
28
|
+
| Hosted Checkout | Redirect to a payment page hosted by the platform, all payment methods. Simplest and the default. | No |
|
|
29
|
+
| Hosted Tokenization | Card form in an iframe on your own checkout page. | No |
|
|
30
|
+
| Hosted Fields | Separate card fields that you style, on your own checkout page. | No |
|
|
31
|
+
| Client integration | Mobile app or own form; a Client SDK encrypts the card data on the device. | Encrypted only |
|
|
32
|
+
| Server-to-server | You send card data or a token from your server. Card data requires PCI DSS SAQ D. | Yes |
|
|
33
|
+
| Payment Links | Send a link by email, chat or invoice; no checkout page needed. | No |
|
|
34
|
+
|
|
35
|
+
## Client setup rules
|
|
36
|
+
|
|
37
|
+
- Create one client per application at startup and reuse it. `references/ruby.md` says what the client holds and
|
|
38
|
+
whether it is thread-safe.
|
|
39
|
+
- Read the API key ID, secret and merchant ID (PSPID) from configuration or a secret store. Never hard-code them.
|
|
40
|
+
Validate the configuration once at startup and fail fast when a value is missing. For local development use the
|
|
41
|
+
secret store of your platform or environment variables, never a file in the repository.
|
|
42
|
+
- Endpoints: test `https://payment.direct.ecom.preprod.worldline-solutions.com`, live
|
|
43
|
+
`https://payment.direct.ecom.worldline-solutions.com`.
|
|
44
|
+
- Set the integrator to your company or application name. It is mandatory: the SDK refuses to create the client
|
|
45
|
+
without it.
|
|
46
|
+
- Amounts are in the smallest currency unit: EUR 10.00 is `1000`.
|
|
47
|
+
|
|
48
|
+
## Mandatory rules
|
|
49
|
+
|
|
50
|
+
1. **Send an idempotence key on every create call that supports idempotent requests.** Use a new UUID per operation
|
|
51
|
+
and store it with the operation before the first call. For CreatePayment one operation is one payment attempt: a
|
|
52
|
+
new attempt, for example after a decline, needs a new key (see "Payment attempt and idempotence key" in
|
|
53
|
+
`references/flows.md`). When a request got no response (timeout, connection error), retry it with the same key.
|
|
54
|
+
When the platform answered with an error marked `retriable`, send it again with a new key (see
|
|
55
|
+
`references/errors.md`). The platform's guide lists the supported operations (for example CreatePayment,
|
|
56
|
+
CapturePayment, RefundPayment, CancelPayment, SubsequentPayment). CreateHostedCheckout and CreatePaymentLink do
|
|
57
|
+
not support them: the platform ignores the key, so a resend creates a second session or link. Send no key for
|
|
58
|
+
those two.
|
|
59
|
+
2. **Persist `HostedCheckoutId` and `RETURNMAC` with the order before redirecting.** Keep them, the idempotence key
|
|
60
|
+
and the payment IDs in storage that survives a restart (your database), not in memory. A demo that keeps them in
|
|
61
|
+
memory must say so in its README. When the customer returns, the platform appends `RETURNMAC` to the query
|
|
62
|
+
string of the return URL. It identifies the returning customer: only a request whose `RETURNMAC` matches the
|
|
63
|
+
stored value belongs to that checkout. Compare it in constant time. Keep this check even when asked to simplify
|
|
64
|
+
the code.
|
|
65
|
+
3. **Use the URLs from the response as returned, never a hand-built concatenation.** This applies to the Hosted
|
|
66
|
+
Checkout `redirectUrl`, the 3-D Secure `merchantAction.redirectData.redirectURL`, the payment link
|
|
67
|
+
`redirectionUrl` and the `hostedTokenizationUrl`.
|
|
68
|
+
4. **Verify every webhook with the SDK's webhooks helper before processing the event.** Reject events that fail
|
|
69
|
+
verification. Never add a switch, setting or environment check that skips verification, not even for local
|
|
70
|
+
development. To test locally, configure a test webhook key ID and secret, or send a test event with
|
|
71
|
+
SendTestWebhook.
|
|
72
|
+
5. **After a declined-payment error, read the status with `GetPaymentDetails` before deciding anything.**
|
|
73
|
+
6. **Never log or store raw card data.** No card number, CVV or expiry date in logs, databases, exceptions or
|
|
74
|
+
analytics. Do not log request objects that contain card data.
|
|
75
|
+
|
|
76
|
+
## Also required
|
|
77
|
+
|
|
78
|
+
- Decide the outcome on your server from `GetHostedCheckout` or `GetPaymentDetails`, never from the return URL or the
|
|
79
|
+
browser alone.
|
|
80
|
+
- Base order state on `statusOutput.statusCategory`; see "Payment status" in `references/flows.md`.
|
|
81
|
+
- Build the return URL from configuration (an absolute public base URL), never from the request's `Host` header.
|
|
82
|
+
- Webhooks can arrive twice and in any order. Save each verified event before you answer with HTTP 2xx, then process
|
|
83
|
+
it in the background. Do not count on the platform sending it again after a 2xx; see `references/webhooks.md`.
|
|
84
|
+
- Use the test endpoint and test credentials until the user explicitly asks for live.
|
|
85
|
+
- Documentation: https://docs.direct.worldline-solutions.com
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
require 'onlinepayments/sdk'
|
|
2
|
+
|
|
3
|
+
# Each method takes an idempotence key. Create it once per operation (e.g. when someone clicks "Refund") and store it.
|
|
4
|
+
# Pass the same key again if the request got no answer; see ErrorHandlingExample.
|
|
5
|
+
class AfterPaymentOperationsExample
|
|
6
|
+
# @param merchant [OnlinePayments::SDK::Merchant::MerchantClient]
|
|
7
|
+
def initialize(merchant)
|
|
8
|
+
@merchant = merchant
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# [START capture-payment]
|
|
12
|
+
# Captures an authorized payment (status PENDING_CAPTURE). Without an amount, the full amount is captured.
|
|
13
|
+
# @param payment_id [String]
|
|
14
|
+
# @param amount_in_cents [Integer]
|
|
15
|
+
# @param is_final [Boolean] true: this capture is final, no further capture is accepted.
|
|
16
|
+
# @param idempotence_key [String]
|
|
17
|
+
# @return [OnlinePayments::SDK::Domain::CaptureResponse]
|
|
18
|
+
def capture(payment_id, amount_in_cents, is_final, idempotence_key)
|
|
19
|
+
details = merchant.payments.get_payment_details(payment_id)
|
|
20
|
+
raise "Payment #{payment_id} cannot be captured in status #{details.status}" if details.status != 'PENDING_CAPTURE'
|
|
21
|
+
|
|
22
|
+
request = OnlinePayments::SDK::Domain::CapturePaymentRequest.new
|
|
23
|
+
request.amount = amount_in_cents
|
|
24
|
+
request.is_final = is_final
|
|
25
|
+
context = OnlinePayments::SDK::CallContext.new(idempotence_key)
|
|
26
|
+
merchant.payments.capture_payment(payment_id, request, context)
|
|
27
|
+
end
|
|
28
|
+
# [END capture-payment]
|
|
29
|
+
|
|
30
|
+
# [START refund-payment]
|
|
31
|
+
# Refunds a captured payment, fully or partly.
|
|
32
|
+
# @param payment_id [String]
|
|
33
|
+
# @param amount_in_cents [Integer]
|
|
34
|
+
# @param currency_code [String]
|
|
35
|
+
# @param idempotence_key [String]
|
|
36
|
+
# @return [OnlinePayments::SDK::Domain::RefundResponse]
|
|
37
|
+
def refund(payment_id, amount_in_cents, currency_code, idempotence_key)
|
|
38
|
+
details = merchant.payments.get_payment_details(payment_id)
|
|
39
|
+
unless details.status_output&.is_refundable == true
|
|
40
|
+
raise "Payment #{payment_id} is not refundable in status #{details.status}"
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
amount_of_money = OnlinePayments::SDK::Domain::AmountOfMoney.new
|
|
44
|
+
amount_of_money.amount = amount_in_cents
|
|
45
|
+
amount_of_money.currency_code = currency_code
|
|
46
|
+
request = OnlinePayments::SDK::Domain::RefundRequest.new
|
|
47
|
+
request.amount_of_money = amount_of_money
|
|
48
|
+
context = OnlinePayments::SDK::CallContext.new(idempotence_key)
|
|
49
|
+
# REFUND_REQUESTED: the platform is processing the refund and waiting for the result. The status then becomes
|
|
50
|
+
# REFUNDED or REJECTED; treat the refund as done only when it is REFUNDED.
|
|
51
|
+
merchant.payments.refund_payment(payment_id, request, context)
|
|
52
|
+
end
|
|
53
|
+
# [END refund-payment]
|
|
54
|
+
|
|
55
|
+
# [START cancel-payment]
|
|
56
|
+
# Cancels (voids) an authorization that is not captured yet. No amount cancels the full amount.
|
|
57
|
+
# @param payment_id [String]
|
|
58
|
+
# @param idempotence_key [String]
|
|
59
|
+
# @return [OnlinePayments::SDK::Domain::CancelPaymentResponse]
|
|
60
|
+
def cancel(payment_id, idempotence_key)
|
|
61
|
+
details = merchant.payments.get_payment_details(payment_id)
|
|
62
|
+
unless details.status_output&.is_cancellable == true
|
|
63
|
+
raise "Payment #{payment_id} is not cancellable in status #{details.status}"
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
context = OnlinePayments::SDK::CallContext.new(idempotence_key)
|
|
67
|
+
merchant.payments.cancel_payment(payment_id, OnlinePayments::SDK::Domain::CancelPaymentRequest.new, context)
|
|
68
|
+
end
|
|
69
|
+
# [END cancel-payment]
|
|
70
|
+
|
|
71
|
+
private
|
|
72
|
+
|
|
73
|
+
# @return [OnlinePayments::SDK::Merchant::MerchantClient]
|
|
74
|
+
attr_reader :merchant
|
|
75
|
+
end
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
# Stand-ins for your application's own types and persistence. The examples use them where your code must store or read
|
|
2
|
+
# data; replace them with your own code.
|
|
3
|
+
|
|
4
|
+
# The payment state of an order in your application.
|
|
5
|
+
module OrderPaymentState
|
|
6
|
+
PENDING = :pending
|
|
7
|
+
AUTHORIZED = :authorized
|
|
8
|
+
PAID = :paid
|
|
9
|
+
FAILED = :failed
|
|
10
|
+
CANCELLED = :cancelled
|
|
11
|
+
REFUNDED = :refunded
|
|
12
|
+
REVERSED = :reversed
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# What the web layer must do after a create payment call: redirect the customer to redirect_url, or show the state.
|
|
16
|
+
class PaymentStep
|
|
17
|
+
# @param redirect_url [String, nil]
|
|
18
|
+
# @param state [Symbol, nil] one of the OrderPaymentState values
|
|
19
|
+
def initialize(redirect_url: nil, state: nil)
|
|
20
|
+
@redirect_url = redirect_url
|
|
21
|
+
@state = state
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# @return [String, nil]
|
|
25
|
+
attr_reader :redirect_url
|
|
26
|
+
|
|
27
|
+
# @return [Symbol, nil]
|
|
28
|
+
attr_reader :state
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
class StoredHostedCheckout
|
|
32
|
+
# @param hosted_checkout_id [String]
|
|
33
|
+
# @param returnmac [String]
|
|
34
|
+
def initialize(hosted_checkout_id, returnmac)
|
|
35
|
+
@hosted_checkout_id = hosted_checkout_id
|
|
36
|
+
@returnmac = returnmac
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# @return [String]
|
|
40
|
+
attr_reader :hosted_checkout_id
|
|
41
|
+
|
|
42
|
+
# @return [String]
|
|
43
|
+
attr_reader :returnmac
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Stand-in for your database code.
|
|
47
|
+
class OrderStore
|
|
48
|
+
# @param order_id [String]
|
|
49
|
+
# @param hosted_checkout_id [String]
|
|
50
|
+
# @param returnmac [String]
|
|
51
|
+
# @return [void]
|
|
52
|
+
def save_hosted_checkout(order_id, hosted_checkout_id, returnmac)
|
|
53
|
+
raise NotImplementedError
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# @param order_id [String]
|
|
57
|
+
# @return [StoredHostedCheckout]
|
|
58
|
+
def get_hosted_checkout(order_id)
|
|
59
|
+
raise NotImplementedError
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# The idempotence key of the create call for this order. Store it before the call.
|
|
63
|
+
# @param order_id [String]
|
|
64
|
+
# @param idempotence_key [String]
|
|
65
|
+
# @return [void]
|
|
66
|
+
def save_idempotence_key(order_id, idempotence_key)
|
|
67
|
+
raise NotImplementedError
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# @param order_id [String]
|
|
71
|
+
# @return [String, nil]
|
|
72
|
+
def get_idempotence_key(order_id)
|
|
73
|
+
raise NotImplementedError
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# @param order_id [String]
|
|
77
|
+
# @param payment_id [String]
|
|
78
|
+
# @return [void]
|
|
79
|
+
def save_payment_id(order_id, payment_id)
|
|
80
|
+
raise NotImplementedError
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# @param order_id [String]
|
|
84
|
+
# @return [String, nil] nil while no payment ID is stored yet
|
|
85
|
+
def get_payment_id(order_id)
|
|
86
|
+
raise NotImplementedError
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# @param order_id [String]
|
|
90
|
+
# @param state [Symbol] one of the OrderPaymentState values
|
|
91
|
+
# @return [void]
|
|
92
|
+
def save_state(order_id, state)
|
|
93
|
+
raise NotImplementedError
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# @param customer_id [String]
|
|
97
|
+
# @param initial_payment_id [String]
|
|
98
|
+
# @return [void]
|
|
99
|
+
def save_recurring_payment_id(customer_id, initial_payment_id)
|
|
100
|
+
raise NotImplementedError
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
# @param customer_id [String]
|
|
104
|
+
# @return [String]
|
|
105
|
+
def get_recurring_payment_id(customer_id)
|
|
106
|
+
raise NotImplementedError
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
# Browser values collected with JavaScript on the checkout page.
|
|
111
|
+
class BrowserInfo
|
|
112
|
+
# @param color_depth [Integer]
|
|
113
|
+
# @param java_enabled [Boolean]
|
|
114
|
+
# @param screen_height [Integer]
|
|
115
|
+
# @param screen_width [Integer]
|
|
116
|
+
# @param timezone_offset_utc_minutes [Integer]
|
|
117
|
+
# @param locale [String]
|
|
118
|
+
def initialize(color_depth:, java_enabled:, screen_height:, screen_width:, timezone_offset_utc_minutes:, locale:)
|
|
119
|
+
@color_depth = color_depth
|
|
120
|
+
@java_enabled = java_enabled
|
|
121
|
+
@screen_height = screen_height
|
|
122
|
+
@screen_width = screen_width
|
|
123
|
+
@timezone_offset_utc_minutes = timezone_offset_utc_minutes
|
|
124
|
+
@locale = locale
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
# @return [Integer]
|
|
128
|
+
attr_reader :color_depth
|
|
129
|
+
|
|
130
|
+
# @return [Boolean]
|
|
131
|
+
attr_reader :java_enabled
|
|
132
|
+
|
|
133
|
+
# @return [Integer]
|
|
134
|
+
attr_reader :screen_height
|
|
135
|
+
|
|
136
|
+
# @return [Integer]
|
|
137
|
+
attr_reader :screen_width
|
|
138
|
+
|
|
139
|
+
# @return [Integer]
|
|
140
|
+
attr_reader :timezone_offset_utc_minutes
|
|
141
|
+
|
|
142
|
+
# @return [String]
|
|
143
|
+
attr_reader :locale
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
# Card details as entered by the customer. Never log or store this object.
|
|
147
|
+
class CardInput
|
|
148
|
+
# @param number [String]
|
|
149
|
+
# @param holder_name [String]
|
|
150
|
+
# @param expiry_date [String] MMYY, e.g. 1230 for December 2030.
|
|
151
|
+
# @param cvv [String]
|
|
152
|
+
def initialize(number:, holder_name:, expiry_date:, cvv:)
|
|
153
|
+
@number = number
|
|
154
|
+
@holder_name = holder_name
|
|
155
|
+
@expiry_date = expiry_date
|
|
156
|
+
@cvv = cvv
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
# @return [String]
|
|
160
|
+
attr_reader :number
|
|
161
|
+
|
|
162
|
+
# @return [String]
|
|
163
|
+
attr_reader :holder_name
|
|
164
|
+
|
|
165
|
+
# @return [String]
|
|
166
|
+
attr_reader :expiry_date
|
|
167
|
+
|
|
168
|
+
# @return [String]
|
|
169
|
+
attr_reader :cvv
|
|
170
|
+
end
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
require 'onlinepayments/sdk'
|
|
2
|
+
require_relative 'app_types'
|
|
3
|
+
require_relative 'create_payment_response_handler'
|
|
4
|
+
require_relative 'payment_attempt'
|
|
5
|
+
|
|
6
|
+
class ClientIntegrationExample
|
|
7
|
+
# @param merchant [OnlinePayments::SDK::Merchant::MerchantClient]
|
|
8
|
+
# @param orders [OrderStore]
|
|
9
|
+
def initialize(merchant, orders)
|
|
10
|
+
@merchant = merchant
|
|
11
|
+
@orders = orders
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# [START client-session-create]
|
|
15
|
+
# Creates the session that a Client SDK (JavaScript, iOS, Android, Flutter...) needs to encrypt card data.
|
|
16
|
+
# @return [OnlinePayments::SDK::Domain::SessionResponse]
|
|
17
|
+
def create_client_session
|
|
18
|
+
session = merchant.sessions.create_session(OnlinePayments::SDK::Domain::SessionRequest.new)
|
|
19
|
+
# Send client_session_id, customer_id, client_api_url and asset_url to the app. Never send your API key.
|
|
20
|
+
session
|
|
21
|
+
end
|
|
22
|
+
# [END client-session-create]
|
|
23
|
+
|
|
24
|
+
# [START client-encrypted-payment]
|
|
25
|
+
# The Client SDK returns an encrypted string; the app posts it to your server.
|
|
26
|
+
# @param order_id [String]
|
|
27
|
+
# @param encrypted_customer_input [String]
|
|
28
|
+
# @param amount_in_cents [Integer]
|
|
29
|
+
# @param currency_code [String]
|
|
30
|
+
# @param device [OnlinePayments::SDK::Domain::CustomerDevice]
|
|
31
|
+
# @param return_url [String]
|
|
32
|
+
# @return [PaymentStep]
|
|
33
|
+
def pay(order_id, encrypted_customer_input, amount_in_cents, currency_code, device, return_url)
|
|
34
|
+
amount_of_money = OnlinePayments::SDK::Domain::AmountOfMoney.new
|
|
35
|
+
amount_of_money.amount = amount_in_cents
|
|
36
|
+
amount_of_money.currency_code = currency_code
|
|
37
|
+
|
|
38
|
+
references = OnlinePayments::SDK::Domain::OrderReferences.new
|
|
39
|
+
references.merchant_reference = order_id
|
|
40
|
+
|
|
41
|
+
customer = OnlinePayments::SDK::Domain::Customer.new
|
|
42
|
+
customer.device = device
|
|
43
|
+
|
|
44
|
+
order = OnlinePayments::SDK::Domain::Order.new
|
|
45
|
+
order.amount_of_money = amount_of_money
|
|
46
|
+
order.references = references
|
|
47
|
+
order.customer = customer
|
|
48
|
+
|
|
49
|
+
redirection_data = OnlinePayments::SDK::Domain::RedirectionData.new
|
|
50
|
+
redirection_data.return_url = return_url
|
|
51
|
+
three_d_secure = OnlinePayments::SDK::Domain::ThreeDSecure.new
|
|
52
|
+
three_d_secure.redirection_data = redirection_data
|
|
53
|
+
|
|
54
|
+
card_input = OnlinePayments::SDK::Domain::CardPaymentMethodSpecificInput.new
|
|
55
|
+
card_input.authorization_mode = 'SALE'
|
|
56
|
+
card_input.three_d_secure = three_d_secure
|
|
57
|
+
|
|
58
|
+
request = OnlinePayments::SDK::Domain::CreatePaymentRequest.new
|
|
59
|
+
request.encrypted_customer_input = encrypted_customer_input
|
|
60
|
+
request.order = order
|
|
61
|
+
request.card_payment_method_specific_input = card_input
|
|
62
|
+
|
|
63
|
+
context = OnlinePayments::SDK::CallContext.new(PaymentAttempt.key_for(order_id, orders))
|
|
64
|
+
response = merchant.payments.create_payment(request, context)
|
|
65
|
+
CreatePaymentResponseHandler.handle_create_payment_response(response, order_id, orders)
|
|
66
|
+
end
|
|
67
|
+
# [END client-encrypted-payment]
|
|
68
|
+
|
|
69
|
+
private
|
|
70
|
+
|
|
71
|
+
# @return [OnlinePayments::SDK::Merchant::MerchantClient]
|
|
72
|
+
attr_reader :merchant
|
|
73
|
+
|
|
74
|
+
# @return [OrderStore]
|
|
75
|
+
attr_reader :orders
|
|
76
|
+
end
|