amazon_pay 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: d7040fc32759f87f3f3f21b053831138dd4c5c04
4
- data.tar.gz: aac1ff85663dffd1cc964b371d9f05f669150bfc
2
+ SHA256:
3
+ metadata.gz: 294f94d2300bab4c088fe8f4609bcf25ae97b615cff07c7d5603e272a579c7d7
4
+ data.tar.gz: 8a438dbee412d742240305b6e338cb0be4ffff769d84d1fe3bb13a4ffdc035e7
5
5
  SHA512:
6
- metadata.gz: 6c746d20fd2e12307e06318b78f669656199d0baa849c0d2cd7f8bbe6f383222fe566b8ff7d0e802cb1bdc4784f742bc1c3524b69b38ce32e3738dc3cde5e7f7
7
- data.tar.gz: 6bee2aa81e8e8d8aa00f48ff71c5d8fbc7d3519b172bfd1154aa7ce9bd2ec282936eb6ca6b20e25954c86c0421d352e49a91b5582988fe65e2158c5a0f19bd7e
6
+ metadata.gz: 348548089b4b8290b71a429b6fcb7b1836c2a8cf411387419d9c9c480e9c9cab652b04b9a45868afb8bb69cd1283348e61c46953691bef29d4635756513301f2
7
+ data.tar.gz: 2f0f99a204da9a5e9119470fc7b5502f080199e794c0d3ef170f6b58a6d8e63c672ee2625196dbe6cae4d6e12d16b234135584805db2e20e06cb5b2259bb0f44
data/README.md CHANGED
@@ -113,6 +113,101 @@ client.get_order_reference_details(
113
113
 
114
114
  ```
115
115
 
116
+ Below is an example on how to query using the Seller Order ID using the
117
+ ListOrderReference API call:
118
+
119
+ ```ruby
120
+ require 'amazon_pay'
121
+
122
+ # Your Amazon Pay keys are
123
+ # available in your Seller Central account
124
+ merchant_id = 'YOUR_MERCHANT_ID'
125
+ access_key = 'YOUR_ACCESS_KEY'
126
+ secret_key = 'YOUR_SECRET_KEY'
127
+
128
+ client = AmazonPay::Client.new(
129
+ merchant_id,
130
+ access_key,
131
+ secret_key
132
+ )
133
+
134
+ seller_order_id = 'merchant_id:Test 4321'
135
+ # These are examples of input
136
+ # for the option values
137
+ query_id = '1234-example-order'
138
+ query_id_type = 'SellerOrderId'
139
+ created_time_range_start_time = '2017-09-20T17:39:27.925Z'
140
+ created_time_range_end_time = '2017-09-25T17:39:27.925Z'
141
+ sort_order = 'Descending'
142
+ order_reference_status_list_filter = ['canceled', 'open', 'closed']
143
+ page_size = 1
144
+
145
+ response = client.list_order_reference(
146
+ query_id,
147
+ query_id_type,
148
+ created_time_range_start: created_time_range_start_time,
149
+ created_time_range_end: created_time_range_end_time,
150
+ sort_order: sort_order,
151
+ page_size: page_size,
152
+ order_reference_status_list_filter: order_reference_status_list_filter,
153
+ mws_auth_token: nil
154
+ )
155
+
156
+ ```
157
+
158
+ Below is an example on how to query using the next token received
159
+ from ListOrderReference using the ListOrderReferenceByNextToken
160
+ API call:
161
+
162
+ ```ruby
163
+ require 'amazon_pay'
164
+
165
+ # Your Amazon Pay keys are
166
+ # available in your Seller Central account
167
+ merchant_id = 'YOUR_MERCHANT_ID'
168
+ access_key = 'YOUR_ACCESS_KEY'
169
+ secret_key = 'YOUR_SECRET_KEY'
170
+
171
+ client = AmazonPay::Client.new(
172
+ merchant_id,
173
+ access_key,
174
+ secret_key
175
+ )
176
+
177
+ response = client.list_order_reference_by_next_token(
178
+ 'eyJuZXh0UGFnZVRva2VuIjoiQUFBQUFBQUFBQUZXL0x3dE50TDBTUWhla29JVk5VNWgvbURhSWJXc1E2MnlVdzVuaURCTURFN2g4U0xja3EweWpCSlY4S2pVRHFJWC9wcDBKOG8rMnJDcFREa2xjWjViVmJweFhPS2xuYUJXL0pQeTB4UGIwNjlUU3dlcnVSSHB5TUREMUV2aiswM3pvY3FWbkRZL0p3VTVpWUV4cUdaeGpYbzg0WVI2NkVmek9tbTRjVUZSbDNJL2ZOOC9kMWRuMkMyaWxaMy9nNlRtU2cvMG9CdTJ2U1FVVy9rcThxc1dmS1dQNkFQaGhKK08xOFlmVko5NS9WWFRPeXliMWJVdEl0U3h5K2FlYlN1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 # 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
+ log_enabled: true,
199
+ # If you don't specify a log file like
200
+ # the example below, logging will be
201
+ # output to the standard out stream
202
+ log_file_name: 'log.txt',
203
+ # Currently only the debug level has been
204
+ # implemented in the SDK. This is done
205
+ # by default.
206
+ log_level: :debug
207
+ )
208
+
209
+ ```
210
+
116
211
  ### Response Parsing
117
212
 
118
213
  ```ruby
@@ -378,6 +378,72 @@ module AmazonPay
378
378
  operation(parameters, optional)
379
379
  end
380
380
 
381
+ # Allows the search of any Amazon Pay order made using secondary
382
+ # seller order IDs generated manually, a solution provider, or a custom
383
+ # order fulfillment service.
384
+ # @param query_id [String]
385
+ # @param query_id_type [String]
386
+ # @optional created_time_range_start [String]
387
+ # @optional created_time_range_end [String]
388
+ # @optional sort_order [String]
389
+ # @optional page_size [Integer]
390
+ # @optional order_reference_status_list_filter Array[String]
391
+ # @optional merchant_id [String]
392
+ # @optional mws_auth_token [String]
393
+ def list_order_reference(
394
+ query_id,
395
+ query_id_type,
396
+ created_time_range_start: nil,
397
+ created_time_range_end: nil,
398
+ sort_order: nil,
399
+ page_size: nil,
400
+ order_reference_status_list_filter: nil,
401
+ merchant_id: @merchant_id,
402
+ mws_auth_token: nil
403
+ )
404
+
405
+ payment_domain = payment_domain_hash[@region]
406
+
407
+ parameters = {
408
+ 'Action' => 'ListOrderReference',
409
+ 'SellerId' => merchant_id,
410
+ 'QueryId' => query_id,
411
+ 'QueryIdType' => query_id_type
412
+ }
413
+
414
+ optional = {
415
+ 'CreatedTimeRange.StartTime' => created_time_range_start,
416
+ 'CreatedTimeRange.EndTime' => created_time_range_end,
417
+ 'SortOrder' => sort_order,
418
+ 'PageSize' => page_size,
419
+ 'PaymentDomain' => payment_domain,
420
+ 'MWSAuthToken' => mws_auth_token
421
+ }
422
+
423
+ if order_reference_status_list_filter
424
+ order_reference_status_list_filter.each_with_index do |val, index|
425
+ optional_key = "OrderReferenceStatusListFilter.OrderReferenceStatus.#{index + 1}"
426
+ optional[optional_key] = val
427
+ end
428
+ end
429
+
430
+ operation(parameters, optional)
431
+ end
432
+
433
+ # When ListOrderReference returns multiple pages
434
+ # you can continue by using the NextPageToken returned
435
+ # by ListOrderReference
436
+ # @param next_page_token [String]
437
+ def list_order_reference_by_next_token(next_page_token)
438
+ parameters = {
439
+ 'Action' => 'ListOrderReferenceByNextToken',
440
+ 'SellerId' => @merchant_id,
441
+ 'NextPageToken' => next_page_token
442
+ }
443
+
444
+ operation(parameters, {})
445
+ end
446
+
381
447
  # Returns details about the Order Reference object and its current state
382
448
  # @see https://pay.amazon.com/documentation/apireference/201751630#201751970
383
449
  # @param amazon_order_reference_id [String]
@@ -938,6 +1004,17 @@ module AmazonPay
938
1004
  }
939
1005
  end
940
1006
 
1007
+ def payment_domain_hash
1008
+ {
1009
+ jp: 'FE_JPY',
1010
+ uk: 'EU_GBP',
1011
+ de: 'EU_EUR',
1012
+ eu: 'EU_EUR',
1013
+ us: 'NA_USD',
1014
+ na: 'NA_USD'
1015
+ }
1016
+ end
1017
+
941
1018
  # This method builds the provider credit details hash
942
1019
  # that will be combined with either the authorize or capture
943
1020
  # API call.
@@ -1,9 +1,7 @@
1
1
  module AmazonPay
2
-
3
2
  # This will extend the client class to add additional
4
3
  # helper methods that combine core API calls.
5
4
  class Client
6
-
7
5
  # This method combines multiple API calls to perform
8
6
  # a complete transaction with minimum requirements.
9
7
  # @param amazon_reference_id [String]
@@ -19,50 +17,53 @@ module AmazonPay
19
17
  # @optional merchant_id [String]
20
18
  # @optional mws_auth_token [String]
21
19
  def charge(
22
- amazon_reference_id,
23
- authorization_reference_id,
24
- charge_amount,
25
- charge_currency_code: @currency_code,
26
- charge_note: nil,
27
- charge_order_id: nil,
28
- store_name: nil,
29
- custom_information: nil,
30
- soft_descriptor: nil,
31
- platform_id: nil,
32
- merchant_id: @merchant_id,
33
- mws_auth_token: nil)
20
+ amazon_reference_id,
21
+ authorization_reference_id,
22
+ charge_amount,
23
+ charge_currency_code: @currency_code,
24
+ charge_note: nil,
25
+ charge_order_id: nil,
26
+ store_name: nil,
27
+ custom_information: nil,
28
+ soft_descriptor: nil,
29
+ platform_id: nil,
30
+ merchant_id: @merchant_id,
31
+ mws_auth_token: nil
32
+ )
34
33
 
35
34
  if is_order_reference?(amazon_reference_id)
36
35
  response = call_order_reference_api(
37
- amazon_reference_id,
38
- authorization_reference_id,
39
- charge_amount,
40
- charge_currency_code,
41
- charge_note,
42
- charge_order_id,
43
- store_name,
44
- custom_information,
45
- soft_descriptor,
46
- platform_id,
47
- merchant_id,
48
- mws_auth_token)
36
+ amazon_reference_id,
37
+ authorization_reference_id,
38
+ charge_amount,
39
+ charge_currency_code,
40
+ charge_note,
41
+ charge_order_id,
42
+ store_name,
43
+ custom_information,
44
+ soft_descriptor,
45
+ platform_id,
46
+ merchant_id,
47
+ mws_auth_token
48
+ )
49
49
  return response
50
50
  end
51
51
 
52
52
  if is_billing_agreement?(amazon_reference_id)
53
53
  response = call_billing_agreement_api(
54
- amazon_reference_id,
55
- authorization_reference_id,
56
- charge_amount,
57
- charge_currency_code,
58
- charge_note,
59
- charge_order_id,
60
- store_name,
61
- custom_information,
62
- soft_descriptor,
63
- platform_id,
64
- merchant_id,
65
- mws_auth_token)
54
+ amazon_reference_id,
55
+ authorization_reference_id,
56
+ charge_amount,
57
+ charge_currency_code,
58
+ charge_note,
59
+ charge_order_id,
60
+ store_name,
61
+ custom_information,
62
+ soft_descriptor,
63
+ platform_id,
64
+ merchant_id,
65
+ mws_auth_token
66
+ )
66
67
  return response
67
68
  end
68
69
  end
@@ -94,36 +95,38 @@ module AmazonPay
94
95
  )
95
96
 
96
97
  set_order_attributes(amazon_order_reference_id,
97
- # amount:(This value can't be modified after order is confirmed so it isn't passed to set_order_attributes)
98
- # currency_code:(This value can't be modified after order is confirmed so it isn't passed to set_order_attributes)
99
- # platform_id:(This value can't be modified after order is confirmed so it isn't passed to set_order_attributes)
100
- seller_note: seller_note,
101
- seller_order_id: seller_order_id,
102
- payment_service_provider_id: payment_service_provider_id,
103
- payment_service_provider_order_id: payment_service_provider_order_id,
104
- request_payment_authorization: request_payment_authorization,
105
- store_name: store_name,
106
- # order_item_categories:(This value can't be modified after order is confirmed so it isn't passed to set_order_attributes)
107
- custom_information: custom_information,
108
- merchant_id: merchant_id,
109
- mws_auth_token: mws_auth_token)
98
+ # amount:(This value can't be modified after order is confirmed so it isn't passed to set_order_attributes)
99
+ # currency_code:(This value can't be modified after order is confirmed so it isn't passed to set_order_attributes)
100
+ # platform_id:(This value can't be modified after order is confirmed so it isn't passed to set_order_attributes)
101
+ seller_note: seller_note,
102
+ seller_order_id: seller_order_id,
103
+ payment_service_provider_id: payment_service_provider_id,
104
+ payment_service_provider_order_id: payment_service_provider_order_id,
105
+ request_payment_authorization: request_payment_authorization,
106
+ store_name: store_name,
107
+ # order_item_categories:(This value can't be modified after order is confirmed so it isn't passed to set_order_attributes)
108
+ custom_information: custom_information,
109
+ merchant_id: merchant_id,
110
+ mws_auth_token: mws_auth_token
111
+ )
110
112
  end
111
113
 
112
114
  private
113
115
 
114
116
  def call_order_reference_api(
115
- amazon_reference_id,
116
- authorization_reference_id,
117
- charge_amount,
118
- charge_currency_code,
119
- charge_note,
120
- charge_order_id,
121
- store_name,
122
- custom_information,
123
- soft_descriptor,
124
- platform_id,
125
- merchant_id,
126
- mws_auth_token)
117
+ amazon_reference_id,
118
+ authorization_reference_id,
119
+ charge_amount,
120
+ charge_currency_code,
121
+ charge_note,
122
+ charge_order_id,
123
+ store_name,
124
+ custom_information,
125
+ soft_descriptor,
126
+ platform_id,
127
+ merchant_id,
128
+ mws_auth_token
129
+ )
127
130
 
128
131
  response = set_order_reference_details(
129
132
  amazon_reference_id,
@@ -135,12 +138,14 @@ module AmazonPay
135
138
  store_name: store_name,
136
139
  custom_information: custom_information,
137
140
  merchant_id: merchant_id,
138
- mws_auth_token: mws_auth_token)
141
+ mws_auth_token: mws_auth_token
142
+ )
139
143
  if response.success
140
144
  response = confirm_order_reference(
141
145
  amazon_reference_id,
142
146
  merchant_id: merchant_id,
143
- mws_auth_token: mws_auth_token)
147
+ mws_auth_token: mws_auth_token
148
+ )
144
149
  if response.success
145
150
  response = authorize(
146
151
  amazon_reference_id,
@@ -152,35 +157,34 @@ module AmazonPay
152
157
  capture_now: true,
153
158
  soft_descriptor: soft_descriptor,
154
159
  merchant_id: merchant_id,
155
- mws_auth_token: mws_auth_token)
156
- return response
157
- else
158
- return response
160
+ mws_auth_token: mws_auth_token
161
+ )
159
162
  end
160
- else
161
- return response
162
163
  end
164
+ return response
163
165
  end
164
166
 
165
167
  def call_billing_agreement_api(
166
- amazon_reference_id,
167
- authorization_reference_id,
168
- charge_amount,
169
- charge_currency_code,
170
- charge_note,
171
- charge_order_id,
172
- store_name,
173
- custom_information,
174
- soft_descriptor,
175
- platform_id,
176
- merchant_id,
177
- mws_auth_token)
168
+ amazon_reference_id,
169
+ authorization_reference_id,
170
+ charge_amount,
171
+ charge_currency_code,
172
+ charge_note,
173
+ charge_order_id,
174
+ store_name,
175
+ custom_information,
176
+ soft_descriptor,
177
+ platform_id,
178
+ merchant_id,
179
+ mws_auth_token
180
+ )
178
181
 
179
182
  response = get_billing_agreement_details(
180
183
  amazon_reference_id,
181
184
  merchant_id: merchant_id,
182
- mws_auth_token: mws_auth_token)
183
- if response.get_element('GetBillingAgreementDetailsResponse/GetBillingAgreementDetailsResult/BillingAgreementDetails/BillingAgreementStatus','State').eql?('Draft')
185
+ mws_auth_token: mws_auth_token
186
+ )
187
+ if response.get_element('GetBillingAgreementDetailsResponse/GetBillingAgreementDetailsResult/BillingAgreementDetails/BillingAgreementStatus', 'State').eql?('Draft')
184
188
  response = set_billing_agreement_details(
185
189
  amazon_reference_id,
186
190
  platform_id: platform_id,
@@ -189,15 +193,15 @@ module AmazonPay
189
193
  store_name: store_name,
190
194
  custom_information: custom_information,
191
195
  merchant_id: merchant_id,
192
- mws_auth_token: mws_auth_token)
196
+ mws_auth_token: mws_auth_token
197
+ )
193
198
  if response.success
194
199
  response = confirm_billing_agreement(
195
200
  amazon_reference_id,
196
201
  merchant_id: merchant_id,
197
- mws_auth_token: mws_auth_token)
198
- if response.success.eql?(false)
199
- return response
200
- end
202
+ mws_auth_token: mws_auth_token
203
+ )
204
+ return response if response.success.eql?(false)
201
205
  end
202
206
  end
203
207
 
@@ -217,19 +221,17 @@ module AmazonPay
217
221
  custom_information: custom_information,
218
222
  inherit_shipping_address: true,
219
223
  merchant_id: merchant_id,
220
- mws_auth_token: mws_auth_token)
224
+ mws_auth_token: mws_auth_token
225
+ )
221
226
  return response
222
227
  end
223
228
 
224
-
225
229
  def is_order_reference?(amazon_reference_id)
226
- amazon_reference_id.start_with?('S','P')
230
+ amazon_reference_id.start_with?('S', 'P')
227
231
  end
228
232
 
229
233
  def is_billing_agreement?(amazon_reference_id)
230
- amazon_reference_id.start_with?('C','B')
234
+ amazon_reference_id.start_with?('C', 'B')
231
235
  end
232
-
233
236
  end
234
-
235
237
  end
@@ -1,5 +1,5 @@
1
1
  module AmazonPay
2
- VERSION = "2.1.0"
2
+ VERSION = "2.2.0"
3
3
  SDK_NAME = "amazon-pay-sdk-ruby"
4
4
  API_VERSION = "2013-01-01"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amazon_pay
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - AmazonPay
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-12 00:00:00.000000000 Z
11
+ date: 2018-02-26 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: AmazonPay Ruby SDK
14
14
  email: amazon-pay-sdk@amazon.com
@@ -31,7 +31,7 @@ files:
31
31
  - lib/amazon_pay/version.rb
32
32
  homepage: https://github.com/amzn/amazon-pay-sdk-ruby
33
33
  licenses:
34
- - Apache License, Version 2.0
34
+ - Apache-2.0
35
35
  metadata: {}
36
36
  post_install_message:
37
37
  rdoc_options: []
@@ -49,7 +49,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
49
49
  version: '0'
50
50
  requirements: []
51
51
  rubyforge_project:
52
- rubygems_version: 2.6.12
52
+ rubygems_version: 2.7.4
53
53
  signing_key:
54
54
  specification_version: 4
55
55
  summary: AmazonPay Ruby SDK