Class: AmazonPay::Client
- Inherits:
-
Object
- Object
- AmazonPay::Client
- Defined in:
- lib/amazon_pay/client.rb,
lib/amazon_pay/client_helper.rb
Overview
This will extend the client class to add additional helper methods that combine core API calls.
Instance Attribute Summary collapse
-
#access_key ⇒ Object
readonly
Returns the value of attribute access_key.
-
#application_name ⇒ Object
readonly
Returns the value of attribute application_name.
-
#application_version ⇒ Object
readonly
Returns the value of attribute application_version.
-
#currency_code ⇒ Object
readonly
Returns the value of attribute currency_code.
-
#log_enabled ⇒ Object
readonly
Returns the value of attribute log_enabled.
-
#log_file_name ⇒ Object
readonly
Returns the value of attribute log_file_name.
-
#log_level ⇒ Object
readonly
Returns the value of attribute log_level.
-
#merchant_id ⇒ Object
readonly
Returns the value of attribute merchant_id.
-
#platform_id ⇒ Object
readonly
Returns the value of attribute platform_id.
-
#proxy_addr ⇒ Object
Returns the value of attribute proxy_addr.
-
#proxy_pass ⇒ Object
Returns the value of attribute proxy_pass.
-
#proxy_port ⇒ Object
Returns the value of attribute proxy_port.
-
#proxy_user ⇒ Object
Returns the value of attribute proxy_user.
-
#region ⇒ Object
readonly
Returns the value of attribute region.
-
#sandbox ⇒ Object
readonly
Returns the value of attribute sandbox.
-
#secret_key ⇒ Object
readonly
Returns the value of attribute secret_key.
-
#throttle ⇒ Object
readonly
Returns the value of attribute throttle.
Instance Method Summary collapse
-
#authorize(amazon_order_reference_id, authorization_reference_id, amount, currency_code: @currency_code, seller_authorization_note: nil, transaction_timeout: nil, capture_now: nil, soft_descriptor: nil, provider_credit_details: nil, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
Reserves a specified amount against the payment method(s) stored in the order reference.
-
#authorize_on_billing_agreement(amazon_billing_agreement_id, authorization_reference_id, amount, currency_code: @currency_code, seller_authorization_note: nil, transaction_timeout: nil, capture_now: false, soft_descriptor: nil, seller_note: nil, platform_id: nil, custom_information: nil, seller_order_id: nil, store_name: nil, inherit_shipping_address: nil, supplementary_data: nil, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
Reserves a specified amount against the payment method(s) stored in the billing agreement.
-
#cancel_order_reference(amazon_order_reference_id, cancelation_reason: nil, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
Cancels a previously confirmed order reference.
-
#capture(amazon_authorization_id, capture_reference_id, amount, currency_code: @currency_code, seller_capture_note: nil, soft_descriptor: nil, provider_credit_details: nil, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
Captures funds from an authorized payment instrument.
-
#charge(amazon_reference_id, authorization_reference_id, charge_amount, charge_currency_code: @currency_code, charge_note: nil, charge_order_id: nil, store_name: nil, custom_information: nil, soft_descriptor: nil, platform_id: nil, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
This method combines multiple API calls to perform a complete transaction with minimum requirements.
-
#close_authorization(amazon_authorization_id, closure_reason: nil, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
Closes an authorization.
-
#close_billing_agreement(amazon_billing_agreement_id, closure_reason: nil, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
Confirms that you want to terminate the billing agreement with the buyer and that you do not expect to create any new order references or authorizations on this billing agreement.
-
#close_order_reference(amazon_order_reference_id, closure_reason: nil, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
Confirms that an order reference has been fulfilled (fully or partially) and that you do not expect to create any new authorizations on this order reference.
-
#confirm_billing_agreement(amazon_billing_agreement_id, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
Confirms that the billing agreement is free of constraints and all required information has been set on the billing agreement.
-
#confirm_order_reference(amazon_order_reference_id, success_url: nil, failure_url: nil, authorization_amount: nil, currency_code: @currency_code, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
Confirms that the order reference is free of constraints and all required information has been set on the order reference.
-
#create_order_reference_for_id(id, id_type, inherit_shipping_address: nil, confirm_now: nil, amount: nil, currency_code: @currency_code, platform_id: nil, seller_note: nil, seller_order_id: nil, store_name: nil, custom_information: nil, supplementary_data: nil, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
Creates an order reference for the given object.
-
#get_authorization_details(amazon_authorization_id, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
Returns the status of a particular authorization and the total amount captured on the authorization.
-
#get_billing_agreement_details(amazon_billing_agreement_id, address_consent_token: nil, access_token: nil, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
Returns details about the Billing Agreement object and its current state.
-
#get_capture_details(amazon_capture_id, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
Returns the status of a particular capture and the total amount refunded on the capture.
-
#get_merchant_account_status(merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
Returns status of the merchant.
-
#get_order_reference_details(amazon_order_reference_id, address_consent_token: nil, access_token: nil, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
Returns details about the Order Reference object and its current state.
- #get_provider_credit_details(amazon_provider_credit_id, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
- #get_provider_credit_reversal_details(amazon_provider_credit_reversal_id, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
-
#get_refund_details(amazon_refund_id, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
Returns the status of a particular refund.
-
#get_service_status ⇒ Object
The GetServiceStatus operation returns the operational status of the AmazonPay API section of Amazon Marketplace Web Service (Amazon MWS).
-
#initialize(merchant_id, access_key, secret_key, sandbox: false, currency_code: :usd, region: :na, platform_id: nil, throttle: true, application_name: nil, application_version: nil, proxy_addr: :ENV, proxy_port: nil, proxy_user: nil, proxy_pass: nil, log_enabled: false, log_file_name: nil, log_level: :DEBUG) ⇒ Client
constructor
API keys are located at:.
-
#list_order_reference(query_id, query_id_type, created_time_range_start: nil, created_time_range_end: nil, sort_order: nil, page_size: nil, order_reference_status_list_filter: nil, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
Allows the search of any Amazon Pay order made using secondary seller order IDs generated manually, a solution provider, or a custom order fulfillment service.
-
#list_order_reference_by_next_token(next_page_token) ⇒ Object
When ListOrderReference returns multiple pages you can continue by using the NextPageToken returned by ListOrderReference.
-
#modify_order_attributes(amazon_order_reference_id, seller_note: nil, seller_order_id: nil, payment_service_provider_id: nil, payment_service_provider_order_id: nil, request_payment_authorization: nil, store_name: nil, custom_information: nil, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
Modify order attributes such as CustomInformation for the order This is a convenience function for set_order_attributes to prevent accidentally passing extra variables that can’t be modified ater Amazon Order Reference (ORO) is confirmed.
-
#refund(amazon_capture_id, refund_reference_id, amount, currency_code: @currency_code, seller_refund_note: nil, soft_descriptor: nil, provider_credit_reversal_details: nil, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
Refunds a previously captured amount.
- #reverse_provider_credit(amazon_provider_credit_id, credit_reversal_reference_id, amount, currency_code: @currency_code, credit_reversal_note: nil, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
-
#set_billing_agreement_details(amazon_billing_agreement_id, platform_id: nil, seller_note: nil, seller_billing_agreement_id: nil, custom_information: nil, store_name: nil, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
Sets billing agreement details such as a description of the agreement and other information about the seller.
-
#set_order_attributes(amazon_order_reference_id, amount: nil, currency_code: @currency_code, platform_id: nil, seller_note: nil, seller_order_id: nil, payment_service_provider_id: nil, payment_service_provider_order_id: nil, request_payment_authorization: nil, store_name: nil, order_item_categories: nil, custom_information: nil, supplementary_data: nil, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
Sets order attributes such as the order total and a description for the order.
-
#set_order_reference_details(amazon_order_reference_id, amount, currency_code: @currency_code, platform_id: nil, seller_note: nil, seller_order_id: nil, request_payment_authorization: nil, store_name: nil, order_item_categories: nil, custom_information: nil, supplementary_data: nil, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
Sets order reference details such as the order total and a description for the order.
-
#validate_billing_agreement(amazon_billing_agreement_id, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
Validates the status of the BillingAgreement object and the payment method associated with it.
Constructor Details
#initialize(merchant_id, access_key, secret_key, sandbox: false, currency_code: :usd, region: :na, platform_id: nil, throttle: true, application_name: nil, application_version: nil, proxy_addr: :ENV, proxy_port: nil, proxy_user: nil, proxy_pass: nil, log_enabled: false, log_file_name: nil, log_level: :DEBUG) ⇒ Client
API keys are located at:
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/amazon_pay/client.rb', line 56 def initialize( merchant_id, access_key, secret_key, sandbox: false, currency_code: :usd, region: :na, platform_id: nil, throttle: true, application_name: nil, application_version: nil, proxy_addr: :ENV, proxy_port: nil, proxy_user: nil, proxy_pass: nil, log_enabled: false, log_file_name: nil, log_level: :DEBUG ) @merchant_id = merchant_id @access_key = access_key @secret_key = secret_key @currency_code = currency_code.to_s.upcase @sandbox = sandbox @sandbox_str = @sandbox ? 'OffAmazonPayments_Sandbox' : 'OffAmazonPayments' @region = region @mws_endpoint = region_hash[@region] ? region_hash[@region] : raise("Invalid Region Code. (#{@region})") @platform_id = platform_id @throttle = throttle @application_name = application_name @application_version = application_version @proxy_addr = proxy_addr @proxy_port = proxy_port @proxy_user = proxy_user @proxy_pass = proxy_pass @default_hash = { 'AWSAccessKeyId' => @access_key, 'SignatureMethod' => 'HmacSHA256', 'SignatureVersion' => '2', 'Version' => AmazonPay::API_VERSION } @log_enabled = log_enabled @log_level = log_level @log_file_name = log_file_name @default_hash['PlatformId'] = @platform_id if @platform_id end |
Instance Attribute Details
#access_key ⇒ Object (readonly)
Returns the value of attribute access_key.
14 15 16 |
# File 'lib/amazon_pay/client.rb', line 14 def access_key @access_key end |
#application_name ⇒ Object (readonly)
Returns the value of attribute application_name.
14 15 16 |
# File 'lib/amazon_pay/client.rb', line 14 def application_name @application_name end |
#application_version ⇒ Object (readonly)
Returns the value of attribute application_version.
14 15 16 |
# File 'lib/amazon_pay/client.rb', line 14 def application_version @application_version end |
#currency_code ⇒ Object (readonly)
Returns the value of attribute currency_code.
14 15 16 |
# File 'lib/amazon_pay/client.rb', line 14 def currency_code @currency_code end |
#log_enabled ⇒ Object (readonly)
Returns the value of attribute log_enabled.
14 15 16 |
# File 'lib/amazon_pay/client.rb', line 14 def log_enabled @log_enabled end |
#log_file_name ⇒ Object (readonly)
Returns the value of attribute log_file_name.
14 15 16 |
# File 'lib/amazon_pay/client.rb', line 14 def log_file_name @log_file_name end |
#log_level ⇒ Object (readonly)
Returns the value of attribute log_level.
14 15 16 |
# File 'lib/amazon_pay/client.rb', line 14 def log_level @log_level end |
#merchant_id ⇒ Object (readonly)
Returns the value of attribute merchant_id.
14 15 16 |
# File 'lib/amazon_pay/client.rb', line 14 def merchant_id @merchant_id end |
#platform_id ⇒ Object (readonly)
Returns the value of attribute platform_id.
14 15 16 |
# File 'lib/amazon_pay/client.rb', line 14 def platform_id @platform_id end |
#proxy_addr ⇒ Object
Returns the value of attribute proxy_addr.
30 31 32 |
# File 'lib/amazon_pay/client.rb', line 30 def proxy_addr @proxy_addr end |
#proxy_pass ⇒ Object
Returns the value of attribute proxy_pass.
30 31 32 |
# File 'lib/amazon_pay/client.rb', line 30 def proxy_pass @proxy_pass end |
#proxy_port ⇒ Object
Returns the value of attribute proxy_port.
30 31 32 |
# File 'lib/amazon_pay/client.rb', line 30 def proxy_port @proxy_port end |
#proxy_user ⇒ Object
Returns the value of attribute proxy_user.
30 31 32 |
# File 'lib/amazon_pay/client.rb', line 30 def proxy_user @proxy_user end |
#region ⇒ Object (readonly)
Returns the value of attribute region.
14 15 16 |
# File 'lib/amazon_pay/client.rb', line 14 def region @region end |
#sandbox ⇒ Object (readonly)
Returns the value of attribute sandbox.
14 15 16 |
# File 'lib/amazon_pay/client.rb', line 14 def sandbox @sandbox end |
#secret_key ⇒ Object (readonly)
Returns the value of attribute secret_key.
14 15 16 |
# File 'lib/amazon_pay/client.rb', line 14 def secret_key @secret_key end |
#throttle ⇒ Object (readonly)
Returns the value of attribute throttle.
14 15 16 |
# File 'lib/amazon_pay/client.rb', line 14 def throttle @throttle end |
Instance Method Details
#authorize(amazon_order_reference_id, authorization_reference_id, amount, currency_code: @currency_code, seller_authorization_note: nil, transaction_timeout: nil, capture_now: nil, soft_descriptor: nil, provider_credit_details: nil, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
Reserves a specified amount against the payment method(s) stored in the order reference
724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 |
# File 'lib/amazon_pay/client.rb', line 724 def ( amazon_order_reference_id, , amount, currency_code: @currency_code, seller_authorization_note: nil, transaction_timeout: nil, capture_now: nil, soft_descriptor: nil, provider_credit_details: nil, merchant_id: @merchant_id, mws_auth_token: nil ) parameters = { 'Action' => 'Authorize', 'SellerId' => merchant_id, 'AmazonOrderReferenceId' => amazon_order_reference_id, 'AuthorizationReferenceId' => , 'AuthorizationAmount.Amount' => amount, 'AuthorizationAmount.CurrencyCode' => currency_code } optional = { 'SellerAuthorizationNote' => , 'TransactionTimeout' => transaction_timeout, 'CaptureNow' => capture_now, 'SoftDescriptor' => soft_descriptor, 'MWSAuthToken' => mws_auth_token } optional.merge!(set_provider_credit_details(provider_credit_details)) if provider_credit_details operation(parameters, optional) end |
#authorize_on_billing_agreement(amazon_billing_agreement_id, authorization_reference_id, amount, currency_code: @currency_code, seller_authorization_note: nil, transaction_timeout: nil, capture_now: false, soft_descriptor: nil, seller_note: nil, platform_id: nil, custom_information: nil, seller_order_id: nil, store_name: nil, inherit_shipping_address: nil, supplementary_data: nil, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
Reserves a specified amount against the payment method(s) stored in the billing agreement
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 |
# File 'lib/amazon_pay/client.rb', line 319 def ( amazon_billing_agreement_id, , amount, currency_code: @currency_code, seller_authorization_note: nil, transaction_timeout: nil, capture_now: false, soft_descriptor: nil, seller_note: nil, platform_id: nil, custom_information: nil, seller_order_id: nil, store_name: nil, inherit_shipping_address: nil, supplementary_data: nil, merchant_id: @merchant_id, mws_auth_token: nil ) parameters = { 'Action' => 'AuthorizeOnBillingAgreement', 'SellerId' => merchant_id, 'AmazonBillingAgreementId' => amazon_billing_agreement_id, 'AuthorizationReferenceId' => , 'AuthorizationAmount.Amount' => amount, 'AuthorizationAmount.CurrencyCode' => currency_code } optional = { 'SellerAuthorizationNote' => , 'TransactionTimeout' => transaction_timeout, 'CaptureNow' => capture_now, 'SoftDescriptor' => soft_descriptor, 'SellerNote' => seller_note, 'PlatformId' => platform_id, 'SellerOrderAttributes.CustomInformation' => custom_information, 'SellerOrderAttributes.SellerOrderId' => seller_order_id, 'SellerOrderAttributes.StoreName' => store_name, 'SellerOrderAttributes.SupplementaryData' => supplementary_data, 'InheritShippingAddress' => inherit_shipping_address, 'MWSAuthToken' => mws_auth_token } operation(parameters, optional) end |
#cancel_order_reference(amazon_order_reference_id, cancelation_reason: nil, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
Cancels a previously confirmed order reference
689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 |
# File 'lib/amazon_pay/client.rb', line 689 def cancel_order_reference( amazon_order_reference_id, cancelation_reason: nil, merchant_id: @merchant_id, mws_auth_token: nil ) parameters = { 'Action' => 'CancelOrderReference', 'SellerId' => merchant_id, 'AmazonOrderReferenceId' => amazon_order_reference_id } optional = { 'CancelationReason' => cancelation_reason, 'MWSAuthToken' => mws_auth_token } operation(parameters, optional) end |
#capture(amazon_authorization_id, capture_reference_id, amount, currency_code: @currency_code, seller_capture_note: nil, soft_descriptor: nil, provider_credit_details: nil, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
Captures funds from an authorized payment instrument.
796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 |
# File 'lib/amazon_pay/client.rb', line 796 def capture( , capture_reference_id, amount, currency_code: @currency_code, seller_capture_note: nil, soft_descriptor: nil, provider_credit_details: nil, merchant_id: @merchant_id, mws_auth_token: nil ) parameters = { 'Action' => 'Capture', 'SellerId' => merchant_id, 'AmazonAuthorizationId' => , 'CaptureReferenceId' => capture_reference_id, 'CaptureAmount.Amount' => amount, 'CaptureAmount.CurrencyCode' => currency_code } optional = { 'SellerCaptureNote' => seller_capture_note, 'SoftDescriptor' => soft_descriptor, 'MWSAuthToken' => mws_auth_token } optional.merge!(set_provider_credit_details(provider_credit_details)) if provider_credit_details operation(parameters, optional) end |
#charge(amazon_reference_id, authorization_reference_id, charge_amount, charge_currency_code: @currency_code, charge_note: nil, charge_order_id: nil, store_name: nil, custom_information: nil, soft_descriptor: nil, platform_id: nil, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
This method combines multiple API calls to perform a complete transaction with minimum requirements.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/amazon_pay/client_helper.rb', line 21 def charge( amazon_reference_id, , charge_amount, charge_currency_code: @currency_code, charge_note: nil, charge_order_id: nil, store_name: nil, custom_information: nil, soft_descriptor: nil, platform_id: nil, merchant_id: @merchant_id, mws_auth_token: nil ) if order_reference?(amazon_reference_id) call_order_reference_api( amazon_reference_id, , charge_amount, charge_currency_code, charge_note, charge_order_id, store_name, custom_information, soft_descriptor, platform_id, merchant_id, mws_auth_token ) elsif billing_agreement?(amazon_reference_id) call_billing_agreement_api( amazon_reference_id, , charge_amount, charge_currency_code, charge_note, charge_order_id, store_name, custom_information, soft_descriptor, platform_id, merchant_id, mws_auth_token ) end end |
#close_authorization(amazon_authorization_id, closure_reason: nil, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
Closes an authorization
926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 |
# File 'lib/amazon_pay/client.rb', line 926 def ( , closure_reason: nil, merchant_id: @merchant_id, mws_auth_token: nil ) parameters = { 'Action' => 'CloseAuthorization', 'SellerId' => merchant_id, 'AmazonAuthorizationId' => } optional = { 'ClosureReason' => closure_reason, 'MWSAuthToken' => mws_auth_token } operation(parameters, optional) end |
#close_billing_agreement(amazon_billing_agreement_id, closure_reason: nil, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
Confirms that you want to terminate the billing agreement with the buyer and that you do not expect to create any new order references or authorizations on this billing agreement
374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 |
# File 'lib/amazon_pay/client.rb', line 374 def close_billing_agreement( amazon_billing_agreement_id, closure_reason: nil, merchant_id: @merchant_id, mws_auth_token: nil ) parameters = { 'Action' => 'CloseBillingAgreement', 'SellerId' => merchant_id, 'AmazonBillingAgreementId' => amazon_billing_agreement_id } optional = { 'ClosureReason' => closure_reason, 'MWSAuthToken' => mws_auth_token } operation(parameters, optional) end |
#close_order_reference(amazon_order_reference_id, closure_reason: nil, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
Confirms that an order reference has been fulfilled (fully or partially) and that you do not expect to create any new authorizations on this order reference
955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 |
# File 'lib/amazon_pay/client.rb', line 955 def close_order_reference( amazon_order_reference_id, closure_reason: nil, merchant_id: @merchant_id, mws_auth_token: nil ) parameters = { 'Action' => 'CloseOrderReference', 'SellerId' => merchant_id, 'AmazonOrderReferenceId' => amazon_order_reference_id } optional = { 'ClosureReason' => closure_reason, 'MWSAuthToken' => mws_auth_token } operation(parameters, optional) end |
#confirm_billing_agreement(amazon_billing_agreement_id, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
Confirms that the billing agreement is free of constraints and all required information has been set on the billing agreement
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 |
# File 'lib/amazon_pay/client.rb', line 255 def confirm_billing_agreement( amazon_billing_agreement_id, merchant_id: @merchant_id, mws_auth_token: nil ) parameters = { 'Action' => 'ConfirmBillingAgreement', 'SellerId' => merchant_id, 'AmazonBillingAgreementId' => amazon_billing_agreement_id } optional = { 'MWSAuthToken' => mws_auth_token } operation(parameters, optional) end |
#confirm_order_reference(amazon_order_reference_id, success_url: nil, failure_url: nil, authorization_amount: nil, currency_code: @currency_code, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
Confirms that the order reference is free of constraints and all required information has been set on the order reference
654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 |
# File 'lib/amazon_pay/client.rb', line 654 def confirm_order_reference( amazon_order_reference_id, success_url: nil, failure_url: nil, authorization_amount: nil, currency_code: @currency_code, merchant_id: @merchant_id, mws_auth_token: nil ) parameters = { 'Action' => 'ConfirmOrderReference', 'SellerId' => merchant_id, 'AmazonOrderReferenceId' => amazon_order_reference_id } optional = { 'SuccessUrl' => success_url, 'FailureUrl' => failure_url, 'AuthorizationAmount.Amount' => , 'AuthorizationAmount.CurrencyCode' => currency_code, 'MWSAuthToken' => mws_auth_token } optional['AuthorizationAmount.CurrencyCode'] = nil if .nil? operation(parameters, optional) end |
#create_order_reference_for_id(id, id_type, inherit_shipping_address: nil, confirm_now: nil, amount: nil, currency_code: @currency_code, platform_id: nil, seller_note: nil, seller_order_id: nil, store_name: nil, custom_information: nil, supplementary_data: nil, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
Creates an order reference for the given object
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/amazon_pay/client.rb', line 133 def create_order_reference_for_id( id, id_type, inherit_shipping_address: nil, confirm_now: nil, amount: nil, currency_code: @currency_code, platform_id: nil, seller_note: nil, seller_order_id: nil, store_name: nil, custom_information: nil, supplementary_data: nil, merchant_id: @merchant_id, mws_auth_token: nil ) parameters = { 'Action' => 'CreateOrderReferenceForId', 'SellerId' => merchant_id, 'Id' => id, 'IdType' => id_type } optional = { 'InheritShippingAddress' => inherit_shipping_address, 'ConfirmNow' => confirm_now, 'OrderReferenceAttributes.OrderTotal.Amount' => amount, 'OrderReferenceAttributes.OrderTotal.CurrencyCode' => currency_code, 'OrderReferenceAttributes.PlatformId' => platform_id, 'OrderReferenceAttributes.SellerNote' => seller_note, 'OrderReferenceAttributes.SellerOrderAttributes.SellerOrderId' => seller_order_id, 'OrderReferenceAttributes.SellerOrderAttributes.StoreName' => store_name, 'OrderReferenceAttributes.SellerOrderAttributes.CustomInformation' => custom_information, 'OrderReferenceAttributes.SellerOrderAttributes.SupplementaryData' => supplementary_data, 'MWSAuthToken' => mws_auth_token } operation(parameters, optional) end |
#get_authorization_details(amazon_authorization_id, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
Returns the status of a particular authorization and the total amount captured on the authorization
766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 |
# File 'lib/amazon_pay/client.rb', line 766 def ( , merchant_id: @merchant_id, mws_auth_token: nil ) parameters = { 'Action' => 'GetAuthorizationDetails', 'SellerId' => merchant_id, 'AmazonAuthorizationId' => } optional = { 'MWSAuthToken' => mws_auth_token } operation(parameters, optional) end |
#get_billing_agreement_details(amazon_billing_agreement_id, address_consent_token: nil, access_token: nil, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
Returns details about the Billing Agreement object and its current state
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'lib/amazon_pay/client.rb', line 182 def get_billing_agreement_details( amazon_billing_agreement_id, address_consent_token: nil, access_token: nil, merchant_id: @merchant_id, mws_auth_token: nil ) parameters = { 'Action' => 'GetBillingAgreementDetails', 'SellerId' => merchant_id, 'AmazonBillingAgreementId' => amazon_billing_agreement_id } optional = { # Preseving address_consent_token for backwards compatibility # AccessToken returns all data in AddressConsentToken plus new data # You cannot pass both address_consent_token and access_token in # the same call or you will encounter a 400/"AmbiguousToken" error 'AccessToken' => access_token, 'AddressConsentToken' => , 'MWSAuthToken' => mws_auth_token } operation(parameters, optional) end |
#get_capture_details(amazon_capture_id, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
Returns the status of a particular capture and the total amount refunded on the capture
834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 |
# File 'lib/amazon_pay/client.rb', line 834 def get_capture_details( amazon_capture_id, merchant_id: @merchant_id, mws_auth_token: nil ) parameters = { 'Action' => 'GetCaptureDetails', 'SellerId' => merchant_id, 'AmazonCaptureId' => amazon_capture_id } optional = { 'MWSAuthToken' => mws_auth_token } operation(parameters, optional) end |
#get_merchant_account_status(merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
Returns status of the merchant
464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 |
# File 'lib/amazon_pay/client.rb', line 464 def get_merchant_account_status( merchant_id: @merchant_id, mws_auth_token: nil ) parameters = { 'Action' => 'GetMerchantAccountStatus', 'SellerId' => merchant_id } optional = { 'MWSAuthToken' => mws_auth_token } operation(parameters, optional) end |
#get_order_reference_details(amazon_order_reference_id, address_consent_token: nil, access_token: nil, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
Returns details about the Order Reference object and its current state
488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 |
# File 'lib/amazon_pay/client.rb', line 488 def get_order_reference_details( amazon_order_reference_id, address_consent_token: nil, access_token: nil, merchant_id: @merchant_id, mws_auth_token: nil ) parameters = { 'Action' => 'GetOrderReferenceDetails', 'SellerId' => merchant_id, 'AmazonOrderReferenceId' => amazon_order_reference_id } optional = { # Preseving address_consent_token for backwards compatibility # AccessToken returns all data in AddressConsentToken plus new data 'AccessToken' => access_token || , 'MWSAuthToken' => mws_auth_token } operation(parameters, optional) end |
#get_provider_credit_details(amazon_provider_credit_id, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 |
# File 'lib/amazon_pay/client.rb', line 979 def get_provider_credit_details( amazon_provider_credit_id, merchant_id: @merchant_id, mws_auth_token: nil ) parameters = { 'Action' => 'GetProviderCreditDetails', 'SellerId' => merchant_id, 'AmazonProviderCreditId' => amazon_provider_credit_id } optional = { 'MWSAuthToken' => mws_auth_token } operation(parameters, optional) end |
#get_provider_credit_reversal_details(amazon_provider_credit_reversal_id, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 |
# File 'lib/amazon_pay/client.rb', line 1001 def get_provider_credit_reversal_details( amazon_provider_credit_reversal_id, merchant_id: @merchant_id, mws_auth_token: nil ) parameters = { 'Action' => 'GetProviderCreditReversalDetails', 'SellerId' => merchant_id, 'AmazonProviderCreditReversalId' => amazon_provider_credit_reversal_id } optional = { 'MWSAuthToken' => mws_auth_token } operation(parameters, optional) end |
#get_refund_details(amazon_refund_id, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
Returns the status of a particular refund
901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 |
# File 'lib/amazon_pay/client.rb', line 901 def get_refund_details( amazon_refund_id, merchant_id: @merchant_id, mws_auth_token: nil ) parameters = { 'Action' => 'GetRefundDetails', 'SellerId' => merchant_id, 'AmazonRefundId' => amazon_refund_id } optional = { 'MWSAuthToken' => mws_auth_token } operation(parameters, optional) end |
#get_service_status ⇒ Object
The GetServiceStatus operation returns the operational status of the AmazonPay API section of Amazon Marketplace Web Service (Amazon MWS). Status values are GREEN, GREEN_I, YELLOW, and RED.
109 110 111 112 113 114 115 |
# File 'lib/amazon_pay/client.rb', line 109 def get_service_status parameters = { 'Action' => 'GetServiceStatus' } operation(parameters, {}) end |
#list_order_reference(query_id, query_id_type, created_time_range_start: nil, created_time_range_end: nil, sort_order: nil, page_size: nil, order_reference_status_list_filter: nil, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
Allows the search of any Amazon Pay order made using secondary seller order IDs generated manually, a solution provider, or a custom order fulfillment service.
407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 |
# File 'lib/amazon_pay/client.rb', line 407 def list_order_reference( query_id, query_id_type, created_time_range_start: nil, created_time_range_end: nil, sort_order: nil, page_size: nil, order_reference_status_list_filter: nil, merchant_id: @merchant_id, mws_auth_token: nil ) payment_domain = payment_domain_hash[@region] parameters = { 'Action' => 'ListOrderReference', 'SellerId' => merchant_id, 'QueryId' => query_id, 'QueryIdType' => query_id_type } optional = { 'CreatedTimeRange.StartTime' => created_time_range_start, 'CreatedTimeRange.EndTime' => created_time_range_end, 'SortOrder' => sort_order, 'PageSize' => page_size, 'PaymentDomain' => payment_domain, 'MWSAuthToken' => mws_auth_token } if order_reference_status_list_filter order_reference_status_list_filter.each_with_index do |val, index| optional_key = "OrderReferenceStatusListFilter.OrderReferenceStatus.#{index + 1}" optional[optional_key] = val end end operation(parameters, optional) end |
#list_order_reference_by_next_token(next_page_token) ⇒ Object
When ListOrderReference returns multiple pages you can continue by using the NextPageToken returned by ListOrderReference
451 452 453 454 455 456 457 458 459 |
# File 'lib/amazon_pay/client.rb', line 451 def list_order_reference_by_next_token(next_page_token) parameters = { 'Action' => 'ListOrderReferenceByNextToken', 'SellerId' => @merchant_id, 'NextPageToken' => next_page_token } operation(parameters, {}) end |
#modify_order_attributes(amazon_order_reference_id, seller_note: nil, seller_order_id: nil, payment_service_provider_id: nil, payment_service_provider_order_id: nil, request_payment_authorization: nil, store_name: nil, custom_information: nil, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
Modify order attributes such as CustomInformation for the order This is a convenience function for set_order_attributes to prevent accidentally passing extra variables that can’t be modified ater Amazon Order Reference (ORO) is confirmed.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/amazon_pay/client_helper.rb', line 82 def modify_order_attributes( amazon_order_reference_id, seller_note: nil, seller_order_id: nil, payment_service_provider_id: nil, payment_service_provider_order_id: nil, request_payment_authorization: nil, store_name: nil, custom_information: nil, merchant_id: @merchant_id, mws_auth_token: nil ) set_order_attributes( # amount:(This value can't be modified after order is confirmed so it isn't passed to set_order_attributes) # currency_code:(This value can't be modified after order is confirmed so it isn't passed to set_order_attributes) # platform_id:(This value can't be modified after order is confirmed so it isn't passed to set_order_attributes) amazon_order_reference_id, seller_note: seller_note, seller_order_id: seller_order_id, payment_service_provider_id: payment_service_provider_id, payment_service_provider_order_id: payment_service_provider_order_id, request_payment_authorization: , store_name: store_name, # order_item_categories:(This value can't be modified after order is confirmed so it isn't passed to set_order_attributes) custom_information: custom_information, merchant_id: merchant_id, mws_auth_token: mws_auth_token ) end |
#refund(amazon_capture_id, refund_reference_id, amount, currency_code: @currency_code, seller_refund_note: nil, soft_descriptor: nil, provider_credit_reversal_details: nil, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
Refunds a previously captured amount
864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 |
# File 'lib/amazon_pay/client.rb', line 864 def refund( amazon_capture_id, refund_reference_id, amount, currency_code: @currency_code, seller_refund_note: nil, soft_descriptor: nil, provider_credit_reversal_details: nil, merchant_id: @merchant_id, mws_auth_token: nil ) parameters = { 'Action' => 'Refund', 'SellerId' => merchant_id, 'AmazonCaptureId' => amazon_capture_id, 'RefundReferenceId' => refund_reference_id, 'RefundAmount.Amount' => amount, 'RefundAmount.CurrencyCode' => currency_code } optional = { 'SellerRefundNote' => seller_refund_note, 'SoftDescriptor' => soft_descriptor, 'MWSAuthToken' => mws_auth_token } optional.merge!(set_provider_credit_reversal_details(provider_credit_reversal_details)) if provider_credit_reversal_details operation(parameters, optional) end |
#reverse_provider_credit(amazon_provider_credit_id, credit_reversal_reference_id, amount, currency_code: @currency_code, credit_reversal_note: nil, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 |
# File 'lib/amazon_pay/client.rb', line 1027 def reverse_provider_credit( amazon_provider_credit_id, credit_reversal_reference_id, amount, currency_code: @currency_code, credit_reversal_note: nil, merchant_id: @merchant_id, mws_auth_token: nil ) parameters = { 'Action' => 'ReverseProviderCredit', 'SellerId' => merchant_id, 'AmazonProviderCreditId' => amazon_provider_credit_id, 'CreditReversalReferenceId' => credit_reversal_reference_id, 'CreditReversalAmount.Amount' => amount, 'CreditReversalAmount.CurrencyCode' => currency_code } optional = { 'CreditReversalNote' => credit_reversal_note, 'MWSAuthToken' => mws_auth_token } operation(parameters, optional) end |
#set_billing_agreement_details(amazon_billing_agreement_id, platform_id: nil, seller_note: nil, seller_billing_agreement_id: nil, custom_information: nil, store_name: nil, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
Sets billing agreement details such as a description of the agreement and other information about the seller.
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 |
# File 'lib/amazon_pay/client.rb', line 220 def set_billing_agreement_details( amazon_billing_agreement_id, platform_id: nil, seller_note: nil, seller_billing_agreement_id: nil, custom_information: nil, store_name: nil, merchant_id: @merchant_id, mws_auth_token: nil ) parameters = { 'Action' => 'SetBillingAgreementDetails', 'SellerId' => merchant_id, 'AmazonBillingAgreementId' => amazon_billing_agreement_id } optional = { 'BillingAgreementAttributes.PlatformId' => platform_id, 'BillingAgreementAttributes.SellerNote' => seller_note, 'BillingAgreementAttributes.SellerBillingAgreementAttributes.SellerBillingAgreementId' => seller_billing_agreement_id, 'BillingAgreementAttributes.SellerBillingAgreementAttributes.CustomInformation' => custom_information, 'BillingAgreementAttributes.SellerBillingAgreementAttributes.StoreName' => store_name, 'MWSAuthToken' => mws_auth_token } operation(parameters, optional) end |
#set_order_attributes(amazon_order_reference_id, amount: nil, currency_code: @currency_code, platform_id: nil, seller_note: nil, seller_order_id: nil, payment_service_provider_id: nil, payment_service_provider_order_id: nil, request_payment_authorization: nil, store_name: nil, order_item_categories: nil, custom_information: nil, supplementary_data: nil, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
Sets order attributes such as the order total and a description for the order
591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 |
# File 'lib/amazon_pay/client.rb', line 591 def set_order_attributes( amazon_order_reference_id, amount: nil, currency_code: @currency_code, platform_id: nil, seller_note: nil, seller_order_id: nil, payment_service_provider_id: nil, payment_service_provider_order_id: nil, request_payment_authorization: nil, store_name: nil, order_item_categories: nil, custom_information: nil, supplementary_data: nil, merchant_id: @merchant_id, mws_auth_token: nil ) parameters = { 'Action' => 'SetOrderAttributes', 'SellerId' => merchant_id, 'AmazonOrderReferenceId' => amazon_order_reference_id } optional = { 'OrderAttributes.OrderTotal.Amount' => amount, 'OrderAttributes.OrderTotal.CurrencyCode' => currency_code, 'OrderAttributes.PlatformId' => platform_id, 'OrderAttributes.SellerNote' => seller_note, 'OrderAttributes.SellerOrderAttributes.SellerOrderId' => seller_order_id, 'OrderAttributes.PaymentServiceProviderAttributes.PaymentServiceProviderId' => payment_service_provider_id, 'OrderAttributes.PaymentServiceProviderAttributes.PaymentServiceProviderOrderId' => payment_service_provider_order_id, 'OrderAttributes.RequestPaymentAuthorization' => , 'OrderAttributes.SellerOrderAttributes.StoreName' => store_name, 'OrderAttributes.SellerOrderAttributes.CustomInformation' => custom_information, 'OrderAttributes.SellerOrderAttributes.SupplementaryData' => supplementary_data, 'MWSAuthToken' => mws_auth_token } optional['OrderAttributes.OrderTotal.CurrencyCode'] = nil if amount.nil? if order_item_categories optional.merge!( get_categories_list( 'OrderAttributes', order_item_categories ) ) end operation(parameters, optional) end |
#set_order_reference_details(amazon_order_reference_id, amount, currency_code: @currency_code, platform_id: nil, seller_note: nil, seller_order_id: nil, request_payment_authorization: nil, store_name: nil, order_item_categories: nil, custom_information: nil, supplementary_data: nil, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
Sets order reference details such as the order total and a description for the order
528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 |
# File 'lib/amazon_pay/client.rb', line 528 def set_order_reference_details( amazon_order_reference_id, amount, currency_code: @currency_code, platform_id: nil, seller_note: nil, seller_order_id: nil, request_payment_authorization: nil, store_name: nil, order_item_categories: nil, custom_information: nil, supplementary_data: nil, merchant_id: @merchant_id, mws_auth_token: nil ) parameters = { 'Action' => 'SetOrderReferenceDetails', 'SellerId' => merchant_id, 'AmazonOrderReferenceId' => amazon_order_reference_id, 'OrderReferenceAttributes.OrderTotal.Amount' => amount, 'OrderReferenceAttributes.OrderTotal.CurrencyCode' => currency_code } optional = { 'OrderReferenceAttributes.PlatformId' => platform_id, 'OrderReferenceAttributes.RequestPaymentAuthorization' => , 'OrderReferenceAttributes.SellerNote' => seller_note, 'OrderReferenceAttributes.SellerOrderAttributes.SellerOrderId' => seller_order_id, 'OrderReferenceAttributes.SellerOrderAttributes.StoreName' => store_name, 'OrderReferenceAttributes.SellerOrderAttributes.CustomInformation' => custom_information, 'OrderReferenceAttributes.SellerOrderAttributes.SupplementaryData' => supplementary_data, 'MWSAuthToken' => mws_auth_token } if order_item_categories optional.merge!( get_categories_list( 'OrderReferenceAttributes', order_item_categories ) ) end operation(parameters, optional) end |
#validate_billing_agreement(amazon_billing_agreement_id, merchant_id: @merchant_id, mws_auth_token: nil) ⇒ Object
Validates the status of the BillingAgreement object and the payment method associated with it
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 |
# File 'lib/amazon_pay/client.rb', line 280 def validate_billing_agreement( amazon_billing_agreement_id, merchant_id: @merchant_id, mws_auth_token: nil ) parameters = { 'Action' => 'ValidateBillingAgreement', 'SellerId' => merchant_id, 'AmazonBillingAgreementId' => amazon_billing_agreement_id } optional = { 'MWSAuthToken' => mws_auth_token } operation(parameters, optional) end |