jamm 1.6.0 → 2.0.0
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 +2 -4
- data/lib/jamm/api/api/payment_api.rb +272 -0
- data/lib/jamm/api/models/v1_async_status.rb +44 -0
- data/lib/jamm/api/models/v1_charge_result.rb +37 -4
- data/lib/jamm/api/models/v1_charge_status.rb +46 -0
- data/lib/jamm/api/models/v1_error_type.rb +16 -1
- data/lib/jamm/api/models/v1_event_type.rb +2 -2
- data/lib/jamm/api/models/v1_off_session_payment_async_request.rb +224 -0
- data/lib/jamm/api/models/v1_off_session_payment_async_response.rb +257 -0
- data/lib/jamm/api/models/v1_on_session_payment_data.rb +13 -4
- data/lib/jamm/api/models/v1_on_session_payment_error_code.rb +2 -1
- data/lib/jamm/api/models/v1_on_session_payment_request.rb +11 -1
- data/lib/jamm/api/models/v1_refund_request.rb +226 -0
- data/lib/jamm/api/models/v1_refund_response.rb +226 -0
- data/lib/jamm/api/models/{v1_get_major_banks_response.rb → v1_withdraw_async_request.rb} +17 -25
- data/lib/jamm/api/models/v1_withdraw_async_response.rb +257 -0
- data/lib/jamm/api/models/v1_withdraw_async_status_request.rb +215 -0
- data/lib/jamm/api/models/v1_withdraw_async_status_response.rb +257 -0
- data/lib/jamm/api.rb +10 -1
- data/lib/jamm/api_patches.rb +1 -1
- data/lib/jamm/client.rb +15 -1
- data/lib/jamm/customer.rb +17 -10
- data/lib/jamm/healthcheck.rb +3 -2
- data/lib/jamm/payment.rb +32 -10
- data/lib/jamm/version.rb +1 -1
- data/lib/jamm/webhook.rb +3 -2
- data/lib/jamm.rb +20 -7
- metadata +12 -5
- data/lib/jamm/charge.rb +0 -65
- data/lib/jamm/contract.rb +0 -39
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
#Jamm API
|
|
3
|
+
|
|
4
|
+
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
5
|
+
|
|
6
|
+
The version of the OpenAPI document: 1.0
|
|
7
|
+
|
|
8
|
+
Generated by: https://openapi-generator.tech
|
|
9
|
+
Generator version: 7.9.0
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
require 'date'
|
|
14
|
+
require 'time'
|
|
15
|
+
|
|
16
|
+
module Api
|
|
17
|
+
# This message represents the response containing the status of an asynchronous withdrawal.
|
|
18
|
+
class WithdrawAsyncStatusResponse
|
|
19
|
+
attr_accessor :status
|
|
20
|
+
|
|
21
|
+
attr_accessor :customer
|
|
22
|
+
|
|
23
|
+
attr_accessor :charge
|
|
24
|
+
|
|
25
|
+
class EnumAttributeValidator
|
|
26
|
+
attr_reader :datatype
|
|
27
|
+
attr_reader :allowable_values
|
|
28
|
+
|
|
29
|
+
def initialize(datatype, allowable_values)
|
|
30
|
+
@allowable_values = allowable_values.map do |value|
|
|
31
|
+
case datatype.to_s
|
|
32
|
+
when /Integer/i
|
|
33
|
+
value.to_i
|
|
34
|
+
when /Float/i
|
|
35
|
+
value.to_f
|
|
36
|
+
else
|
|
37
|
+
value
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def valid?(value)
|
|
43
|
+
!value || allowable_values.include?(value)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
48
|
+
def self.attribute_map
|
|
49
|
+
{
|
|
50
|
+
:'status' => :'status',
|
|
51
|
+
:'customer' => :'customer',
|
|
52
|
+
:'charge' => :'charge'
|
|
53
|
+
}
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Returns all the JSON keys this model knows about
|
|
57
|
+
def self.acceptable_attributes
|
|
58
|
+
attribute_map.values
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# Attribute type mapping.
|
|
62
|
+
def self.openapi_types
|
|
63
|
+
{
|
|
64
|
+
:'status' => :'AsyncStatus',
|
|
65
|
+
:'customer' => :'Customer',
|
|
66
|
+
:'charge' => :'ChargeResult'
|
|
67
|
+
}
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# List of attributes with nullable: true
|
|
71
|
+
def self.openapi_nullable
|
|
72
|
+
Set.new([
|
|
73
|
+
])
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# Initializes the object
|
|
77
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
78
|
+
def initialize(attributes = {})
|
|
79
|
+
if (!attributes.is_a?(Hash))
|
|
80
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Api::WithdrawAsyncStatusResponse` initialize method"
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
84
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
85
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
|
86
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Api::WithdrawAsyncStatusResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
|
87
|
+
end
|
|
88
|
+
h[k.to_sym] = v
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if attributes.key?(:'status')
|
|
92
|
+
self.status = attributes[:'status']
|
|
93
|
+
else
|
|
94
|
+
self.status = 'ASYNC_STATUS_UNSPECIFIED'
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
if attributes.key?(:'customer')
|
|
98
|
+
self.customer = attributes[:'customer']
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
if attributes.key?(:'charge')
|
|
102
|
+
self.charge = attributes[:'charge']
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
107
|
+
# @return Array for valid properties with the reasons
|
|
108
|
+
def list_invalid_properties
|
|
109
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
|
110
|
+
invalid_properties = Array.new
|
|
111
|
+
invalid_properties
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
# Check to see if the all the properties in the model are valid
|
|
115
|
+
# @return true if the model is valid
|
|
116
|
+
def valid?
|
|
117
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
|
118
|
+
true
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
# Checks equality by comparing each attribute.
|
|
122
|
+
# @param [Object] Object to be compared
|
|
123
|
+
def ==(o)
|
|
124
|
+
return true if self.equal?(o)
|
|
125
|
+
self.class == o.class &&
|
|
126
|
+
status == o.status &&
|
|
127
|
+
customer == o.customer &&
|
|
128
|
+
charge == o.charge
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
# @see the `==` method
|
|
132
|
+
# @param [Object] Object to be compared
|
|
133
|
+
def eql?(o)
|
|
134
|
+
self == o
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
# Calculates hash code according to all attributes.
|
|
138
|
+
# @return [Integer] Hash code
|
|
139
|
+
def hash
|
|
140
|
+
[status, customer, charge].hash
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
# Builds the object from hash
|
|
144
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
145
|
+
# @return [Object] Returns the model itself
|
|
146
|
+
def self.build_from_hash(attributes)
|
|
147
|
+
return nil unless attributes.is_a?(Hash)
|
|
148
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
149
|
+
transformed_hash = {}
|
|
150
|
+
openapi_types.each_pair do |key, type|
|
|
151
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
|
152
|
+
transformed_hash["#{key}"] = nil
|
|
153
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
154
|
+
# check to ensure the input is an array given that the attribute
|
|
155
|
+
# is documented as an array but the input is not
|
|
156
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
|
157
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
|
158
|
+
end
|
|
159
|
+
elsif !attributes[attribute_map[key]].nil?
|
|
160
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
new(transformed_hash)
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
# Deserializes the data based on type
|
|
167
|
+
# @param string type Data type
|
|
168
|
+
# @param string value Value to be deserialized
|
|
169
|
+
# @return [Object] Deserialized data
|
|
170
|
+
def self._deserialize(type, value)
|
|
171
|
+
case type.to_sym
|
|
172
|
+
when :Time
|
|
173
|
+
Time.parse(value)
|
|
174
|
+
when :Date
|
|
175
|
+
Date.parse(value)
|
|
176
|
+
when :String
|
|
177
|
+
value.to_s
|
|
178
|
+
when :Integer
|
|
179
|
+
value.to_i
|
|
180
|
+
when :Float
|
|
181
|
+
value.to_f
|
|
182
|
+
when :Boolean
|
|
183
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
184
|
+
true
|
|
185
|
+
else
|
|
186
|
+
false
|
|
187
|
+
end
|
|
188
|
+
when :Object
|
|
189
|
+
# generic object (usually a Hash), return directly
|
|
190
|
+
value
|
|
191
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
192
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
193
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
194
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
195
|
+
k_type = Regexp.last_match[:k_type]
|
|
196
|
+
v_type = Regexp.last_match[:v_type]
|
|
197
|
+
{}.tap do |hash|
|
|
198
|
+
value.each do |k, v|
|
|
199
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
200
|
+
end
|
|
201
|
+
end
|
|
202
|
+
else # model
|
|
203
|
+
# models (e.g. Pet) or oneOf
|
|
204
|
+
klass = Api.const_get(type)
|
|
205
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
|
206
|
+
end
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
# Returns the string representation of the object
|
|
210
|
+
# @return [String] String presentation of the object
|
|
211
|
+
def to_s
|
|
212
|
+
to_hash.to_s
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
216
|
+
# @return [Hash] Returns the object in the form of hash
|
|
217
|
+
def to_body
|
|
218
|
+
to_hash
|
|
219
|
+
end
|
|
220
|
+
|
|
221
|
+
# Returns the object in the form of hash
|
|
222
|
+
# @return [Hash] Returns the object in the form of hash
|
|
223
|
+
def to_hash
|
|
224
|
+
hash = {}
|
|
225
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
226
|
+
value = self.send(attr)
|
|
227
|
+
if value.nil?
|
|
228
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
229
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
hash[param] = _to_hash(value)
|
|
233
|
+
end
|
|
234
|
+
hash
|
|
235
|
+
end
|
|
236
|
+
|
|
237
|
+
# Outputs non-array value in the form of hash
|
|
238
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
239
|
+
# @param [Object] value Any valid value
|
|
240
|
+
# @return [Hash] Returns the value in the form of hash
|
|
241
|
+
def _to_hash(value)
|
|
242
|
+
if value.is_a?(Array)
|
|
243
|
+
value.compact.map { |v| _to_hash(v) }
|
|
244
|
+
elsif value.is_a?(Hash)
|
|
245
|
+
{}.tap do |hash|
|
|
246
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
247
|
+
end
|
|
248
|
+
elsif value.respond_to? :to_hash
|
|
249
|
+
value.to_hash
|
|
250
|
+
else
|
|
251
|
+
value
|
|
252
|
+
end
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
end
|
data/lib/jamm/api.rb
CHANGED
|
@@ -24,6 +24,7 @@ require 'jamm/api/models/googlerpc_status'
|
|
|
24
24
|
require 'jamm/api/models/protobuf_any'
|
|
25
25
|
require 'jamm/api/models/v1_add_charge_request'
|
|
26
26
|
require 'jamm/api/models/v1_add_charge_response'
|
|
27
|
+
require 'jamm/api/models/v1_async_status'
|
|
27
28
|
require 'jamm/api/models/v1_bank'
|
|
28
29
|
require 'jamm/api/models/v1_bank_assets'
|
|
29
30
|
require 'jamm/api/models/v1_bank_branch'
|
|
@@ -35,6 +36,7 @@ require 'jamm/api/models/v1_charge'
|
|
|
35
36
|
require 'jamm/api/models/v1_charge_message'
|
|
36
37
|
require 'jamm/api/models/v1_charge_message_status'
|
|
37
38
|
require 'jamm/api/models/v1_charge_result'
|
|
39
|
+
require 'jamm/api/models/v1_charge_status'
|
|
38
40
|
require 'jamm/api/models/v1_contract'
|
|
39
41
|
require 'jamm/api/models/v1_contract_message'
|
|
40
42
|
require 'jamm/api/models/v1_contract_status'
|
|
@@ -58,13 +60,14 @@ require 'jamm/api/models/v1_get_charge_response'
|
|
|
58
60
|
require 'jamm/api/models/v1_get_charges_response'
|
|
59
61
|
require 'jamm/api/models/v1_get_contract_response'
|
|
60
62
|
require 'jamm/api/models/v1_get_customer_response'
|
|
61
|
-
require 'jamm/api/models/v1_get_major_banks_response'
|
|
62
63
|
require 'jamm/api/models/v1_initial_charge'
|
|
63
64
|
require 'jamm/api/models/v1_kyc_status'
|
|
64
65
|
require 'jamm/api/models/v1_merchant'
|
|
65
66
|
require 'jamm/api/models/v1_merchant_customer'
|
|
66
67
|
require 'jamm/api/models/v1_merchant_webhook_message'
|
|
67
68
|
require 'jamm/api/models/v1_message_response'
|
|
69
|
+
require 'jamm/api/models/v1_off_session_payment_async_request'
|
|
70
|
+
require 'jamm/api/models/v1_off_session_payment_async_response'
|
|
68
71
|
require 'jamm/api/models/v1_off_session_payment_request'
|
|
69
72
|
require 'jamm/api/models/v1_off_session_payment_response'
|
|
70
73
|
require 'jamm/api/models/v1_on_session_payment_data'
|
|
@@ -76,11 +79,17 @@ require 'jamm/api/models/v1_pagination'
|
|
|
76
79
|
require 'jamm/api/models/v1_payment_authorization_status'
|
|
77
80
|
require 'jamm/api/models/v1_payment_link'
|
|
78
81
|
require 'jamm/api/models/v1_ping_response'
|
|
82
|
+
require 'jamm/api/models/v1_refund_request'
|
|
83
|
+
require 'jamm/api/models/v1_refund_response'
|
|
79
84
|
require 'jamm/api/models/v1_search_banks_response'
|
|
80
85
|
require 'jamm/api/models/v1_search_branches_response'
|
|
81
86
|
require 'jamm/api/models/v1_url'
|
|
82
87
|
require 'jamm/api/models/v1_update_customer_response'
|
|
83
88
|
require 'jamm/api/models/v1_user_account_message'
|
|
89
|
+
require 'jamm/api/models/v1_withdraw_async_request'
|
|
90
|
+
require 'jamm/api/models/v1_withdraw_async_response'
|
|
91
|
+
require 'jamm/api/models/v1_withdraw_async_status_request'
|
|
92
|
+
require 'jamm/api/models/v1_withdraw_async_status_response'
|
|
84
93
|
require 'jamm/api/models/v1_withdraw_request'
|
|
85
94
|
require 'jamm/api/models/v1_withdraw_response'
|
|
86
95
|
|
data/lib/jamm/api_patches.rb
CHANGED
data/lib/jamm/client.rb
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
module Jamm
|
|
4
4
|
module Client
|
|
5
|
-
def self.handler
|
|
5
|
+
def self.handler(merchant: nil)
|
|
6
6
|
base = Jamm::OpenAPI::ApiClient.new
|
|
7
7
|
|
|
8
8
|
# Configure
|
|
@@ -10,6 +10,20 @@ module Jamm
|
|
|
10
10
|
base.config.scheme = Jamm.openapi.config.scheme
|
|
11
11
|
base.default_headers['Authorization'] = "Bearer #{Jamm::OAuth.token}"
|
|
12
12
|
|
|
13
|
+
# Platform feature, optionally set merchant id to call Jamm API
|
|
14
|
+
# on behalf of the merchant.
|
|
15
|
+
if merchant
|
|
16
|
+
unless defined?(Jamm::Mode) && Jamm.respond_to?(:mode) && Jamm.mode == Jamm::Mode::PLATFORM
|
|
17
|
+
raise ArgumentError, 'merchant can only be set when Jamm.mode is Jamm::Mode::PLATFORM'
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Merchant ID format validation to match backend expectations (e.g. "mer-*").
|
|
21
|
+
unless merchant.is_a?(String) && merchant.match?(/\Amer-[0-9A-Za-z_-]+\z/)
|
|
22
|
+
raise ArgumentError, 'invalid merchant id format (expected something like "mer-*")'
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
base.default_headers['Jamm-Merchant'] = merchant
|
|
26
|
+
end
|
|
13
27
|
base
|
|
14
28
|
end
|
|
15
29
|
end
|
data/lib/jamm/customer.rb
CHANGED
|
@@ -16,8 +16,10 @@ module Jamm
|
|
|
16
16
|
KycStatus = Jamm::OpenAPI::KycStatus
|
|
17
17
|
PaymentAuthorizationStatus = Jamm::OpenAPI::PaymentAuthorizationStatus
|
|
18
18
|
|
|
19
|
-
def self.create(buyer:)
|
|
20
|
-
|
|
19
|
+
def self.create(buyer:, merchant: nil)
|
|
20
|
+
handler = Jamm::Client.handler(merchant: merchant)
|
|
21
|
+
|
|
22
|
+
r = Jamm::OpenAPI::CustomerApi.new(handler).create(
|
|
21
23
|
buyer: buyer
|
|
22
24
|
)
|
|
23
25
|
|
|
@@ -26,8 +28,10 @@ module Jamm
|
|
|
26
28
|
raise Jamm::ApiError.from_error(e)
|
|
27
29
|
end
|
|
28
30
|
|
|
29
|
-
def self.get(id_or_email)
|
|
30
|
-
|
|
31
|
+
def self.get(id_or_email, merchant: nil)
|
|
32
|
+
handler = Jamm::Client.handler(merchant: merchant)
|
|
33
|
+
|
|
34
|
+
r = Jamm::OpenAPI::CustomerApi.new(handler).get(id_or_email)
|
|
31
35
|
|
|
32
36
|
if r.customer.activated.nil?
|
|
33
37
|
# Activated flag requires explicit binding on false, since RPC/OpenAPI does
|
|
@@ -40,24 +44,27 @@ module Jamm
|
|
|
40
44
|
raise Jamm::ApiError.from_error(e)
|
|
41
45
|
end
|
|
42
46
|
|
|
43
|
-
def self.get_contract(id)
|
|
44
|
-
Jamm::
|
|
47
|
+
def self.get_contract(id, merchant: nil)
|
|
48
|
+
handler = Jamm::Client.handler(merchant: merchant)
|
|
49
|
+
Jamm::OpenAPI::CustomerApi.new(handler).get_contract(id)
|
|
45
50
|
rescue Jamm::OpenAPI::ApiError => e
|
|
46
51
|
return nil if [404].include?(e.code)
|
|
47
52
|
|
|
48
53
|
raise Jamm::ApiError.from_error(e)
|
|
49
54
|
end
|
|
50
55
|
|
|
51
|
-
def self.update(id, params)
|
|
52
|
-
|
|
56
|
+
def self.update(id, params, merchant: nil)
|
|
57
|
+
handler = Jamm::Client.handler(merchant: merchant)
|
|
58
|
+
r = Jamm::OpenAPI::CustomerApi.new(handler).update(id, params)
|
|
53
59
|
|
|
54
60
|
r.customer
|
|
55
61
|
rescue Jamm::OpenAPI::ApiError => e
|
|
56
62
|
raise Jamm::ApiError.from_error(e)
|
|
57
63
|
end
|
|
58
64
|
|
|
59
|
-
def self.delete(id)
|
|
60
|
-
Jamm::
|
|
65
|
+
def self.delete(id, merchant: nil)
|
|
66
|
+
handler = Jamm::Client.handler(merchant: merchant)
|
|
67
|
+
Jamm::OpenAPI::CustomerApi.new(handler).delete(id)
|
|
61
68
|
rescue Jamm::OpenAPI::ApiError => e
|
|
62
69
|
raise Jamm::ApiError.from_error(e)
|
|
63
70
|
end
|
data/lib/jamm/healthcheck.rb
CHANGED
|
@@ -7,8 +7,9 @@ require 'jamm/errors'
|
|
|
7
7
|
|
|
8
8
|
module Jamm
|
|
9
9
|
module Healthcheck
|
|
10
|
-
def self.ping
|
|
11
|
-
Jamm::
|
|
10
|
+
def self.ping(merchant: nil)
|
|
11
|
+
handler = Jamm::Client.handler(merchant: merchant)
|
|
12
|
+
Jamm::OpenAPI::HealthcheckApi.new(handler).ping
|
|
12
13
|
rescue Jamm::OpenAPI::ApiError => e
|
|
13
14
|
raise Jamm::ApiError.from_error(e)
|
|
14
15
|
end
|
data/lib/jamm/payment.rb
CHANGED
|
@@ -7,47 +7,69 @@ require 'jamm/errors'
|
|
|
7
7
|
|
|
8
8
|
module Jamm
|
|
9
9
|
module Payment
|
|
10
|
-
def self.on_session(
|
|
10
|
+
def self.on_session(
|
|
11
|
+
charge: nil,
|
|
12
|
+
redirect: nil,
|
|
13
|
+
customer: nil,
|
|
14
|
+
buyer: nil,
|
|
15
|
+
one_time: false,
|
|
16
|
+
# Platform can set merchant id to call on behalf of the merchant.
|
|
17
|
+
merchant: nil
|
|
18
|
+
)
|
|
11
19
|
request = if customer.nil?
|
|
12
20
|
Jamm::OpenAPI::OnSessionPaymentRequest.new(
|
|
13
21
|
buyer: buyer,
|
|
14
22
|
charge: charge,
|
|
15
|
-
redirect: redirect
|
|
23
|
+
redirect: redirect,
|
|
24
|
+
one_time: one_time
|
|
16
25
|
)
|
|
17
26
|
else
|
|
18
27
|
Jamm::OpenAPI::OnSessionPaymentRequest.new(
|
|
19
28
|
customer: customer,
|
|
20
29
|
charge: charge,
|
|
21
|
-
redirect: redirect
|
|
30
|
+
redirect: redirect,
|
|
31
|
+
one_time: one_time
|
|
22
32
|
)
|
|
23
33
|
end
|
|
24
34
|
|
|
25
|
-
Jamm::
|
|
35
|
+
handler = Jamm::Client.handler(merchant: merchant)
|
|
36
|
+
Jamm::OpenAPI::PaymentApi.new(handler).on_session_payment(request)
|
|
26
37
|
rescue Jamm::OpenAPI::ApiError => e
|
|
27
38
|
raise Jamm::ApiError.from_error(e)
|
|
28
39
|
end
|
|
29
40
|
|
|
30
|
-
def self.off_session(customer:, charge:)
|
|
41
|
+
def self.off_session(customer:, charge:, merchant: nil)
|
|
31
42
|
request = Jamm::OpenAPI::OffSessionPaymentRequest.new(
|
|
32
43
|
customer: customer,
|
|
33
44
|
charge: charge
|
|
34
45
|
)
|
|
35
46
|
|
|
36
|
-
Jamm::
|
|
47
|
+
handler = Jamm::Client.handler(merchant: merchant)
|
|
48
|
+
Jamm::OpenAPI::PaymentApi.new(handler).off_session_payment(request)
|
|
37
49
|
rescue Jamm::OpenAPI::ApiError => e
|
|
38
50
|
raise Jamm::ApiError.from_error(e)
|
|
39
51
|
end
|
|
40
52
|
|
|
41
|
-
def self.get(charge_id)
|
|
42
|
-
Jamm::
|
|
53
|
+
def self.get(charge_id, merchant: nil)
|
|
54
|
+
handler = Jamm::Client.handler(merchant: merchant)
|
|
55
|
+
|
|
56
|
+
Jamm::OpenAPI::PaymentApi.new(handler).get_charge(charge_id)
|
|
43
57
|
rescue Jamm::OpenAPI::ApiError => e
|
|
44
58
|
return nil if e.code == 404
|
|
45
59
|
|
|
46
60
|
raise Jamm::ApiError.from_error(e)
|
|
47
61
|
end
|
|
48
62
|
|
|
49
|
-
def self.
|
|
50
|
-
Jamm::
|
|
63
|
+
def self.refund(request, merchant: nil)
|
|
64
|
+
handler = Jamm::Client.handler(merchant: merchant)
|
|
65
|
+
Jamm::OpenAPI::PaymentApi.new(handler).refund(request)
|
|
66
|
+
rescue Jamm::OpenAPI::ApiError => e
|
|
67
|
+
raise Jamm::ApiError.from_error(e)
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def self.list(customer:, pagination: nil, merchant: nil)
|
|
71
|
+
handler = Jamm::Client.handler(merchant: merchant)
|
|
72
|
+
Jamm::OpenAPI::PaymentApi.new(handler).get_charges(customer, pagination.nil? ? {} : pagination)
|
|
51
73
|
rescue Jamm::OpenAPI::ApiError => e
|
|
52
74
|
if [404].include?(e.code)
|
|
53
75
|
nil
|
data/lib/jamm/version.rb
CHANGED
data/lib/jamm/webhook.rb
CHANGED
|
@@ -22,7 +22,7 @@ module Jamm
|
|
|
22
22
|
out.content = Jamm::OpenAPI::ChargeMessage.new(json[:content])
|
|
23
23
|
return out
|
|
24
24
|
|
|
25
|
-
when Jamm::OpenAPI::EventType::
|
|
25
|
+
when Jamm::OpenAPI::EventType::CHARGE_REFUND
|
|
26
26
|
out.content = Jamm::OpenAPI::ChargeMessage.new(json[:content])
|
|
27
27
|
return out
|
|
28
28
|
|
|
@@ -42,7 +42,8 @@ module Jamm
|
|
|
42
42
|
raise 'Unknown event type'
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
-
# Verify message
|
|
45
|
+
# Verify message.
|
|
46
|
+
# This method will use client secret to verify the message.
|
|
46
47
|
def self.verify(data:, signature:)
|
|
47
48
|
raise ArgumentError, 'data cannot be nil' if data.nil?
|
|
48
49
|
raise ArgumentError, 'signature cannot be nil' if signature.nil?
|
data/lib/jamm.rb
CHANGED
|
@@ -11,9 +11,7 @@ require 'jamm/openapi'
|
|
|
11
11
|
require 'jamm/version'
|
|
12
12
|
|
|
13
13
|
# OpenAPI wrappers
|
|
14
|
-
require 'jamm/charge'
|
|
15
14
|
require 'jamm/customer'
|
|
16
|
-
require 'jamm/contract'
|
|
17
15
|
require 'jamm/deprecation'
|
|
18
16
|
require 'jamm/healthcheck'
|
|
19
17
|
require 'jamm/payment'
|
|
@@ -24,7 +22,15 @@ require 'jamm/api_patches'
|
|
|
24
22
|
|
|
25
23
|
# Jamm Ruby SDK
|
|
26
24
|
module Jamm
|
|
25
|
+
# SDK mode, either platform or merchant.
|
|
26
|
+
module Mode
|
|
27
|
+
PLATFORM = 'platform'
|
|
28
|
+
MERCHANT = 'merchant'
|
|
29
|
+
end
|
|
30
|
+
|
|
27
31
|
# Configurable attributes.
|
|
32
|
+
@environment = nil
|
|
33
|
+
@mode = nil
|
|
28
34
|
@oauth_base = nil
|
|
29
35
|
@openapi = nil
|
|
30
36
|
@open_timeout = 30
|
|
@@ -32,31 +38,38 @@ module Jamm
|
|
|
32
38
|
@max_retry = 0
|
|
33
39
|
|
|
34
40
|
class << self
|
|
35
|
-
attr_accessor :api, :client_id, :client_secret, :api_base, :
|
|
41
|
+
attr_accessor :api, :client_id, :client_secret, :api_base, :environment, :mode, :oauth_base, :api_version, :connect_base,
|
|
36
42
|
:openapi, :open_timeout, :read_timeout, :max_retry, :retry_initial_delay, :retry_max_delay
|
|
37
43
|
end
|
|
38
44
|
|
|
39
|
-
|
|
45
|
+
# Configure SDK with Client ID and Secret.
|
|
46
|
+
# Optionally enable `platform` for platformers to call Jamm API on behalf of their merchant.
|
|
47
|
+
def self.configure(client_id:, client_secret:, env:, platform: false)
|
|
40
48
|
Jamm.client_id = client_id
|
|
41
49
|
Jamm.client_secret = client_secret
|
|
42
50
|
|
|
51
|
+
Jamm.mode = platform ? Jamm::Mode::PLATFORM : Jamm::Mode::MERCHANT
|
|
52
|
+
|
|
43
53
|
case env
|
|
44
54
|
when 'prd', 'prod', 'production'
|
|
45
|
-
self.oauth_base = 'https://merchant-identity.jamm-pay.jp'
|
|
55
|
+
self.oauth_base = Jamm.mode == Jamm::Mode::PLATFORM ? 'https://platform-identity.jamm-pay.jp' : 'https://merchant-identity.jamm-pay.jp'
|
|
46
56
|
|
|
57
|
+
self.environment = 'production'
|
|
47
58
|
self.openapi = Jamm::OpenAPI::ApiClient.new
|
|
48
59
|
openapi.config.host = 'api.jamm-pay.jp'
|
|
49
60
|
|
|
50
61
|
when 'local'
|
|
51
|
-
self.oauth_base = 'https://merchant-identity.develop.jamm-pay.jp'
|
|
62
|
+
self.oauth_base = Jamm.mode == Jamm::Mode::PLATFORM ? 'https://platform-identity.develop.jamm-pay.jp' : 'https://merchant-identity.develop.jamm-pay.jp'
|
|
52
63
|
|
|
64
|
+
self.environment = 'local'
|
|
53
65
|
self.openapi = Jamm::OpenAPI::ApiClient.new
|
|
54
66
|
openapi.config.host = 'api.jamm.test'
|
|
55
67
|
openapi.config.verify_ssl = false
|
|
56
68
|
openapi.config.verify_ssl_host = false
|
|
57
69
|
else
|
|
58
|
-
self.oauth_base = "https://merchant-identity.#{env}.jamm-pay.jp"
|
|
70
|
+
self.oauth_base = Jamm.mode == Jamm::Mode::PLATFORM ? "https://platform-identity.#{env}.jamm-pay.jp" : "https://merchant-identity.#{env}.jamm-pay.jp"
|
|
59
71
|
|
|
72
|
+
self.environment = env
|
|
60
73
|
self.openapi = Jamm::OpenAPI::ApiClient.new
|
|
61
74
|
openapi.config.host = "api.#{env}.jamm-pay.jp"
|
|
62
75
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: jamm
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jamm
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-03-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rest-client
|
|
@@ -74,6 +74,7 @@ files:
|
|
|
74
74
|
- lib/jamm/api/models/protobuf_any.rb
|
|
75
75
|
- lib/jamm/api/models/v1_add_charge_request.rb
|
|
76
76
|
- lib/jamm/api/models/v1_add_charge_response.rb
|
|
77
|
+
- lib/jamm/api/models/v1_async_status.rb
|
|
77
78
|
- lib/jamm/api/models/v1_bank.rb
|
|
78
79
|
- lib/jamm/api/models/v1_bank_assets.rb
|
|
79
80
|
- lib/jamm/api/models/v1_bank_branch.rb
|
|
@@ -85,6 +86,7 @@ files:
|
|
|
85
86
|
- lib/jamm/api/models/v1_charge_message.rb
|
|
86
87
|
- lib/jamm/api/models/v1_charge_message_status.rb
|
|
87
88
|
- lib/jamm/api/models/v1_charge_result.rb
|
|
89
|
+
- lib/jamm/api/models/v1_charge_status.rb
|
|
88
90
|
- lib/jamm/api/models/v1_contract.rb
|
|
89
91
|
- lib/jamm/api/models/v1_contract_message.rb
|
|
90
92
|
- lib/jamm/api/models/v1_contract_status.rb
|
|
@@ -108,13 +110,14 @@ files:
|
|
|
108
110
|
- lib/jamm/api/models/v1_get_charges_response.rb
|
|
109
111
|
- lib/jamm/api/models/v1_get_contract_response.rb
|
|
110
112
|
- lib/jamm/api/models/v1_get_customer_response.rb
|
|
111
|
-
- lib/jamm/api/models/v1_get_major_banks_response.rb
|
|
112
113
|
- lib/jamm/api/models/v1_initial_charge.rb
|
|
113
114
|
- lib/jamm/api/models/v1_kyc_status.rb
|
|
114
115
|
- lib/jamm/api/models/v1_merchant.rb
|
|
115
116
|
- lib/jamm/api/models/v1_merchant_customer.rb
|
|
116
117
|
- lib/jamm/api/models/v1_merchant_webhook_message.rb
|
|
117
118
|
- lib/jamm/api/models/v1_message_response.rb
|
|
119
|
+
- lib/jamm/api/models/v1_off_session_payment_async_request.rb
|
|
120
|
+
- lib/jamm/api/models/v1_off_session_payment_async_response.rb
|
|
118
121
|
- lib/jamm/api/models/v1_off_session_payment_request.rb
|
|
119
122
|
- lib/jamm/api/models/v1_off_session_payment_response.rb
|
|
120
123
|
- lib/jamm/api/models/v1_on_session_payment_data.rb
|
|
@@ -126,18 +129,22 @@ files:
|
|
|
126
129
|
- lib/jamm/api/models/v1_payment_authorization_status.rb
|
|
127
130
|
- lib/jamm/api/models/v1_payment_link.rb
|
|
128
131
|
- lib/jamm/api/models/v1_ping_response.rb
|
|
132
|
+
- lib/jamm/api/models/v1_refund_request.rb
|
|
133
|
+
- lib/jamm/api/models/v1_refund_response.rb
|
|
129
134
|
- lib/jamm/api/models/v1_search_banks_response.rb
|
|
130
135
|
- lib/jamm/api/models/v1_search_branches_response.rb
|
|
131
136
|
- lib/jamm/api/models/v1_update_customer_response.rb
|
|
132
137
|
- lib/jamm/api/models/v1_url.rb
|
|
133
138
|
- lib/jamm/api/models/v1_user_account_message.rb
|
|
139
|
+
- lib/jamm/api/models/v1_withdraw_async_request.rb
|
|
140
|
+
- lib/jamm/api/models/v1_withdraw_async_response.rb
|
|
141
|
+
- lib/jamm/api/models/v1_withdraw_async_status_request.rb
|
|
142
|
+
- lib/jamm/api/models/v1_withdraw_async_status_response.rb
|
|
134
143
|
- lib/jamm/api/models/v1_withdraw_request.rb
|
|
135
144
|
- lib/jamm/api/models/v1_withdraw_response.rb
|
|
136
145
|
- lib/jamm/api/version.rb
|
|
137
146
|
- lib/jamm/api_patches.rb
|
|
138
|
-
- lib/jamm/charge.rb
|
|
139
147
|
- lib/jamm/client.rb
|
|
140
|
-
- lib/jamm/contract.rb
|
|
141
148
|
- lib/jamm/customer.rb
|
|
142
149
|
- lib/jamm/deprecation.rb
|
|
143
150
|
- lib/jamm/errors.rb
|