Class: MWS::OffAmazonPayments::Client

Inherits:
Peddler::Client show all
Defined in:
lib/mws/off_amazon_payments/client.rb

Overview

Note:

The Off-Amazon Payments API section is only applicable to payments made through the Login and Pay with Amazon service offered by Amazon Payments. You cannot use this API section to process payments for Amazon Marketplace, Amazon Webstore, or Checkout by Amazon.

The Off-Amazon Payments API helps you to process payments for purchases made by buyers on your website using the Login and Pay with Amazon service. This API enables you to programmatically retrieve shipping and payment information provided by the buyer from their Amazon account. It allows you to authorize, capture, and refund payments, enabling a variety of payments scenarios.

Instance Attribute Summary

Attributes inherited from Peddler::Client

#auth_token, #body, #merchant_id, #path, #primary_marketplace_id, #version

Instance Method Summary collapse

Methods inherited from Peddler::Client

#aws_endpoint, #defaults, #error_handler, #headers, #initialize, #marketplace, #marketplace_id, #marketplace_id=, on_error, #on_error, #operation, path, #run, version

Constructor Details

This class inherits a constructor from Peddler::Client

Instance Method Details

#authorize(amazon_order_reference_id, authorization_reference_id, authorization_amount, opts = {}) ⇒ Peddler::XMLParser

Reserves a specified amount against the payment method(s) stored in the order reference

Parameters:

  • amazon_order_reference_id (String)
  • authorization_reference_id (String)
  • authorization_amount (Struct, Hash)
  • opts (Hash) (defaults to: {})

Options Hash (opts):

  • :seller_authorization_note (String)
  • :transaction_timeout (Integer)
  • :capture_now (Boolean)
  • :soft_descriptor (String)

Returns:

See Also:



42
43
44
45
46
47
48
49
50
51
# File 'lib/mws/off_amazon_payments/client.rb', line 42

def authorize(amazon_order_reference_id, authorization_reference_id, authorization_amount, opts = {})
  operation('Authorize')
    .add(opts.update(
           'AmazonOrderReferenceId' => amazon_order_reference_id,
           'AuthorizationReferenceId' => authorization_reference_id,
           'AuthorizationAmount' => authorization_amount
    ))

  run
end

#authorize_on_billing_agreement(amazon_billing_agreement_id, authorization_reference_id, authorization_amount, opts = {}) ⇒ Peddler::XMLParser

Reserves a specified amount against the payment method(s) stored in the billing agreement

Parameters:

  • amazon_billing_agreement_id (String)
  • authorization_reference_id (String)
  • authorization_amount (Hash, Struct)
  • opts (Hash) (defaults to: {})

Options Hash (opts):

  • :seller_authorization_note (String)
  • :transaction_timeout (Integer)
  • :capture_now (Boolean)
  • :soft_descriptor (String)
  • :seller_note (String)
  • :platform_id (String)
  • :seller_order_attributes (Hash, Struct)
  • :inherit_shipping_address (Boolean)

Returns:

See Also:



271
272
273
274
275
276
277
278
279
280
# File 'lib/mws/off_amazon_payments/client.rb', line 271

def authorize_on_billing_agreement(amazon_billing_agreement_id, authorization_reference_id, authorization_amount, opts = {})
  operation('AuthorizeOnBillingAgreement')
    .add(opts.update(
           'AmazonBillingAgreementId' => amazon_billing_agreement_id,
           'AuthorizationReferenceId' => authorization_reference_id,
           'AuthorizationAmount' => authorization_amount
    ))

  run
end

#cancel_order_reference(amazon_order_reference_id, opts = {}) ⇒ Peddler::XMLParser

Cancels a previously confirmed order reference

Parameters:

  • amazon_order_reference_id (String)
  • opts (Hash) (defaults to: {})

Options Hash (opts):

  • cancelation_reason (String)

Returns:

See Also:



60
61
62
63
64
65
# File 'lib/mws/off_amazon_payments/client.rb', line 60

def cancel_order_reference(amazon_order_reference_id, opts = {})
  operation('CancelOrderReference')
    .add(opts.update('AmazonOrderReferenceId' => amazon_order_reference_id))

  run
end

#capture(amazon_authorization_id, capture_reference_id, capture_amount, opts = {}) ⇒ Peddler::XMLParser

Captures funds from an authorized payment instrument

Parameters:

  • amazon_authorization_id (String)
  • capture_reference_id (String)
  • capture_amount (Struct, Hash)
  • opts (Hash) (defaults to: {})

Options Hash (opts):

  • :seller_capture_note (String)
  • :soft_descriptor (String)

Returns:

See Also:



77
78
79
80
81
82
83
84
85
86
# File 'lib/mws/off_amazon_payments/client.rb', line 77

def capture(amazon_authorization_id, capture_reference_id, capture_amount, opts = {})
  operation('Capture')
    .add(opts.update(
           'AmazonAuthorizationId' => amazon_authorization_id,
           'CaptureReferenceId' => capture_reference_id,
           'CaptureAmount' => capture_amount
    ))

  run
end

#close_authorization(amazon_authorization_id, opts = {}) ⇒ Peddler::XMLParser

Closes an authorization

Parameters:

  • amazon_authorization_id (String)
  • opts (Hash) (defaults to: {})

Options Hash (opts):

  • closure_reason (String)

Returns:

See Also:



95
96
97
98
99
100
# File 'lib/mws/off_amazon_payments/client.rb', line 95

def close_authorization(amazon_authorization_id, opts = {})
  operation('CloseAuthorization')
    .add(opts.update('AmazonAuthorizationId' => amazon_authorization_id))

  run
end

#close_billing_agreement(amazon_billing_agreement_id, opts = {}) ⇒ Peddler::XMLParser

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

Parameters:

  • amazon_billing_agreement_id (String)
  • opts (Hash) (defaults to: {})

Options Hash (opts):

  • :closure_reason (String)

Returns:

See Also:



291
292
293
294
295
296
297
298
# File 'lib/mws/off_amazon_payments/client.rb', line 291

def close_billing_agreement(amazon_billing_agreement_id, opts = {})
  operation('CloseBillingAgreement')
    .add(opts.update(
           'AmazonBillingAgreementId' => amazon_billing_agreement_id
    ))

  run
end

#close_order_reference(amazon_order_reference_id, opts = {}) ⇒ Peddler::XMLParser

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

Parameters:

  • amazon_order_reference_id (String)
  • opts (Hash) (defaults to: {})

Options Hash (opts):

  • closure_reason (String)

Returns:

See Also:



111
112
113
114
115
116
# File 'lib/mws/off_amazon_payments/client.rb', line 111

def close_order_reference(amazon_order_reference_id, opts = {})
  operation('CloseOrderReference')
    .add(opts.update('AmazonOrderReferenceId' => amazon_order_reference_id))

  run
end

#confirm_billing_agreement(amazon_billing_agreement_id) ⇒ Peddler::XMLParser

Confirms that the billing agreement is free of constraints and all required information has been set on the billing agreement

Parameters:

  • amazon_billing_agreement_id (String)

Returns:

See Also:



306
307
308
309
310
311
312
313
# File 'lib/mws/off_amazon_payments/client.rb', line 306

def confirm_billing_agreement(amazon_billing_agreement_id)
  operation('ConfirmBillingAgreement')
    .add(
      'AmazonBillingAgreementId' => amazon_billing_agreement_id
    )

  run
end

#confirm_order_reference(amazon_order_reference_id) ⇒ Peddler::XMLParser

Confirms that the order reference is free of constraints and all required information has been set on the order reference

Parameters:

  • amazon_order_reference_id (String)

Returns:

See Also:



124
125
126
127
128
129
# File 'lib/mws/off_amazon_payments/client.rb', line 124

def confirm_order_reference(amazon_order_reference_id)
  operation('ConfirmOrderReference')
    .add('AmazonOrderReferenceId' => amazon_order_reference_id)

  run
end

#create_order_reference_for_id(id, id_type, opts = {}) ⇒ Peddler::XMLParser

Creates an order reference for the given object

Parameters:

  • id (String)
  • id_type (String)
  • opts (Hash) (defaults to: {})

Options Hash (opts):

  • :inherit_shipping_address (Boolean)
  • :confirm_now (Boolean)
  • :order_reference_attributes (Struct, Hash)

Returns:

See Also:



141
142
143
144
145
146
147
148
149
# File 'lib/mws/off_amazon_payments/client.rb', line 141

def create_order_reference_for_id(id, id_type, opts = {})
  operation('CreateOrderReferenceForId')
    .add(opts.update(
           'Id' => id,
           'IdType' => id_type
    ))

  run
end

#get_authorization_details(amazon_authorization_id) ⇒ Peddler::XMLParser

Returns the status of a particular authorization and the total amount captured on the authorization

Parameters:

  • amazon_authorization_id (String)

Returns:

See Also:



157
158
159
160
161
162
# File 'lib/mws/off_amazon_payments/client.rb', line 157

def get_authorization_details(amazon_authorization_id)
  operation('GetAuthorizationDetails')
    .add('AmazonAuthorizationId' => amazon_authorization_id)

  run
end

#get_billing_agreement_details(amazon_billing_agreement_id, opts = {}) ⇒ Peddler::XMLParser

Returns details about the Billing Agreement object and its current state

Parameters:

  • amazon_billing_agreement_id (String)
  • opts (Hash) (defaults to: {})

Options Hash (opts):

  • :address_consent_token (String)

Returns:

See Also:



322
323
324
325
326
327
328
329
# File 'lib/mws/off_amazon_payments/client.rb', line 322

def get_billing_agreement_details(amazon_billing_agreement_id, opts = {})
  operation('GetBillingAgreementDetails')
    .add(opts.update(
           'AmazonBillingAgreementId' => amazon_billing_agreement_id
    ))

  run
end

#get_capture_details(amazon_capture_id) ⇒ Peddler::XMLParser

Returns the status of a particular capture and the total amount refunded on the capture

Parameters:

  • amazon_capture_id (String)

Returns:

See Also:



170
171
172
173
174
175
# File 'lib/mws/off_amazon_payments/client.rb', line 170

def get_capture_details(amazon_capture_id)
  operation('GetCaptureDetails')
    .add('AmazonCaptureId' => amazon_capture_id)

  run
end

#get_order_reference_details(amazon_order_reference_id, opts = {}) ⇒ Peddler::XMLParser

Returns details about the Order Reference object and its current state

Parameters:

  • amazon_order_reference_id (String)
  • opts (Hash) (defaults to: {})

Options Hash (opts):

  • address_consent_token (String)

Returns:

See Also:



184
185
186
187
188
189
# File 'lib/mws/off_amazon_payments/client.rb', line 184

def get_order_reference_details(amazon_order_reference_id, opts = {})
  operation('GetOrderReferenceDetails')
    .add(opts.update('AmazonOrderReferenceId' => amazon_order_reference_id))

  run
end

#get_refund_details(amazon_refund_id) ⇒ Peddler::XMLParser

Returns the status of a particular refund

Parameters:

  • amazon_refund_id (String)

Returns:

See Also:



196
197
198
199
200
201
# File 'lib/mws/off_amazon_payments/client.rb', line 196

def get_refund_details(amazon_refund_id)
  operation('GetRefundDetails')
    .add('AmazonRefundId' => amazon_refund_id)

  run
end

#get_service_statusPeddler::XMLParser

Gets the operational status of the API



207
208
209
210
# File 'lib/mws/off_amazon_payments/client.rb', line 207

def get_service_status
  operation('GetServiceStatus')
  run
end

#refund(amazon_capture_id, refund_reference_id, refund_amount, opts = {}) ⇒ Peddler::XMLParser

Refunds a previously captured amount

Parameters:

  • amazon_capture_id (String)
  • refund_reference_id (String)
  • refund_amount (Struct, Hash)
  • opts (Hash) (defaults to: {})

Options Hash (opts):

  • :seller_refund_note (String)
  • :soft_descriptor (String)

Returns:

See Also:



222
223
224
225
226
227
228
229
230
231
# File 'lib/mws/off_amazon_payments/client.rb', line 222

def refund(amazon_capture_id, refund_reference_id, refund_amount, opts = {})
  operation('Refund')
    .add(opts.update(
           'AmazonCaptureId' => amazon_capture_id,
           'RefundReferenceId' => refund_reference_id,
           'RefundAmount' => refund_amount
    ))

  run
end

#sandboxself

Switches the client to the sandbox environment



24
25
26
27
# File 'lib/mws/off_amazon_payments/client.rb', line 24

def sandbox
  self.path = "/OffAmazonPayments_Sandbox/#{version}/"
  self
end

#set_billing_agreement_details(amazon_billing_agreement_id, billing_agreement_attributes) ⇒ Peddler::XMLParser

Sets billing agreement details such as a description of the agreement and other information about the seller

Parameters:

  • amazon_billing_agreement_id (String)
  • billing_agreement_attributes (Struct, Hash)

Returns:

See Also:



338
339
340
341
342
343
344
345
346
# File 'lib/mws/off_amazon_payments/client.rb', line 338

def set_billing_agreement_details(amazon_billing_agreement_id, billing_agreement_attributes)
  operation('SetBillingAgreementDetails')
    .add(
      'AmazonBillingAgreementId' => amazon_billing_agreement_id,
      'BillingAgreementAttributes' => billing_agreement_attributes
    )

  run
end

#set_order_reference_details(amazon_order_reference_id, order_total, opts = {}) ⇒ Peddler::XMLParser

Sets order reference details such as the order total and a description for the order

Parameters:

  • amazon_order_reference_id (String)
  • order_total (Struct, Hash)
  • opts (Hash) (defaults to: {})

Options Hash (opts):

  • :platform_id (String)
  • :seller_note (String)
  • :seller_order_attributes (Struct, Hash)

Returns:

See Also:



244
245
246
247
248
249
250
251
252
# File 'lib/mws/off_amazon_payments/client.rb', line 244

def set_order_reference_details(amazon_order_reference_id, order_total, opts = {})
  operation('SetOrderReferenceDetails')
    .add(
      'AmazonOrderReferenceId' => amazon_order_reference_id,
      'OrderReferenceAttributes' => opts.update('OrderTotal' => order_total)
    )

  run
end

#validate_billing_agreement(amazon_billing_agreement_id) ⇒ Peddler::XMLParser

Validates the status of the BillingAgreement object and the payment method associated with it

Parameters:

  • amazon_billing_agreement_id (String)

Returns:

See Also:



354
355
356
357
358
359
360
361
# File 'lib/mws/off_amazon_payments/client.rb', line 354

def validate_billing_agreement(amazon_billing_agreement_id)
  operation('ValidateBillingAgreement')
    .add(
      'AmazonBillingAgreementId' => amazon_billing_agreement_id
    )

  run
end