amazon_pay 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6fe8a7cb7c7d3bf5e8984213b08f09ac8efacc70
4
+ data.tar.gz: 742f3bf2b4c60bbe6c4fb68f877c7ac58be6415f
5
+ SHA512:
6
+ metadata.gz: 68b3f8d645532fd264f6dfdc3450bf5d645534005376f98ab1f7437ba4240952f24e1205eb9aa0e6b1ef0bc3ed72baff9d663bd719784170eeed50e4e731b50c
7
+ data.tar.gz: d80bb0c8a923dfe4ceae7e7091d8b6f300e79a71f0f3ff9494d0fa5b88079e20348066961b8484949c5b5b82922345f608891d66c274ca0cbd02ce3eb723be88
data/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "{}"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright {yyyy} {name of copyright owner}
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
202
+
data/NOTICE ADDED
@@ -0,0 +1,9 @@
1
+ Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License"). You may not use
4
+ this file except in compliance with the License. A copy of the License is
5
+ located at http://aws.amazon.com/apache2.0/ or in the "license" file
6
+ accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT
7
+ WARRANTIES OR CONDITIONS OF ANY KIND, either express or simplied. See the
8
+ License for the specific language governing permissions and limitations under
9
+ the License.
data/README.md ADDED
@@ -0,0 +1,428 @@
1
+ # Amazon Pay Ruby SDK
2
+ Amazon Pay API Integration
3
+
4
+ # Install
5
+
6
+ ```
7
+ gem install amazon_pay
8
+ ```
9
+ or add the following in your Gemfile:
10
+
11
+ ```ruby
12
+ gem 'amazon_pay'
13
+ ```
14
+ ```
15
+ bundle install
16
+ ```
17
+
18
+ ## Requirements
19
+
20
+ * Ruby 2.0.0 or higher
21
+
22
+ ## Quick Start
23
+
24
+ Instantiating the client:
25
+
26
+ ```ruby
27
+ require 'amazon_pay'
28
+
29
+ # Your Amazon Pay keys are
30
+ # available in your Seller Central account
31
+ merchant_id = 'YOUR_MERCHANT_ID'
32
+ access_key = 'YOUR_ACCESS_KEY'
33
+ secret_key = 'YOUR_SECRET_KEY'
34
+
35
+ client = AmazonPay::Client.new(
36
+ merchant_id,
37
+ access_key,
38
+ secret_key
39
+ )
40
+ ```
41
+
42
+ ### Testing in Sandbox Mode
43
+
44
+ The sandbox parameter is defaulted to false if not specified:
45
+
46
+ ```ruby
47
+ require 'amazon_pay'
48
+
49
+ # Your Amazon Pay keys are
50
+ # available in your Seller Central account
51
+ merchant_id = 'YOUR_MERCHANT_ID'
52
+ access_key = 'YOUR_ACCESS_KEY'
53
+ secret_key = 'YOUR_SECRET_KEY'
54
+
55
+ client = AmazonPay::Client.new(
56
+ merchant_id,
57
+ access_key,
58
+ secret_key,
59
+ sandbox: true
60
+ )
61
+ ```
62
+
63
+
64
+ ### Adjusting Region and Currency Code
65
+
66
+ ```ruby
67
+ require 'amazon_pay'
68
+
69
+ # Your Amazon Pay keys are
70
+ # available in your Seller Central account
71
+ merchant_id = 'YOUR_MERCHANT_ID'
72
+ access_key = 'YOUR_ACCESS_KEY'
73
+ secret_key = 'YOUR_SECRET_KEY'
74
+
75
+ client = AmazonPay::Client.new(
76
+ merchant_id,
77
+ access_key,
78
+ secret_key,
79
+ region: :eu,
80
+ currency_code: :gbp
81
+ )
82
+ ```
83
+
84
+ ### Making an API Call
85
+
86
+ Below is an example on how to make the GetOrderReferenceDetails API call:
87
+
88
+ ```ruby
89
+ require 'amazon_pay'
90
+
91
+ # Your Amazon Pay keys are
92
+ # available in your Seller Central account
93
+ merchant_id = 'YOUR_MERCHANT_ID'
94
+ access_key = 'YOUR_ACCESS_KEY'
95
+ secret_key = 'YOUR_SECRET_KEY'
96
+
97
+ client = AmazonPay::Client.new(
98
+ merchant_id,
99
+ access_key,
100
+ secret_key,
101
+ sandbox: true
102
+ )
103
+
104
+ # These values are grabbed from the Amazon Pay
105
+ # Address and Wallet widgets
106
+ amazon_order_reference_id = 'AMAZON_ORDER_REFERENCE_ID'
107
+ address_consent_token = 'ADDRESS_CONSENT_TOKEN'
108
+
109
+ client.get_order_reference_details(
110
+ amazon_order_reference_id,
111
+ address_consent_token: address_consent_token
112
+ )
113
+
114
+ ```
115
+
116
+ ### Response Parsing
117
+
118
+ ```ruby
119
+ # These values are grabbed from the Amazon Pay
120
+ # Address and Wallet widgets
121
+ amazon_order_reference_id = 'AMAZON_ORDER_REFERENCE_ID'
122
+ address_consent_token = 'ADDRESS_CONSENT_TOKEN'
123
+
124
+ response = client.get_order_reference_details(
125
+ amazon_order_reference_id,
126
+ address_consent_token: address_consent_token
127
+ )
128
+
129
+ # This will return the original response body as a String
130
+ response.body
131
+
132
+ # This will return a REXML object
133
+ response.to_xml
134
+
135
+ # The 'get_element' method allows quick conversion to REXML
136
+ # and parsing for the xml element. This will return a
137
+ # String value from the specified element.
138
+ xpath = 'XPath for the node you would like to extract'
139
+ element = 'Node/Element name you would like to extract the value from'
140
+ response.get_element(xpath, element)
141
+
142
+ # This will return the status code of the response
143
+ response.code
144
+
145
+ # This will return true or false depending on the status code
146
+ response.success
147
+ ```
148
+
149
+ ### Instant Payment Notification Verification and Parsing
150
+
151
+ ```ruby
152
+ # This can be placed in your controller for a method
153
+ # that is configured to receive a "POST" IPN from Amazon.
154
+ headers = request.headers
155
+ body = request.body.read
156
+
157
+ ipn = AmazonPay::IpnHandler.new(headers, body)
158
+
159
+ # This will return "true" if the notification is a
160
+ # valid IPN from Amazon
161
+ ipn.authentic?
162
+
163
+ # The following are methods used to extract the necessary
164
+ # data from the IPN
165
+ ipn.type
166
+ ipn.message_id
167
+ ipn.topic_arn
168
+ ipn.message
169
+ ipn.timestamp
170
+ ipn.signature
171
+ ipn.signature_version
172
+ ipn.signing_cert_url
173
+ ipn.unsubscribe_url
174
+ ipn.notification_type
175
+ ipn.seller_id
176
+ ipn.environment
177
+ ipn.version
178
+ ipn.notification_data
179
+ ipn.message_timestamp
180
+
181
+ ```
182
+
183
+ ### Standard One Time Transaction API Flow
184
+
185
+ ```ruby
186
+ require 'amazon_pay'
187
+
188
+ # Your Amazon Pay keys are
189
+ # available in your Seller Central account
190
+ merchant_id = 'YOUR_MERCHANT_ID'
191
+ access_key = 'YOUR_ACCESS_KEY'
192
+ secret_key = 'YOUR_SECRET_KEY'
193
+
194
+ client = AmazonPay::Client.new(
195
+ merchant_id,
196
+ access_key,
197
+ secret_key,
198
+ sandbox: true
199
+ )
200
+
201
+ # These values are grabbed from the Amazon Pay
202
+ # Address and Wallet widgets
203
+ amazon_order_reference_id = 'AMAZON_ORDER_REFERENCE_ID'
204
+ address_consent_token = 'ADDRESS_CONSENT_TOKEN'
205
+
206
+ # To get the buyers full address if shipping/tax
207
+ # calculations are needed you can use the following
208
+ # API call to obtain the order reference details.
209
+ client.get_order_reference_details(
210
+ amazon_order_reference_id,
211
+ address_consent_token: address_consent_token
212
+ )
213
+
214
+ amount = '10.00'
215
+
216
+ # Make the SetOrderReferenceDetails API call to
217
+ # configure the Amazon Order Reference Id.
218
+ # There are additional optional parameters that
219
+ # are not used below.
220
+ client.set_order_reference_details(
221
+ amazon_order_reference_id,
222
+ amount,
223
+ currency_code: 'USD', # Default: USD
224
+ seller_note: 'Your Seller Note',
225
+ seller_order_id: 'Your Seller Order Id',
226
+ store_name: 'Your Store Name'
227
+ )
228
+
229
+ # Make the ConfirmOrderReference API call to
230
+ # confirm the details set in the API call
231
+ # above.
232
+ client.confirm_order_reference(amazon_order_reference_id)
233
+
234
+ # Set a unique id for your current authorization
235
+ # of this payment.
236
+ authorization_reference_id = 'Your Unique Id'
237
+
238
+ # Make the Authorize API call to authorize the
239
+ # transaction. You can also capture the amount
240
+ # in this API call or make the Capture API call
241
+ # separately. There are additional optional
242
+ # parameters not used below.
243
+ response = client.authorize(
244
+ amazon_order_reference_id,
245
+ authorization_reference_id,
246
+ amount,
247
+ currency_code: 'USD', # Default: USD
248
+ seller_authorization_note: 'Your Authorization Note',
249
+ transaction_timeout: 0, # Set to 0 for synchronous mode
250
+ capture_now: true # Set this to true if you want to capture the amount in the same API call
251
+ )
252
+
253
+ # You will need the Amazon Authorization Id from the
254
+ # Authorize API response if you decide to make the
255
+ # Capture API call separately.
256
+ amazon_authorization_id = response.get_element('AuthorizeResponse/AuthorizeResult/AuthorizationDetails','AmazonAuthorizationId')
257
+
258
+ # Set a unique id for your current capture of
259
+ # this payment.
260
+ capture_reference_id = 'Your Unique Id'
261
+
262
+ # Make the Capture API call if you did not set the
263
+ # 'capture_now' parameter to 'true'. There are
264
+ # additional optional parameters that are not used
265
+ # below.
266
+ client.capture(
267
+ amazon_authorization_id,
268
+ capture_reference_id,
269
+ amount,
270
+ currency_code: 'USD', # Default: USD
271
+ seller_capture_note: 'Your Capture Note'
272
+ )
273
+
274
+ # Close the order reference once your one time
275
+ # payment transaction is complete.
276
+ client.close_order_reference(amazon_order_reference_id)
277
+
278
+ ```
279
+
280
+ ### Subscriptions API Flow
281
+
282
+ ```ruby
283
+ require 'amazon_pay'
284
+
285
+ # Your Amazon Pay keys are
286
+ # available in your Seller Central account
287
+ merchant_id = 'YOUR_MERCHANT_ID'
288
+ access_key = 'YOUR_ACCESS_KEY'
289
+ secret_key = 'YOUR_SECRET_KEY'
290
+
291
+ client = AmazonPay::Client.new(
292
+ merchant_id,
293
+ access_key,
294
+ secret_key,
295
+ sandbox: true
296
+ )
297
+
298
+ # These values are grabbed from the Amazon Pay
299
+ # Address and Wallet widgets
300
+ amazon_billing_agreement_id = 'AMAZON_BILLING_AGREEMENT_ID'
301
+ address_consent_token = 'ADDRESS_CONSENT_TOKEN'
302
+
303
+ # To get the buyers full address if shipping/tax
304
+ # calculations are needed you can use the following
305
+ # API call to obtain the billing agreement details.
306
+ client.get_billing_agreement_details(
307
+ amazon_billing_agreement_id,
308
+ address_consent_token
309
+ )
310
+
311
+ # Next you will need to set the various details
312
+ # for this subscription with the following API call.
313
+ # There are additional optional parameters that
314
+ # are not used below.
315
+ client.set_billing_agreement_details(
316
+ amazon_billing_agreement_id,
317
+ seller_note: 'Your Seller Note',
318
+ seller_billing_agreement_id: 'Your Transaction Id',
319
+ store_name: 'Your Store Name',
320
+ custom_information: 'Additional Information'
321
+ )
322
+
323
+ # Make the ConfirmBillingAgreement API call to confirm
324
+ # the Amazon Billing Agreement Id with the details set above.
325
+ # Be sure that everything is set correctly above before
326
+ # confirming.
327
+ client.confirm_billing_agreement(
328
+ amazon_billing_agreement_id
329
+ )
330
+
331
+ # The following API call is not needed at this point, but
332
+ # can be used in the future when you need to validate that
333
+ # the payment method is still valid with the associated billing
334
+ # agreement id.
335
+ client.validate_billing_agreement(
336
+ amazon_billing_agreement_id
337
+ )
338
+
339
+ # Set the amount for your first authorization.
340
+ amount = '10.00'
341
+
342
+ # Set a unique authorization reference id for your
343
+ # first transaction on the billing agreement.
344
+ authorization_reference_id = 'Your Unique Id'
345
+
346
+ # Now you can authorize your first transaction on the
347
+ # billing agreement id. Every month you can make the
348
+ # same API call to continue charging your buyer
349
+ # with the 'capture_now' parameter set to true. You can
350
+ # also make the Capture API call separately. There are
351
+ # additional optional parameters that are not used
352
+ # below.
353
+ client.authorize_on_billing_agreement(
354
+ amazon_billing_agreement_id,
355
+ authorization_reference_id,
356
+ amount,
357
+ currency_code: 'USD', # Default: USD
358
+ seller_authorization_note: 'Your Authorization Note',
359
+ transaction_timeout: 0, # Set to 0 for synchronous mode
360
+ capture_now: true, # Set this to true if you want to capture the amount in the same API call
361
+ seller_note: 'Your Seller Note',
362
+ seller_order_id: 'Your Order Id',
363
+ store_name: 'Your Store Name',
364
+ custom_information: 'Additional Information'
365
+ )
366
+
367
+ # You will need the Amazon Authorization Id from the
368
+ # AuthorizeOnBillingAgreement API response if you decide
369
+ # to make the Capture API call separately.
370
+ amazon_authorization_id = res.get_element('AuthorizeOnBillingAgreementResponse/AuthorizeOnBillingAgreementResult/AuthorizationDetails','AmazonAuthorizationId')
371
+
372
+ # Set a unique id for your current capture of
373
+ # this payment.
374
+ capture_reference_id = 'Your Unique Id'
375
+
376
+ # Make the Capture API call if you did not set the
377
+ # 'capture_now' parameter to 'true'. There are
378
+ # additional optional parameters that are not used
379
+ # below.
380
+ client.capture(
381
+ amazon_authorization_id,
382
+ capture_reference_id,
383
+ amount,
384
+ currency_code: 'USD', # Default: USD
385
+ seller_capture_note: 'Your Capture Note'
386
+ )
387
+
388
+ # The following API call should not be made until you
389
+ # are ready to terminate the billing agreement.
390
+ client.close_billing_agreement(
391
+ amazon_billing_agreement_id,
392
+ closure_reason: 'Reason For Closing'
393
+ )
394
+
395
+ ```
396
+
397
+
398
+ ### Get Login Profile API
399
+
400
+ This API call allows you to obtain user profile information
401
+ once a user has logged into your application using
402
+ their Amazon credentials.
403
+
404
+ ```ruby
405
+ require 'amazon_pay'
406
+
407
+ # Your client id is located in your Seller
408
+ # Central account.
409
+ client_id = 'Your Client Id'
410
+
411
+ login = AmazonPay::Login.new(
412
+ client_id,
413
+ region: :na, # Default: :na
414
+ sandbox: true # Default: false
415
+ )
416
+
417
+ # The access token is available in the return URL
418
+ # parameters after a user has logged in.
419
+ access_token = 'User Access Token'
420
+
421
+ # Make the 'get_user_info' api call.
422
+ profile = login.get_login_profile(access_token)
423
+
424
+ name = profile['name']
425
+ email = profile['email']
426
+ user_id = profile['user_id']
427
+
428
+ ```