smartpay 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/generators/smartpay/templates/controller.rb +26 -10
- data/lib/smartpay/requests/checkout_session.rb +25 -8
- data/lib/smartpay/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56d3e609ce7f1842742670dff4b7eac351f6e653e199362cdd75b6715ec60501
|
4
|
+
data.tar.gz: 35b80a47568eee0755b4335d3aa68922b5b68767ed8e2371c7a45949783b3269
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32ce2b368f3a40956d8fea8929fcf54f3a442688bdc5cb49d3fcb5d1a5b81bb5ba43adcaebd30c0dd1d004fdefa56aeb7e38687bb9912d23157f5d3ead0a33d7
|
7
|
+
data.tar.gz: db3ed60db92f3246636eb173025aefc1aa0f3153e38f67a3a690e4ad381183f6b916d59cc0f88871d0c69544c2f479a85da9eba9d04d06124e9acc1a32b98434
|
@@ -4,25 +4,41 @@ class SmartpaysController < ApplicationController
|
|
4
4
|
|
5
5
|
def create
|
6
6
|
session = Smartpay::Api.create_checkout_session({
|
7
|
-
items: [
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
7
|
+
items: [{
|
8
|
+
name: "オリジナルス STAN SMITH",
|
9
|
+
amount: 250,
|
10
|
+
currency: "JPY",
|
11
|
+
quantity: 1
|
12
|
+
}],
|
13
|
+
customer: {
|
14
|
+
accountAge: 20,
|
15
|
+
email: "merchant-support@smartpay.co",
|
16
|
+
firstName: "田中",
|
17
|
+
lastName: "太郎",
|
18
|
+
firstNameKana: "たなか",
|
19
|
+
lastNameKana: "たろう",
|
20
|
+
address: {
|
21
|
+
line1: "3-6-7",
|
22
|
+
line2: "青山パラシオタワー 11階",
|
23
|
+
subLocality: "",
|
24
|
+
locality: "港区北青山",
|
25
|
+
administrativeArea: "東京都",
|
26
|
+
postalCode: "107-0061",
|
27
|
+
country: "JP"
|
13
28
|
},
|
14
|
-
|
15
|
-
|
29
|
+
dateOfBirth: "1985-06-30",
|
30
|
+
gender: "male"
|
31
|
+
},
|
16
32
|
shipping: {
|
17
33
|
line1: "line1",
|
18
34
|
locality: "locality",
|
19
35
|
postalCode: "123",
|
20
|
-
country: "JP"
|
36
|
+
country: "JP"
|
21
37
|
},
|
22
38
|
reference: "order_ref_1234567",
|
23
39
|
successURL: "https://docs.smartpay.co/example-pages/checkout-successful",
|
24
40
|
cancelURL: "https://docs.smartpay.co/example-pages/checkout-canceled",
|
25
|
-
test: true
|
41
|
+
test: true
|
26
42
|
})
|
27
43
|
redirect_to session.redirect_url
|
28
44
|
end
|
@@ -27,13 +27,8 @@ module Smartpay
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def normalize_payload
|
30
|
-
currency =
|
31
|
-
total_amount =
|
32
|
-
items = payload.dig(:lineItemData) || payload.dig(:items)
|
33
|
-
if items.count > 0
|
34
|
-
total_amount = items.inject(0) { |sum, item| sum + (item[:amount] || 0) }
|
35
|
-
currency = items.first.dig(:currency)
|
36
|
-
end
|
30
|
+
currency = get_currency
|
31
|
+
total_amount = get_total_amount
|
37
32
|
|
38
33
|
{
|
39
34
|
customerInfo: normalize_customer_info(payload.dig(:customerInfo) || payload.dig(:customer) || {}),
|
@@ -44,7 +39,7 @@ module Smartpay
|
|
44
39
|
confirmationMethod: payload.dig(:confirmationMethod),
|
45
40
|
coupons: payload.dig(:coupons),
|
46
41
|
shippingInfo: payload.dig(:shippingInfo) || normalize_shipping(payload.dig(:shipping)),
|
47
|
-
lineItemData: items,
|
42
|
+
lineItemData: payload.dig(:orderData, :lineItemData) || payload.dig(:items),
|
48
43
|
description: payload.dig(:orderDescription),
|
49
44
|
metadata: payload.dig(:orderMetadata)
|
50
45
|
}),
|
@@ -165,6 +160,28 @@ module Smartpay
|
|
165
160
|
metadata: product.dig(:metadata)
|
166
161
|
}
|
167
162
|
end
|
163
|
+
|
164
|
+
def get_currency
|
165
|
+
currency = payload.dig(:orderData, :currency) || payload.dig(:orderData, 'currency')
|
166
|
+
if currency.nil?
|
167
|
+
items = payload.dig(:orderData, :lineItemData, :priceData) || payload.dig(:items)
|
168
|
+
if !items.nil? && items.count > 0
|
169
|
+
currency = items.first.dig(:currency)
|
170
|
+
end
|
171
|
+
end
|
172
|
+
currency
|
173
|
+
end
|
174
|
+
|
175
|
+
def get_total_amount
|
176
|
+
total_amount = payload.dig(:orderData, :amount) || payload.dig(:orderData, 'amount')
|
177
|
+
if total_amount.nil?
|
178
|
+
items = payload.dig(:orderData, :lineItemData, :priceData) || payload.dig(:items)
|
179
|
+
if !items.nil? && items.count > 0
|
180
|
+
total_amount = items.inject(0) { |sum, item| sum + (item[:amount] || 0) }
|
181
|
+
end
|
182
|
+
end
|
183
|
+
total_amount
|
184
|
+
end
|
168
185
|
end
|
169
186
|
end
|
170
187
|
end
|
data/lib/smartpay/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smartpay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Smartpay
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-10-
|
11
|
+
date: 2021-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|