payjpv2 1.0.10 โ 1.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +2 -2
- data/example.rb +61 -11
- data/lib/payjpv2/api_client.rb +2 -2
- data/lib/payjpv2/models/metadata_value.rb +2 -1
- data/lib/payjpv2/models/payment_method_response.rb +2 -1
- data/lib/payjpv2/version.rb +1 -1
- data/spec/integration/anyof_deserialization_spec.rb +107 -0
- data/spec/integration/payment_methods_api_detach_spec.rb +137 -0
- metadata +5 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b5c7c9af553704a217bd596adb3053420567631ce8cc4f70e645359d4d4bd39e
|
|
4
|
+
data.tar.gz: c6f326ca919ac51333a6088d36dccca76d3a7748006709b52af31b0beaf1a9b1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 347a4b4656ec911fc1cdb57edff26d85111fa396c62e7d620d31ff529b4eb28c5f9cf0104131316e95583cab03177d4e6261dc794fe4a438fa22486dbcd665bd
|
|
7
|
+
data.tar.gz: aa7a00e763734f551ee06ec9eaba83608c798d9979ae473c28cc36edfc7530a67aa3abf44117e949c841dc2c1ba4a502c9372f1ba48feea428ea646cbb6d268d
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -5,7 +5,7 @@ A Ruby client library for the PAY.JP v2 API. This SDK provides a convenient way
|
|
|
5
5
|
This Ruby gem is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
|
|
6
6
|
|
|
7
7
|
- API version: 2.0.0
|
|
8
|
-
- Package version: 1.0.
|
|
8
|
+
- Package version: 1.0.11
|
|
9
9
|
- Generator version: 7.14.0
|
|
10
10
|
- Build package: org.openapitools.codegen.languages.RubyClientCodegen
|
|
11
11
|
|
|
@@ -26,7 +26,7 @@ gem install payjpv2
|
|
|
26
26
|
Add this line to your application's Gemfile:
|
|
27
27
|
|
|
28
28
|
```ruby
|
|
29
|
-
gem 'payjpv2', '~> 1.0.
|
|
29
|
+
gem 'payjpv2', '~> 1.0.11'
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
Then execute:
|
data/example.rb
CHANGED
|
@@ -21,6 +21,7 @@ api_instance = PAYJPv2::CustomersApi.new
|
|
|
21
21
|
checkout_sessions_api = PAYJPv2::CheckoutSessionsApi.new
|
|
22
22
|
products_api = PAYJPv2::ProductsApi.new
|
|
23
23
|
prices_api = PAYJPv2::PricesApi.new
|
|
24
|
+
payment_methods_api = PAYJPv2::PaymentMethodsApi.new
|
|
24
25
|
|
|
25
26
|
customer_create_request = PAYJPv2::CustomerCreateRequest.new(
|
|
26
27
|
email: 'jennyrosen@example.com',
|
|
@@ -73,16 +74,65 @@ begin
|
|
|
73
74
|
end
|
|
74
75
|
puts "\n"
|
|
75
76
|
|
|
76
|
-
# 5.
|
|
77
|
-
|
|
77
|
+
# 5. PaymentMethod operations
|
|
78
|
+
# Note: create_payment_method is available only in test mode. In production,
|
|
79
|
+
# a PaymentMethod is created by tokenizing card details on the client side
|
|
80
|
+
# (e.g. payment.js) and then attaching the resulting token to a Customer.
|
|
81
|
+
puts "=== 5. PaymentMethod operations ==="
|
|
82
|
+
|
|
83
|
+
# 5a. Create PaymentMethod (test mode)
|
|
84
|
+
puts "\n--- 5a. Create PaymentMethod (test mode) ---"
|
|
85
|
+
payment_method_request = PAYJPv2::PaymentMethodCardCreateRequest.new(
|
|
86
|
+
type: 'card',
|
|
87
|
+
card: PAYJPv2::PaymentMethodCreateCardDetailsRequest.new(
|
|
88
|
+
number: '4242424242424242',
|
|
89
|
+
exp_month: 12,
|
|
90
|
+
exp_year: 2030,
|
|
91
|
+
cvc: '123'
|
|
92
|
+
),
|
|
93
|
+
billing_details: PAYJPv2::PaymentMethodCardBillingDetailsRequest.new(
|
|
94
|
+
email: 'billing@example.com'
|
|
95
|
+
)
|
|
96
|
+
)
|
|
97
|
+
payment_method = payment_methods_api.create_payment_method(payment_method_request)
|
|
98
|
+
payment_method_id = payment_method.id
|
|
99
|
+
puts "Created PaymentMethod: #{payment_method_id}"
|
|
100
|
+
puts "Type: #{payment_method.type}"
|
|
101
|
+
|
|
102
|
+
# 5b. Attach PaymentMethod to Customer
|
|
103
|
+
puts "\n--- 5b. Attach PaymentMethod ---"
|
|
104
|
+
attached = payment_methods_api.attach_payment_method(
|
|
105
|
+
payment_method_id,
|
|
106
|
+
PAYJPv2::PaymentMethodAttachRequest.new(customer_id: customer_id)
|
|
107
|
+
)
|
|
108
|
+
puts "Attached PaymentMethod: #{attached.id}"
|
|
109
|
+
puts "Customer: #{attached.customer_id}"
|
|
110
|
+
|
|
111
|
+
# 5c. Retrieve PaymentMethod (active)
|
|
112
|
+
puts "\n--- 5c. Retrieve PaymentMethod ---"
|
|
113
|
+
retrieved_pm = payment_methods_api.get_payment_method(payment_method_id)
|
|
114
|
+
puts "PaymentMethod ID: #{retrieved_pm.id}"
|
|
115
|
+
puts "Customer: #{retrieved_pm.customer_id}"
|
|
116
|
+
puts "Detached at: #{retrieved_pm.detached_at || '(active)'}"
|
|
117
|
+
|
|
118
|
+
# 5d. Detach PaymentMethod
|
|
119
|
+
# The API marks the PaymentMethod with `detached_at` while keeping
|
|
120
|
+
# `customer_id` for historical reference.
|
|
121
|
+
puts "\n--- 5d. Detach PaymentMethod ---"
|
|
122
|
+
detached = payment_methods_api.detach_payment_method(payment_method_id)
|
|
123
|
+
puts "Detached PaymentMethod: #{detached.id}"
|
|
124
|
+
puts "Detached at: #{detached.detached_at}\n\n"
|
|
125
|
+
|
|
126
|
+
# 6. Delete Customer
|
|
127
|
+
puts "=== 6. Delete Customer ==="
|
|
78
128
|
api_instance.delete_customer(customer_id)
|
|
79
129
|
puts "Deleted customer: #{customer_id}\n\n"
|
|
80
130
|
|
|
81
|
-
#
|
|
82
|
-
puts "===
|
|
131
|
+
# 7. Create Product, Price, and Checkout Session
|
|
132
|
+
puts "=== 7. Create Product, Price, and Checkout Session ==="
|
|
83
133
|
|
|
84
|
-
#
|
|
85
|
-
puts "\n---
|
|
134
|
+
# 7a. Create Product
|
|
135
|
+
puts "\n--- 7a. Create Product ---"
|
|
86
136
|
product_request = PAYJPv2::ProductCreateRequest.new(
|
|
87
137
|
name: 'Sample Product',
|
|
88
138
|
description: 'A sample product for checkout session demo',
|
|
@@ -100,8 +150,8 @@ begin
|
|
|
100
150
|
puts "Created product: #{product_id}"
|
|
101
151
|
puts "Product name: #{product.name}"
|
|
102
152
|
|
|
103
|
-
#
|
|
104
|
-
puts "\n---
|
|
153
|
+
# 7b. Create Price
|
|
154
|
+
puts "\n--- 7b. Create Price ---"
|
|
105
155
|
price_request = PAYJPv2::PriceCreateRequest.new(
|
|
106
156
|
currency: 'jpy',
|
|
107
157
|
product_id: product_id,
|
|
@@ -121,8 +171,8 @@ begin
|
|
|
121
171
|
puts "Created price: #{price_id}"
|
|
122
172
|
puts "Unit amount: #{price.unit_amount} JPY"
|
|
123
173
|
|
|
124
|
-
#
|
|
125
|
-
puts "\n---
|
|
174
|
+
# 7c. Create Checkout Session
|
|
175
|
+
puts "\n--- 7c. Create Checkout Session ---"
|
|
126
176
|
line_items = [
|
|
127
177
|
PAYJPv2::LineItemRequest.new(
|
|
128
178
|
price_id: price_id, # Use the actual price ID we just created
|
|
@@ -158,5 +208,5 @@ begin
|
|
|
158
208
|
puts "=== All tests passed! ==="
|
|
159
209
|
|
|
160
210
|
rescue PAYJPv2::ApiError => e
|
|
161
|
-
puts "Exception when calling
|
|
211
|
+
puts "Exception when calling PAYJPv2 API: #{e}"
|
|
162
212
|
end
|
data/lib/payjpv2/api_client.rb
CHANGED
|
@@ -280,9 +280,9 @@ module PAYJPv2
|
|
|
280
280
|
data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
|
|
281
281
|
end
|
|
282
282
|
else
|
|
283
|
-
# models (e.g. Pet) or oneOf
|
|
283
|
+
# models (e.g. Pet) or oneOf / anyOf
|
|
284
284
|
klass = PAYJPv2.const_get(return_type)
|
|
285
|
-
klass.respond_to?(:openapi_one_of) ? klass.build(data) : klass.build_from_hash(data)
|
|
285
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(data) : klass.build_from_hash(data)
|
|
286
286
|
end
|
|
287
287
|
end
|
|
288
288
|
|
|
@@ -88,7 +88,8 @@ module PAYJPv2
|
|
|
88
88
|
return model if model
|
|
89
89
|
else
|
|
90
90
|
# raise if data contains keys that are not known to the model
|
|
91
|
-
|
|
91
|
+
# NOTE: acceptable_attributes returns symbols while data keys are strings (from JSON.parse), so symbolize before diff
|
|
92
|
+
raise if const.respond_to?(:acceptable_attributes) && !(data.keys.map(&:to_sym) - const.acceptable_attributes).empty?
|
|
92
93
|
model = const.build_from_hash(data)
|
|
93
94
|
return model if model
|
|
94
95
|
end
|
|
@@ -87,7 +87,8 @@ module PAYJPv2
|
|
|
87
87
|
return model if model
|
|
88
88
|
else
|
|
89
89
|
# raise if data contains keys that are not known to the model
|
|
90
|
-
|
|
90
|
+
# NOTE: acceptable_attributes returns symbols while data keys are strings (from JSON.parse), so symbolize before diff
|
|
91
|
+
raise if const.respond_to?(:acceptable_attributes) && !(data.keys.map(&:to_sym) - const.acceptable_attributes).empty?
|
|
91
92
|
model = const.build_from_hash(data)
|
|
92
93
|
return model if model
|
|
93
94
|
end
|
data/lib/payjpv2/version.rb
CHANGED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
PaymentMethodResponse ใฎใใใช anyOf module ใ API client ใฎ convert_to_type ็ต็ฑใง
|
|
3
|
+
ๆญฃใใใใทใชใขใฉใคใบใใใใใจใ็ขบ่ชใใในใใใฏใ
|
|
4
|
+
|
|
5
|
+
้ๅปใ templates/ruby/api_client.mustache ใฎ convert_to_type ใฏ openapi_one_of ใ ใใ
|
|
6
|
+
ใใงใใฏใใฆ openapi_any_of ใ่ฆใฆใใชใใฃใใใใ Pydantic ใฎ RootModel + Union ใใ
|
|
7
|
+
็ๆใใใ anyOf module ใซๅฏพใใฆ build_from_hash ใๅผใใงใใพใ
|
|
8
|
+
``NoMethodError: undefined method 'build_from_hash' for module PAYJPv2::PaymentMethodResponse``
|
|
9
|
+
ใ็บ็ใใฆใใใ
|
|
10
|
+
|
|
11
|
+
ๅ ใใฆ partial_anyof_module.mustache (ใใใณ partial_oneof_module.mustache) ใฎ
|
|
12
|
+
find_and_cast_into_type ใฏ data.keys (string, from JSON.parse) ใ
|
|
13
|
+
acceptable_attributes (symbol) ใจ็ดๆฅๆฏ่ผใใฆใใใใใๅธธใซ raise โ rescue โ nil ใง
|
|
14
|
+
build ่ชไฝใๆฉ่ฝใใฆใใชใใฃใใ
|
|
15
|
+
|
|
16
|
+
ไธก่
ใไฟฎๆญฃใใๅพใฎๆๅใๅๅธฐใในใใจใใฆๅบๅฎใใใ
|
|
17
|
+
=end
|
|
18
|
+
|
|
19
|
+
require 'spec_helper'
|
|
20
|
+
|
|
21
|
+
describe 'anyOf module deserialization via ApiClient#convert_to_type' do
|
|
22
|
+
let(:api_client) { PAYJPv2::ApiClient.new }
|
|
23
|
+
|
|
24
|
+
let(:card_payload) do
|
|
25
|
+
{
|
|
26
|
+
'object' => 'payment_method',
|
|
27
|
+
'id' => 'pm_test_card',
|
|
28
|
+
'livemode' => false,
|
|
29
|
+
'type' => 'card',
|
|
30
|
+
'customer_id' => 'cus_test',
|
|
31
|
+
'detached_at' => nil,
|
|
32
|
+
'metadata' => {},
|
|
33
|
+
'created_at' => '2026-01-01T00:00:00Z',
|
|
34
|
+
'updated_at' => '2026-01-01T00:00:00Z',
|
|
35
|
+
'billing_details' => {
|
|
36
|
+
'name' => 'PAY TARO',
|
|
37
|
+
'phone' => '09012345678',
|
|
38
|
+
'email' => 'test@example.com',
|
|
39
|
+
'address' => {
|
|
40
|
+
'country' => 'JP',
|
|
41
|
+
'zip' => '1000001',
|
|
42
|
+
'state' => 'Tokyo',
|
|
43
|
+
'city' => 'Chiyoda',
|
|
44
|
+
'line1' => '1-1-1',
|
|
45
|
+
'line2' => nil
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
'card' => {
|
|
49
|
+
'last4' => '4242',
|
|
50
|
+
'brand' => 'visa',
|
|
51
|
+
'exp_month' => 12,
|
|
52
|
+
'exp_year' => 2030,
|
|
53
|
+
'fingerprint' => 'fp_test',
|
|
54
|
+
'country' => 'JP'
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
let(:paypay_payload) do
|
|
60
|
+
{
|
|
61
|
+
'object' => 'payment_method',
|
|
62
|
+
'id' => 'pm_test_paypay',
|
|
63
|
+
'livemode' => false,
|
|
64
|
+
'type' => 'paypay',
|
|
65
|
+
'customer_id' => 'cus_test',
|
|
66
|
+
'detached_at' => nil,
|
|
67
|
+
'metadata' => {},
|
|
68
|
+
'created_at' => '2026-01-01T00:00:00Z',
|
|
69
|
+
'updated_at' => '2026-01-01T00:00:00Z',
|
|
70
|
+
'billing_details' => {
|
|
71
|
+
'name' => 'PAY TARO',
|
|
72
|
+
'phone' => '09012345678',
|
|
73
|
+
'email' => 'test@example.com',
|
|
74
|
+
'address' => {
|
|
75
|
+
'country' => 'JP',
|
|
76
|
+
'zip' => '1000001',
|
|
77
|
+
'state' => 'Tokyo',
|
|
78
|
+
'city' => 'Chiyoda',
|
|
79
|
+
'line1' => '1-1-1',
|
|
80
|
+
'line2' => nil
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
it 'PaymentMethodResponse ใ anyOf module ใจใใฆ็ๆใใใฆใใใใจ' do
|
|
87
|
+
expect(PAYJPv2::PaymentMethodResponse).to be_a(Module)
|
|
88
|
+
expect(PAYJPv2::PaymentMethodResponse).to respond_to(:openapi_any_of)
|
|
89
|
+
expect(PAYJPv2::PaymentMethodResponse).to respond_to(:build)
|
|
90
|
+
expect(PAYJPv2::PaymentMethodResponse).not_to respond_to(:build_from_hash)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
it 'card ๅใฎใฌในใใณในใ convert_to_type ใง PaymentMethodCardResponse ใซ่งฃๆฑบใงใใใใจ' do
|
|
94
|
+
result = api_client.send(:convert_to_type, card_payload, 'PaymentMethodResponse')
|
|
95
|
+
expect(result).to be_a(PAYJPv2::PaymentMethodCardResponse)
|
|
96
|
+
expect(result.id).to eq('pm_test_card')
|
|
97
|
+
expect(result.type).to eq('card')
|
|
98
|
+
expect(result.card.last4).to eq('4242')
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
it 'paypay ๅใฎใฌในใใณในใ convert_to_type ใง PaymentMethodPayPayResponse ใซ่งฃๆฑบใงใใใใจ' do
|
|
102
|
+
result = api_client.send(:convert_to_type, paypay_payload, 'PaymentMethodResponse')
|
|
103
|
+
expect(result).to be_a(PAYJPv2::PaymentMethodPayPayResponse)
|
|
104
|
+
expect(result.id).to eq('pm_test_paypay')
|
|
105
|
+
expect(result.type).to eq('paypay')
|
|
106
|
+
end
|
|
107
|
+
end
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
ๅ ็ๅบใใๅ ฑๅใใใไบ่ฑกใฎๅๅธฐใในใใ
|
|
3
|
+
|
|
4
|
+
pm_api = PAYJPv2::PaymentMethodsApi.new
|
|
5
|
+
pm_api.detach_payment_method(payment_method_id)
|
|
6
|
+
# => NoMethodError: undefined method 'build_from_hash' for module PAYJPv2::PaymentMethodResponse
|
|
7
|
+
|
|
8
|
+
ใใใณใใฌใผใไฟฎๆญฃๅพใฏ่ตทใใชใใใจใใใใณ่ฟใๅคใๆณๅฎใฉใใใฎ
|
|
9
|
+
ๅ
ทไฝใฏใฉใน (PaymentMethodCardResponse / PaymentMethodPayPayResponse) ใง
|
|
10
|
+
่ฟใฃใฆใใใใจใๅผใณๅบใ็ต่ทฏๅ
จไฝใงไฟ่จผใใใ
|
|
11
|
+
|
|
12
|
+
anyof_deserialization_spec.rb ใฏ ApiClient#convert_to_type ใ็ดๆฅๅฉใใฆใใ
|
|
13
|
+
ใใฐใฎๆ นๅ ใฎๅไฝๆค่จผใ ใใๆฌ spec ใฏๅ ็ๅบใๆธใใใณใผใ็ต่ทฏใใฎใใฎใ
|
|
14
|
+
Typhoeus stub ็ต็ฑใงๅ็พใใใ
|
|
15
|
+
=end
|
|
16
|
+
|
|
17
|
+
require 'spec_helper'
|
|
18
|
+
|
|
19
|
+
describe 'PAYJPv2::PaymentMethodsApi#detach_payment_method (regression for anyOf build_from_hash)' do
|
|
20
|
+
let(:payment_method_id) { 'pm_test_card' }
|
|
21
|
+
|
|
22
|
+
let(:detached_card_response_body) do
|
|
23
|
+
{
|
|
24
|
+
'object' => 'payment_method',
|
|
25
|
+
'id' => payment_method_id,
|
|
26
|
+
'livemode' => false,
|
|
27
|
+
'type' => 'card',
|
|
28
|
+
'customer_id' => 'cus_test',
|
|
29
|
+
'detached_at' => '2026-05-13T15:00:00Z',
|
|
30
|
+
'metadata' => {},
|
|
31
|
+
'created_at' => '2026-01-01T00:00:00Z',
|
|
32
|
+
'updated_at' => '2026-05-13T15:00:00Z',
|
|
33
|
+
'billing_details' => {
|
|
34
|
+
'name' => 'PAY TARO',
|
|
35
|
+
'phone' => '09012345678',
|
|
36
|
+
'email' => 'test@example.com',
|
|
37
|
+
'address' => {
|
|
38
|
+
'country' => 'JP',
|
|
39
|
+
'zip' => '1000001',
|
|
40
|
+
'state' => 'Tokyo',
|
|
41
|
+
'city' => 'Chiyoda',
|
|
42
|
+
'line1' => '1-1-1',
|
|
43
|
+
'line2' => nil
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
'card' => {
|
|
47
|
+
'last4' => '4242',
|
|
48
|
+
'brand' => 'visa',
|
|
49
|
+
'exp_month' => 12,
|
|
50
|
+
'exp_year' => 2030,
|
|
51
|
+
'fingerprint' => 'fp_test',
|
|
52
|
+
'country' => 'JP'
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
let(:detached_paypay_response_body) do
|
|
58
|
+
{
|
|
59
|
+
'object' => 'payment_method',
|
|
60
|
+
'id' => 'pm_test_paypay',
|
|
61
|
+
'livemode' => false,
|
|
62
|
+
'type' => 'paypay',
|
|
63
|
+
'customer_id' => 'cus_test',
|
|
64
|
+
'detached_at' => '2026-05-13T15:00:00Z',
|
|
65
|
+
'metadata' => {},
|
|
66
|
+
'created_at' => '2026-01-01T00:00:00Z',
|
|
67
|
+
'updated_at' => '2026-05-13T15:00:00Z',
|
|
68
|
+
'billing_details' => {
|
|
69
|
+
'name' => 'PAY TARO',
|
|
70
|
+
'phone' => '09012345678',
|
|
71
|
+
'email' => 'test@example.com',
|
|
72
|
+
'address' => {
|
|
73
|
+
'country' => 'JP',
|
|
74
|
+
'zip' => '1000001',
|
|
75
|
+
'state' => 'Tokyo',
|
|
76
|
+
'city' => 'Chiyoda',
|
|
77
|
+
'line1' => '1-1-1',
|
|
78
|
+
'line2' => nil
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
before do
|
|
85
|
+
PAYJPv2.configure do |c|
|
|
86
|
+
c.host = 'api.pay.jp'
|
|
87
|
+
c.access_token = 'sk_test_dummy'
|
|
88
|
+
end
|
|
89
|
+
Typhoeus::Expectation.clear
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
after do
|
|
93
|
+
Typhoeus::Expectation.clear
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
it 'card ๅใฎ detach ใฌในใใณในใ PaymentMethodCardResponse ใงๅใๅใใ' do
|
|
97
|
+
Typhoeus.stub(/payment_methods\/#{payment_method_id}\/detach/).and_return(
|
|
98
|
+
Typhoeus::Response.new(
|
|
99
|
+
code: 200,
|
|
100
|
+
headers: { 'Content-Type' => 'application/json' },
|
|
101
|
+
body: detached_card_response_body.to_json
|
|
102
|
+
)
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
pm_api = PAYJPv2::PaymentMethodsApi.new
|
|
106
|
+
|
|
107
|
+
expect { pm_api.detach_payment_method(payment_method_id) }.not_to raise_error
|
|
108
|
+
|
|
109
|
+
result = pm_api.detach_payment_method(payment_method_id)
|
|
110
|
+
expect(result).to be_a(PAYJPv2::PaymentMethodCardResponse)
|
|
111
|
+
expect(result.id).to eq(payment_method_id)
|
|
112
|
+
expect(result.type).to eq('card')
|
|
113
|
+
expect(result.detached_at).not_to be_nil
|
|
114
|
+
expect(result.card.last4).to eq('4242')
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
it 'paypay ๅใฎ detach ใฌในใใณในใ PaymentMethodPayPayResponse ใงๅใๅใใ' do
|
|
118
|
+
paypay_id = 'pm_test_paypay'
|
|
119
|
+
Typhoeus.stub(/payment_methods\/#{paypay_id}\/detach/).and_return(
|
|
120
|
+
Typhoeus::Response.new(
|
|
121
|
+
code: 200,
|
|
122
|
+
headers: { 'Content-Type' => 'application/json' },
|
|
123
|
+
body: detached_paypay_response_body.to_json
|
|
124
|
+
)
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
pm_api = PAYJPv2::PaymentMethodsApi.new
|
|
128
|
+
|
|
129
|
+
expect { pm_api.detach_payment_method(paypay_id) }.not_to raise_error
|
|
130
|
+
|
|
131
|
+
result = pm_api.detach_payment_method(paypay_id)
|
|
132
|
+
expect(result).to be_a(PAYJPv2::PaymentMethodPayPayResponse)
|
|
133
|
+
expect(result.id).to eq(paypay_id)
|
|
134
|
+
expect(result.type).to eq('paypay')
|
|
135
|
+
expect(result.detached_at).not_to be_nil
|
|
136
|
+
end
|
|
137
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: payjpv2
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.11
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- PAY.JP
|
|
@@ -362,6 +362,8 @@ files:
|
|
|
362
362
|
- spec/api/statements_api_spec.rb
|
|
363
363
|
- spec/api/tax_rates_api_spec.rb
|
|
364
364
|
- spec/api/terms_api_spec.rb
|
|
365
|
+
- spec/integration/anyof_deserialization_spec.rb
|
|
366
|
+
- spec/integration/payment_methods_api_detach_spec.rb
|
|
365
367
|
- spec/models/apple_pay_config_request_spec.rb
|
|
366
368
|
- spec/models/balance_list_response_spec.rb
|
|
367
369
|
- spec/models/balance_response_spec.rb
|
|
@@ -527,6 +529,8 @@ test_files:
|
|
|
527
529
|
- spec/api/statements_api_spec.rb
|
|
528
530
|
- spec/api/tax_rates_api_spec.rb
|
|
529
531
|
- spec/api/terms_api_spec.rb
|
|
532
|
+
- spec/integration/anyof_deserialization_spec.rb
|
|
533
|
+
- spec/integration/payment_methods_api_detach_spec.rb
|
|
530
534
|
- spec/models/apple_pay_config_request_spec.rb
|
|
531
535
|
- spec/models/balance_list_response_spec.rb
|
|
532
536
|
- spec/models/balance_response_spec.rb
|