Skip to content

Commit 0351281

Browse files
committed
Amazon Pay API SDK (Ruby) 2.0.0
1 parent e2ef968 commit 0351281

File tree

1 file changed

+53
-53
lines changed

1 file changed

+53
-53
lines changed

README.md

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ If you need to make an Amazon Pay API call that uses the mws.amazonservices.com|
99
## Requirements
1010

1111
- Amazon Pay account: To register for Amazon Pay, go to https://pay.amazon.com, choose your region by selecting the flag icon in the upper right corner, and then click "Register".
12-
- Node 8.0 or higher
12+
- Ruby 2.5.3 or higher
1313

1414
## Installation
1515

1616
Add this line to your application's Gemfile:
1717

1818
```ruby
19-
gem 'amazon_pay'
19+
gem 'amazon_pay'
2020
```
2121

2222
And then execute:
@@ -86,7 +86,7 @@ Please note that your merchant account must be whitelisted to use the [Delivery
8686

8787
Please note that your solution provider account must have a pre-existing relationship (valid and active MWS authorization token) with the merchant account in order to use this function.
8888

89-
- **getAuthorizationToken**(mws_auth_token: nil, merchant_id: nil, headers: nil) &#8594 GET to `#{version}/authorizationTokens#{mws_auth_token}?merchantId=#{merchant_id}`
89+
- **get_authorization_token**(mws_auth_token: nil, merchant_id: nil, headers: nil) &#8594 GET to `#{version}/authorizationTokens#{mws_auth_token}?merchantId=#{merchant_id}`
9090

9191
## Amazon Checkout v2 API
9292

@@ -102,40 +102,40 @@ The headers field is not optional for create/POST calls below because it require
102102

103103
### Amazon Checkout v2 Buyer object
104104

105-
- **getBuyer**(buyer_token: nil, headers: nil) &#8594 GET to `#{version}/buyer/{$buyerToken}`
105+
- **get_buyer**(buyer_token: nil, headers: nil) &#8594 GET to `#{version}/buyer/{$buyerToken}`
106106

107107
### Checkout v2 CheckoutSession object
108108

109-
- **createCheckoutSession**(payload: nil, headers: nil) &#8594 POST to `#{version}/checkoutSessions`
110-
- **getCheckoutSession**(checkout_session_id: nil, headers: nil) &#8594 GET to `#{version}/checkoutSessions/#{checkout_session_id}`
111-
- **updateCheckoutSession**(checkout_session_id: nil, payload: nil, headers: nil) &#8594 PATCH to `#{version}/checkoutSessions#{checkout_session_id}`
112-
- **completeCheckoutSession**(checkout_session_id: nil, payload: nil, headers: nil) &#8594 POST to `#{version}/checkoutSessions#{checkout_session_id}/complete`
109+
- **create_checkout_session**(payload: nil, headers: nil) &#8594 POST to `#{version}/checkoutSessions`
110+
- **get_checkout_session**(checkout_session_id: nil, headers: nil) &#8594 GET to `#{version}/checkoutSessions/#{checkout_session_id}`
111+
- **update_checkout_session**(checkout_session_id: nil, payload: nil, headers: nil) &#8594 PATCH to `#{version}/checkoutSessions#{checkout_session_id}`
112+
- **complete_checkout_session**(checkout_session_id: nil, payload: nil, headers: nil) &#8594 POST to `#{version}/checkoutSessions#{checkout_session_id}/complete`
113113

114114
### Checkout v2 ChargePermission object
115115

116-
- **getChargePermission**(charge_permission_id: nil, headers: nil) &#8594 GET to `#{version}/chargePermissions/#{charge_permission_id}`
117-
- **updateChargePermission**(charge_permission_id: nil, payload: nil, headers: nil) &#8594 PATCH to `#{version}/chargePermissions#{charge_permission_id}`
118-
- **closeChargePermission**(charge_permission_id: nil, payload: nil, headers: nil) &#8594 DELETE to `#{version}/chargePermissions#{charge_permission_id}/close`
116+
- **get_charge_permission**(charge_permission_id: nil, headers: nil) &#8594 GET to `#{version}/chargePermissions/#{charge_permission_id}`
117+
- **update_charge_permission**(charge_permission_id: nil, payload: nil, headers: nil) &#8594 PATCH to `#{version}/chargePermissions#{charge_permission_id}`
118+
- **close_charge_permission**(charge_permission_id: nil, payload: nil, headers: nil) &#8594 DELETE to `#{version}/chargePermissions#{charge_permission_id}/close`
119119

120120
### Checkout v2 Charge object
121121

122-
- **createCharge**(payload: nil, headers: nil) &#8594 POST to `#{version}/charges`
123-
- **getCharge**(charge_id: nil, headers: nil) &#8594 GET to `#{version}/charges/#{charge_id}`
122+
- **create_charge**(payload: nil, headers: nil) &#8594 POST to `#{version}/charges`
123+
- **get_charge**(charge_id: nil, headers: nil) &#8594 GET to `#{version}/charges/#{charge_id}`
124124
- **capture_charge**(charge_id: nil, payload: nil, headers: nil) &#8594 POST to `#{version}/charges/#{charge_id}/capture`
125-
- **cancelCharge**(charge_id: nil, payload: nil, headers: nil) &#8594 DELETE to `#{version}/charges/#{charge_id}/cancel`
125+
- **cancel_charge**(charge_id: nil, payload: nil, headers: nil) &#8594 DELETE to `#{version}/charges/#{charge_id}/cancel`
126126

127127
### Checkout v2 Refund object
128128

129-
- **createRefund**(payload: nil, headers: nil) &#8594 POST to `#{version}/refunds`
130-
- **getRefund**(refund_id: nil, headers: nil) &#8594 GET to `#{version}/refunds/#{refund_id}`
129+
- **create_refund**(payload: nil, headers: nil) &#8594 POST to `#{version}/refunds`
130+
- **get_refund**(refund_id: nil, headers: nil) &#8594 GET to `#{version}/refunds/#{refund_id}`
131131

132132
## In-Store API
133133

134134
Please contact your Amazon Pay Account Manager before using the In-Store API calls in a Production environment to obtain a copy of the In-Store Integration Guide.
135135

136-
- **instoreMerchantScan**(payload: nil, headers: nil) &#8594 POST to `#{version}/in-store/merchant_scan`
137-
- **in: payloadstoreCharge**(payload: nil, headers: nil) &#8594 POST to `#{version}/in-store/charge`
138-
- **instoreRefund**(payload: nil, headers: nil) &#8594 POST to `#{version}/in-store/refund`
136+
- **instore_merchant_scan**(payload: nil, headers: nil) &#8594 POST to `#{version}/in-store/merchant_scan`
137+
- **instore_charge**(payload: nil, headers: nil) &#8594 POST to `#{version}/in-store/charge`
138+
- **instore_refund**(payload: nil, headers: nil) &#8594 POST to `#{version}/in-store/refund`
139139

140140
# Using Convenience Functions
141141

@@ -148,9 +148,9 @@ Step 1. Construct a Client (using the previously defined Config object).
148148

149149
client = AmazonPay::AmazonPayClient.new(config)
150150
#-or-
151-
client = AmazonPay::WebStoreClient.new(config)
151+
client = AmazonPay::AmazonWebStoreClient.new(config)
152152
#-or-
153-
client = AmazonPay::InStoreClient.new(config)
153+
client = AmazonPay::AmazonInStoreClient.new(config)
154154
```
155155

156156
Step 2. Generate the payload.
@@ -182,13 +182,13 @@ Step 2. Generate the payload.
182182
Step 3. Execute the call.
183183

184184
```ruby
185-
response = client.merchant_scan(payload)
185+
response = client.merchant_scan(payload: payload)
186186
```
187187

188188
If you are a Solution Provider and need to make an API call on behalf of a different merchant account, you will need to pass along an extra authentication token parameter into the API call.
189189

190190
```ruby
191-
test_headers = {
191+
test_headers = {
192192
'x-amz-pay-authtoken': 'other_merchant_super_secret_token'
193193
}
194194
response = client.merchant_scan(payload: payload, headers: test_headers)
@@ -203,7 +203,7 @@ If you are a Solution Provider and need to make an API call on behalf of a diffe
203203

204204
config = {
205205
public_key_id: 'ABC123DEF456XYZ',
206-
private_key: File.read(File.expand_path('/test/private.pem', __dir__)),
206+
private_key: File.read(File.expand_path('tst/private.pem', __dir__)),
207207
region: 'us',
208208
sandbox: true
209209
}
@@ -227,7 +227,7 @@ If you are a Solution Provider and need to make an API call on behalf of a diffe
227227

228228
config = {
229229
public_key_id: 'ABC123DEF456XYZ',
230-
private_key: File.read(File.expand_path('/test/private.pem', __dir__)),
230+
private_key: File.read(File.expand_path('tst/private.pem', __dir__)),
231231
region: 'us',
232232
sandbox: true
233233
}
@@ -243,8 +243,8 @@ If you are a Solution Provider and need to make an API call on behalf of a diffe
243243
'x-amz-pay-idempotency-key': SecureRandom.uuid.to_s.gsub(/-/, '')
244244
}
245245

246-
client = AmazonPay::WebStoreClient.new(config)
247-
response = client.createCheckoutSession(payload: nil, headers: nil)
246+
client = AmazonPay::AmazonWebStoreClient.new(config)
247+
response = client.create_checkout_session(payload: payload, headers: headers)
248248
```
249249

250250
## Checkout v2 - Get Checkout Session
@@ -254,7 +254,7 @@ If you are a Solution Provider and need to make an API call on behalf of a diffe
254254

255255
config = {
256256
public_key_id: 'ABC123DEF456XYZ',
257-
private_key: File.read(File.expand_path('/test/private.pem', __dir__)),
257+
private_key: File.read(File.expand_path('tst/private.pem', __dir__)),
258258
region: 'us',
259259
sandbox: true
260260
}
@@ -264,8 +264,8 @@ If you are a Solution Provider and need to make an API call on behalf of a diffe
264264
}
265265

266266
checkout_session_id = '00000000-0000-0000-0000-000000000000'
267-
client = AmazonPay::WebStoreClient.new(config)
268-
response = client.get_checkout_session(checkout_session_id: checkout_session_id: checkout_session_id, headers: nil)
267+
client = AmazonPay::AmazonWebStoreClient.new(config)
268+
response = client.get_checkout_session(checkout_session_id: checkout_session_id, headers: headers)
269269
```
270270

271271
## Checkout v2 - Update Checkout Session
@@ -275,7 +275,7 @@ If you are a Solution Provider and need to make an API call on behalf of a diffe
275275

276276
config = {
277277
public_key_id: 'ABC123DEF456XYZ',
278-
private_key: File.read(File.expand_path('/test/private.pem', __dir__)),
278+
private_key: File.read(File.expand_path('tst/private.pem', __dir__)),
279279
region: 'us',
280280
sandbox: true
281281
}
@@ -301,7 +301,7 @@ If you are a Solution Provider and need to make an API call on behalf of a diffe
301301
}
302302

303303
checkout_session_id = '00000000-0000-0000-0000-000000000000'
304-
client = AmazonPay::WebStoreClient.new(config)
304+
client = AmazonPay::AmazonWebStoreClient.new(config)
305305
response = client.updateCheckoutSession(checkout_session_id: checkout_session_id, payload: payload)
306306
```
307307

@@ -312,7 +312,7 @@ If you are a Solution Provider and need to make an API call on behalf of a diffe
312312

313313
config = {
314314
public_key_id: 'ABC123DEF456XYZ',
315-
private_key: File.read(File.expand_path('/test/private.pem', __dir__)),
315+
private_key: File.read(File.expand_path('tst/private.pem', __dir__)),
316316
region: 'us',
317317
sandbox: true
318318
}
@@ -329,8 +329,8 @@ If you are a Solution Provider and need to make an API call on behalf of a diffe
329329
}
330330

331331
charge_id = 'S01-0000000-0000000-C000000'
332-
client = AmazonPay::WebStoreClient.new(config)
333-
response = client.capture_charge(charge_id: nil, payload: nil, headers: nil)
332+
client = AmazonPay::AmazonWebStoreClient.new(config)
333+
response = client.capture_charge(charge_id: charge_id, payload: payload, headers: headers)
334334
```
335335

336336
## In Store MerchantScan
@@ -358,16 +358,16 @@ Example call to generate_button_signature function:
358358

359359
config = {
360360
public_key_id: 'ABC123DEF456XYZ',
361-
private_key: File.read(File.expand_path('/test/private.pem', __dir__)),
361+
private_key: File.read(File.expand_path('tst/private.pem', __dir__)),
362362
region: 'us',
363363
sandbox: true
364364
}
365365

366-
client = AmazonPay::AmazonPayClient(config)
366+
client = AmazonPay::AmazonPayClient.new(config)
367367
payload = {
368368
webCheckoutDetails: {
369-
checkoutReviewReturnUrl: 'https://localhost/test/checkoutReview.html',
370-
checkoutResultReturnUrl: 'https://localhost/test/checkoutResult.html'
369+
checkoutReviewReturnUrl: 'https://localhosttst/checkoutReview.html',
370+
checkoutResultReturnUrl: 'https://localhosttst/checkoutResult.html'
371371
},
372372
storeId: 'amzn1.application-oa2-client.xxxxx'
373373
}
@@ -385,18 +385,18 @@ Example call to api_call function with values:
385385
* - Makes an API Call using the specified options.
386386
* @param {Object} options - The options to make the API Call
387387
* @param {String} options.method - The HTTP request method
388-
* @param {String} options.urlFragment - The URI for the API Call
389-
* @param {String} [options.payload=null] - The payload for the API Call
390-
* @param {String} [options.headers=null] - The headers for the API Call
388+
* @param {String} options.url_fragment - The URI for the API Call
389+
* @param {String} [options.payload=nil] - The payload for the API Call
390+
* @param {String} [options.headers=nil] - The headers for the API Call
391391
```
392392

393393
Example request method:
394394

395395
```ruby
396396
options = {
397397
method: 'POST',
398-
urlFragment: '#{version}/in-store/merchant_scan',
399-
: payload payload = {
398+
url_fragment: '#{version}/in-store/merchant_scan',
399+
payload = {
400400
scanData: 'UKhrmatMeKdlfY6b',
401401
scanReferenceId: '0b8fb271-2ae2-49a5-b35d4',
402402
merchantCOE: 'US',
@@ -419,8 +419,8 @@ Example request method:
419419
}
420420
}
421421

422-
client = AmazonPay::InStoreClient.new(config)
423-
signedHeders = client.api_call(options)
422+
client = AmazonPay::AmazonInStoreClient.new(config)
423+
signed_headers = client.api_call(options: options)
424424
```
425425

426426
Example call to get_signed_headers function with values:
@@ -431,9 +431,9 @@ Example call to get_signed_headers function with values:
431431
* - Signs the request provided and returns the signed headers object.
432432
* @param {Object} options - The options to make the API Call
433433
* @param {String} options.method - The HTTP request method
434-
* @param {String} options.urlFragment - The URI for the API Call
435-
* @param {String} [options.payload=null] - The payload for the API Call
436-
* @param {String} [options.headers=null] - The headers for the API Call
434+
* @param {String} options.url_fragment - The URI for the API Call
435+
* @param {String} [options.payload=nil] - The payload for the API Call
436+
* @param {String} [options.headers=nil] - The headers for the API Call
437437
**/
438438
```
439439
@@ -442,8 +442,8 @@ Example request method:
442442
```ruby
443443
options = {
444444
method: 'POST',
445-
urlFragment: '#{version}/in-store/merchant_scan',
446-
: payload payload = {
445+
url_fragment: '#{version}/in-store/merchant_scan',
446+
payload = {
447447
scanData: 'UKhrmatMeKdlfY6b',
448448
scanReferenceId: '0b8fb271-2ae2-49a5-b35d4',
449449
merchantCOE: 'US',
@@ -471,6 +471,6 @@ Example request method:
471471
}
472472
}
473473
474-
client = AmazonPay::AmazonPayClient(config)
475-
signedHeaders = client.get_signed_headers(options)
474+
client = AmazonPay::AmazonPayClient.new(config)
475+
signed_headers = client.get_signed_headers(options: options)
476476
```

0 commit comments

Comments
 (0)