jamm 1.7.0 → 2.1.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 +1 -1
- data/lib/jamm/api/api/payment_api.rb +136 -0
- data/lib/jamm/api/models/v1_buyer.rb +1 -1
- data/lib/jamm/api/models/v1_charge.rb +1 -1
- data/lib/jamm/api/models/v1_charge_error.rb +226 -0
- data/lib/jamm/api/models/v1_charge_message.rb +58 -4
- data/lib/jamm/api/models/v1_charge_message_status.rb +2 -1
- data/lib/jamm/api/models/v1_charge_result.rb +46 -4
- data/lib/jamm/api/models/v1_charge_status.rb +46 -0
- data/lib/jamm/api/models/v1_event_type.rb +3 -2
- data/lib/jamm/api/models/v1_initial_charge.rb +12 -2
- data/lib/jamm/api/models/v1_message_response.rb +13 -4
- 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_refund_info.rb +275 -0
- data/lib/jamm/api/models/v1_refund_request.rb +236 -0
- data/lib/jamm/api/models/v1_refund_response.rb +226 -0
- data/lib/jamm/api/models/v1_withdraw_async_response.rb +13 -4
- data/lib/jamm/api.rb +7 -0
- 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 +28 -8
- data/lib/jamm/version.rb +1 -1
- data/lib/jamm/webhook.rb +7 -2
- data/lib/jamm.rb +16 -7
- metadata +9 -4
- data/lib/jamm/charge.rb +0 -65
- data/lib/jamm/contract.rb +0 -39
|
@@ -0,0 +1,226 @@
|
|
|
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
|
+
# Response message for the Refund endpoint. A successful response means the refund request was accepted and is being processed. The final result is delivered via webhook.
|
|
18
|
+
class RefundResponse
|
|
19
|
+
# The charge ID that the refund was requested for.
|
|
20
|
+
attr_accessor :charge_id
|
|
21
|
+
|
|
22
|
+
# The external refund ID for tracking this refund request.
|
|
23
|
+
attr_accessor :refund_id
|
|
24
|
+
|
|
25
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
26
|
+
def self.attribute_map
|
|
27
|
+
{
|
|
28
|
+
:'charge_id' => :'chargeId',
|
|
29
|
+
:'refund_id' => :'refundId'
|
|
30
|
+
}
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# Returns all the JSON keys this model knows about
|
|
34
|
+
def self.acceptable_attributes
|
|
35
|
+
attribute_map.values
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Attribute type mapping.
|
|
39
|
+
def self.openapi_types
|
|
40
|
+
{
|
|
41
|
+
:'charge_id' => :'String',
|
|
42
|
+
:'refund_id' => :'String'
|
|
43
|
+
}
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# List of attributes with nullable: true
|
|
47
|
+
def self.openapi_nullable
|
|
48
|
+
Set.new([
|
|
49
|
+
])
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# Initializes the object
|
|
53
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
54
|
+
def initialize(attributes = {})
|
|
55
|
+
if (!attributes.is_a?(Hash))
|
|
56
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `Api::RefundResponse` initialize method"
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
|
60
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
61
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
|
62
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `Api::RefundResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
|
63
|
+
end
|
|
64
|
+
h[k.to_sym] = v
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if attributes.key?(:'charge_id')
|
|
68
|
+
self.charge_id = attributes[:'charge_id']
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
if attributes.key?(:'refund_id')
|
|
72
|
+
self.refund_id = attributes[:'refund_id']
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
|
77
|
+
# @return Array for valid properties with the reasons
|
|
78
|
+
def list_invalid_properties
|
|
79
|
+
warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
|
|
80
|
+
invalid_properties = Array.new
|
|
81
|
+
invalid_properties
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# Check to see if the all the properties in the model are valid
|
|
85
|
+
# @return true if the model is valid
|
|
86
|
+
def valid?
|
|
87
|
+
warn '[DEPRECATED] the `valid?` method is obsolete'
|
|
88
|
+
true
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# Checks equality by comparing each attribute.
|
|
92
|
+
# @param [Object] Object to be compared
|
|
93
|
+
def ==(o)
|
|
94
|
+
return true if self.equal?(o)
|
|
95
|
+
self.class == o.class &&
|
|
96
|
+
charge_id == o.charge_id &&
|
|
97
|
+
refund_id == o.refund_id
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# @see the `==` method
|
|
101
|
+
# @param [Object] Object to be compared
|
|
102
|
+
def eql?(o)
|
|
103
|
+
self == o
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# Calculates hash code according to all attributes.
|
|
107
|
+
# @return [Integer] Hash code
|
|
108
|
+
def hash
|
|
109
|
+
[charge_id, refund_id].hash
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# Builds the object from hash
|
|
113
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
|
114
|
+
# @return [Object] Returns the model itself
|
|
115
|
+
def self.build_from_hash(attributes)
|
|
116
|
+
return nil unless attributes.is_a?(Hash)
|
|
117
|
+
attributes = attributes.transform_keys(&:to_sym)
|
|
118
|
+
transformed_hash = {}
|
|
119
|
+
openapi_types.each_pair do |key, type|
|
|
120
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
|
121
|
+
transformed_hash["#{key}"] = nil
|
|
122
|
+
elsif type =~ /\AArray<(.*)>/i
|
|
123
|
+
# check to ensure the input is an array given that the attribute
|
|
124
|
+
# is documented as an array but the input is not
|
|
125
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
|
126
|
+
transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
|
127
|
+
end
|
|
128
|
+
elsif !attributes[attribute_map[key]].nil?
|
|
129
|
+
transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
new(transformed_hash)
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
# Deserializes the data based on type
|
|
136
|
+
# @param string type Data type
|
|
137
|
+
# @param string value Value to be deserialized
|
|
138
|
+
# @return [Object] Deserialized data
|
|
139
|
+
def self._deserialize(type, value)
|
|
140
|
+
case type.to_sym
|
|
141
|
+
when :Time
|
|
142
|
+
Time.parse(value)
|
|
143
|
+
when :Date
|
|
144
|
+
Date.parse(value)
|
|
145
|
+
when :String
|
|
146
|
+
value.to_s
|
|
147
|
+
when :Integer
|
|
148
|
+
value.to_i
|
|
149
|
+
when :Float
|
|
150
|
+
value.to_f
|
|
151
|
+
when :Boolean
|
|
152
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
153
|
+
true
|
|
154
|
+
else
|
|
155
|
+
false
|
|
156
|
+
end
|
|
157
|
+
when :Object
|
|
158
|
+
# generic object (usually a Hash), return directly
|
|
159
|
+
value
|
|
160
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
|
161
|
+
inner_type = Regexp.last_match[:inner_type]
|
|
162
|
+
value.map { |v| _deserialize(inner_type, v) }
|
|
163
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
|
164
|
+
k_type = Regexp.last_match[:k_type]
|
|
165
|
+
v_type = Regexp.last_match[:v_type]
|
|
166
|
+
{}.tap do |hash|
|
|
167
|
+
value.each do |k, v|
|
|
168
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
else # model
|
|
172
|
+
# models (e.g. Pet) or oneOf
|
|
173
|
+
klass = Api.const_get(type)
|
|
174
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
# Returns the string representation of the object
|
|
179
|
+
# @return [String] String presentation of the object
|
|
180
|
+
def to_s
|
|
181
|
+
to_hash.to_s
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
# to_body is an alias to to_hash (backward compatibility)
|
|
185
|
+
# @return [Hash] Returns the object in the form of hash
|
|
186
|
+
def to_body
|
|
187
|
+
to_hash
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
# Returns the object in the form of hash
|
|
191
|
+
# @return [Hash] Returns the object in the form of hash
|
|
192
|
+
def to_hash
|
|
193
|
+
hash = {}
|
|
194
|
+
self.class.attribute_map.each_pair do |attr, param|
|
|
195
|
+
value = self.send(attr)
|
|
196
|
+
if value.nil?
|
|
197
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
198
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
hash[param] = _to_hash(value)
|
|
202
|
+
end
|
|
203
|
+
hash
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
# Outputs non-array value in the form of hash
|
|
207
|
+
# For object, use to_hash. Otherwise, just return the value
|
|
208
|
+
# @param [Object] value Any valid value
|
|
209
|
+
# @return [Hash] Returns the value in the form of hash
|
|
210
|
+
def _to_hash(value)
|
|
211
|
+
if value.is_a?(Array)
|
|
212
|
+
value.compact.map { |v| _to_hash(v) }
|
|
213
|
+
elsif value.is_a?(Hash)
|
|
214
|
+
{}.tap do |hash|
|
|
215
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
216
|
+
end
|
|
217
|
+
elsif value.respond_to? :to_hash
|
|
218
|
+
value.to_hash
|
|
219
|
+
else
|
|
220
|
+
value
|
|
221
|
+
end
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
end
|
|
@@ -20,6 +20,8 @@ module Api
|
|
|
20
20
|
|
|
21
21
|
attr_accessor :status
|
|
22
22
|
|
|
23
|
+
attr_accessor :charge_id
|
|
24
|
+
|
|
23
25
|
class EnumAttributeValidator
|
|
24
26
|
attr_reader :datatype
|
|
25
27
|
attr_reader :allowable_values
|
|
@@ -46,7 +48,8 @@ module Api
|
|
|
46
48
|
def self.attribute_map
|
|
47
49
|
{
|
|
48
50
|
:'request_id' => :'requestId',
|
|
49
|
-
:'status' => :'status'
|
|
51
|
+
:'status' => :'status',
|
|
52
|
+
:'charge_id' => :'chargeId'
|
|
50
53
|
}
|
|
51
54
|
end
|
|
52
55
|
|
|
@@ -59,7 +62,8 @@ module Api
|
|
|
59
62
|
def self.openapi_types
|
|
60
63
|
{
|
|
61
64
|
:'request_id' => :'String',
|
|
62
|
-
:'status' => :'AsyncStatus'
|
|
65
|
+
:'status' => :'AsyncStatus',
|
|
66
|
+
:'charge_id' => :'String'
|
|
63
67
|
}
|
|
64
68
|
end
|
|
65
69
|
|
|
@@ -93,6 +97,10 @@ module Api
|
|
|
93
97
|
else
|
|
94
98
|
self.status = 'ASYNC_STATUS_UNSPECIFIED'
|
|
95
99
|
end
|
|
100
|
+
|
|
101
|
+
if attributes.key?(:'charge_id')
|
|
102
|
+
self.charge_id = attributes[:'charge_id']
|
|
103
|
+
end
|
|
96
104
|
end
|
|
97
105
|
|
|
98
106
|
# Show invalid properties with the reasons. Usually used together with valid?
|
|
@@ -116,7 +124,8 @@ module Api
|
|
|
116
124
|
return true if self.equal?(o)
|
|
117
125
|
self.class == o.class &&
|
|
118
126
|
request_id == o.request_id &&
|
|
119
|
-
status == o.status
|
|
127
|
+
status == o.status &&
|
|
128
|
+
charge_id == o.charge_id
|
|
120
129
|
end
|
|
121
130
|
|
|
122
131
|
# @see the `==` method
|
|
@@ -128,7 +137,7 @@ module Api
|
|
|
128
137
|
# Calculates hash code according to all attributes.
|
|
129
138
|
# @return [Integer] Hash code
|
|
130
139
|
def hash
|
|
131
|
-
[request_id, status].hash
|
|
140
|
+
[request_id, status, charge_id].hash
|
|
132
141
|
end
|
|
133
142
|
|
|
134
143
|
# Builds the object from hash
|
data/lib/jamm/api.rb
CHANGED
|
@@ -33,9 +33,11 @@ require 'jamm/api/models/v1_bank_quota'
|
|
|
33
33
|
require 'jamm/api/models/v1_bank_scheduled_maintenance_period'
|
|
34
34
|
require 'jamm/api/models/v1_buyer'
|
|
35
35
|
require 'jamm/api/models/v1_charge'
|
|
36
|
+
require 'jamm/api/models/v1_charge_error'
|
|
36
37
|
require 'jamm/api/models/v1_charge_message'
|
|
37
38
|
require 'jamm/api/models/v1_charge_message_status'
|
|
38
39
|
require 'jamm/api/models/v1_charge_result'
|
|
40
|
+
require 'jamm/api/models/v1_charge_status'
|
|
39
41
|
require 'jamm/api/models/v1_contract'
|
|
40
42
|
require 'jamm/api/models/v1_contract_message'
|
|
41
43
|
require 'jamm/api/models/v1_contract_status'
|
|
@@ -65,6 +67,8 @@ require 'jamm/api/models/v1_merchant'
|
|
|
65
67
|
require 'jamm/api/models/v1_merchant_customer'
|
|
66
68
|
require 'jamm/api/models/v1_merchant_webhook_message'
|
|
67
69
|
require 'jamm/api/models/v1_message_response'
|
|
70
|
+
require 'jamm/api/models/v1_off_session_payment_async_request'
|
|
71
|
+
require 'jamm/api/models/v1_off_session_payment_async_response'
|
|
68
72
|
require 'jamm/api/models/v1_off_session_payment_request'
|
|
69
73
|
require 'jamm/api/models/v1_off_session_payment_response'
|
|
70
74
|
require 'jamm/api/models/v1_on_session_payment_data'
|
|
@@ -76,6 +80,9 @@ require 'jamm/api/models/v1_pagination'
|
|
|
76
80
|
require 'jamm/api/models/v1_payment_authorization_status'
|
|
77
81
|
require 'jamm/api/models/v1_payment_link'
|
|
78
82
|
require 'jamm/api/models/v1_ping_response'
|
|
83
|
+
require 'jamm/api/models/v1_refund_info'
|
|
84
|
+
require 'jamm/api/models/v1_refund_request'
|
|
85
|
+
require 'jamm/api/models/v1_refund_response'
|
|
79
86
|
require 'jamm/api/models/v1_search_banks_response'
|
|
80
87
|
require 'jamm/api/models/v1_search_branches_response'
|
|
81
88
|
require 'jamm/api/models/v1_url'
|
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,7 +7,15 @@ 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,
|
|
@@ -24,32 +32,44 @@ module Jamm
|
|
|
24
32
|
)
|
|
25
33
|
end
|
|
26
34
|
|
|
27
|
-
Jamm::
|
|
35
|
+
handler = Jamm::Client.handler(merchant: merchant)
|
|
36
|
+
Jamm::OpenAPI::PaymentApi.new(handler).on_session_payment(request)
|
|
28
37
|
rescue Jamm::OpenAPI::ApiError => e
|
|
29
38
|
raise Jamm::ApiError.from_error(e)
|
|
30
39
|
end
|
|
31
40
|
|
|
32
|
-
def self.off_session(customer:, charge:)
|
|
41
|
+
def self.off_session(customer:, charge:, merchant: nil)
|
|
33
42
|
request = Jamm::OpenAPI::OffSessionPaymentRequest.new(
|
|
34
43
|
customer: customer,
|
|
35
44
|
charge: charge
|
|
36
45
|
)
|
|
37
46
|
|
|
38
|
-
Jamm::
|
|
47
|
+
handler = Jamm::Client.handler(merchant: merchant)
|
|
48
|
+
Jamm::OpenAPI::PaymentApi.new(handler).off_session_payment(request)
|
|
39
49
|
rescue Jamm::OpenAPI::ApiError => e
|
|
40
50
|
raise Jamm::ApiError.from_error(e)
|
|
41
51
|
end
|
|
42
52
|
|
|
43
|
-
def self.get(charge_id)
|
|
44
|
-
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)
|
|
45
57
|
rescue Jamm::OpenAPI::ApiError => e
|
|
46
58
|
return nil if e.code == 404
|
|
47
59
|
|
|
48
60
|
raise Jamm::ApiError.from_error(e)
|
|
49
61
|
end
|
|
50
62
|
|
|
51
|
-
def self.
|
|
52
|
-
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)
|
|
53
73
|
rescue Jamm::OpenAPI::ApiError => e
|
|
54
74
|
if [404].include?(e.code)
|
|
55
75
|
nil
|
data/lib/jamm/version.rb
CHANGED
data/lib/jamm/webhook.rb
CHANGED
|
@@ -22,7 +22,11 @@ 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::REFUND_SUCCEEDED
|
|
26
|
+
out.content = Jamm::OpenAPI::ChargeMessage.new(json[:content])
|
|
27
|
+
return out
|
|
28
|
+
|
|
29
|
+
when Jamm::OpenAPI::EventType::REFUND_FAILED
|
|
26
30
|
out.content = Jamm::OpenAPI::ChargeMessage.new(json[:content])
|
|
27
31
|
return out
|
|
28
32
|
|
|
@@ -42,7 +46,8 @@ module Jamm
|
|
|
42
46
|
raise 'Unknown event type'
|
|
43
47
|
end
|
|
44
48
|
|
|
45
|
-
# Verify message
|
|
49
|
+
# Verify message.
|
|
50
|
+
# This method will use client secret to verify the message.
|
|
46
51
|
def self.verify(data:, signature:)
|
|
47
52
|
raise ArgumentError, 'data cannot be nil' if data.nil?
|
|
48
53
|
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,8 +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.
|
|
28
32
|
@environment = nil
|
|
33
|
+
@mode = nil
|
|
29
34
|
@oauth_base = nil
|
|
30
35
|
@openapi = nil
|
|
31
36
|
@open_timeout = 30
|
|
@@ -33,24 +38,28 @@ module Jamm
|
|
|
33
38
|
@max_retry = 0
|
|
34
39
|
|
|
35
40
|
class << self
|
|
36
|
-
attr_accessor :api, :client_id, :client_secret, :api_base, :environment, :oauth_base, :api_version, :connect_base,
|
|
41
|
+
attr_accessor :api, :client_id, :client_secret, :api_base, :environment, :mode, :oauth_base, :api_version, :connect_base,
|
|
37
42
|
:openapi, :open_timeout, :read_timeout, :max_retry, :retry_initial_delay, :retry_max_delay
|
|
38
43
|
end
|
|
39
44
|
|
|
40
|
-
|
|
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)
|
|
41
48
|
Jamm.client_id = client_id
|
|
42
49
|
Jamm.client_secret = client_secret
|
|
43
50
|
|
|
51
|
+
Jamm.mode = platform ? Jamm::Mode::PLATFORM : Jamm::Mode::MERCHANT
|
|
52
|
+
|
|
44
53
|
case env
|
|
45
54
|
when 'prd', 'prod', 'production'
|
|
46
|
-
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'
|
|
47
56
|
|
|
48
57
|
self.environment = 'production'
|
|
49
58
|
self.openapi = Jamm::OpenAPI::ApiClient.new
|
|
50
59
|
openapi.config.host = 'api.jamm-pay.jp'
|
|
51
60
|
|
|
52
61
|
when 'local'
|
|
53
|
-
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'
|
|
54
63
|
|
|
55
64
|
self.environment = 'local'
|
|
56
65
|
self.openapi = Jamm::OpenAPI::ApiClient.new
|
|
@@ -58,7 +67,7 @@ module Jamm
|
|
|
58
67
|
openapi.config.verify_ssl = false
|
|
59
68
|
openapi.config.verify_ssl_host = false
|
|
60
69
|
else
|
|
61
|
-
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"
|
|
62
71
|
|
|
63
72
|
self.environment = env
|
|
64
73
|
self.openapi = Jamm::OpenAPI::ApiClient.new
|
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: 1.
|
|
4
|
+
version: 2.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jamm
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-04-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rest-client
|
|
@@ -83,9 +83,11 @@ files:
|
|
|
83
83
|
- lib/jamm/api/models/v1_bank_scheduled_maintenance_period.rb
|
|
84
84
|
- lib/jamm/api/models/v1_buyer.rb
|
|
85
85
|
- lib/jamm/api/models/v1_charge.rb
|
|
86
|
+
- lib/jamm/api/models/v1_charge_error.rb
|
|
86
87
|
- lib/jamm/api/models/v1_charge_message.rb
|
|
87
88
|
- lib/jamm/api/models/v1_charge_message_status.rb
|
|
88
89
|
- lib/jamm/api/models/v1_charge_result.rb
|
|
90
|
+
- lib/jamm/api/models/v1_charge_status.rb
|
|
89
91
|
- lib/jamm/api/models/v1_contract.rb
|
|
90
92
|
- lib/jamm/api/models/v1_contract_message.rb
|
|
91
93
|
- lib/jamm/api/models/v1_contract_status.rb
|
|
@@ -115,6 +117,8 @@ files:
|
|
|
115
117
|
- lib/jamm/api/models/v1_merchant_customer.rb
|
|
116
118
|
- lib/jamm/api/models/v1_merchant_webhook_message.rb
|
|
117
119
|
- lib/jamm/api/models/v1_message_response.rb
|
|
120
|
+
- lib/jamm/api/models/v1_off_session_payment_async_request.rb
|
|
121
|
+
- lib/jamm/api/models/v1_off_session_payment_async_response.rb
|
|
118
122
|
- lib/jamm/api/models/v1_off_session_payment_request.rb
|
|
119
123
|
- lib/jamm/api/models/v1_off_session_payment_response.rb
|
|
120
124
|
- lib/jamm/api/models/v1_on_session_payment_data.rb
|
|
@@ -126,6 +130,9 @@ files:
|
|
|
126
130
|
- lib/jamm/api/models/v1_payment_authorization_status.rb
|
|
127
131
|
- lib/jamm/api/models/v1_payment_link.rb
|
|
128
132
|
- lib/jamm/api/models/v1_ping_response.rb
|
|
133
|
+
- lib/jamm/api/models/v1_refund_info.rb
|
|
134
|
+
- lib/jamm/api/models/v1_refund_request.rb
|
|
135
|
+
- lib/jamm/api/models/v1_refund_response.rb
|
|
129
136
|
- lib/jamm/api/models/v1_search_banks_response.rb
|
|
130
137
|
- lib/jamm/api/models/v1_search_branches_response.rb
|
|
131
138
|
- lib/jamm/api/models/v1_update_customer_response.rb
|
|
@@ -139,9 +146,7 @@ files:
|
|
|
139
146
|
- lib/jamm/api/models/v1_withdraw_response.rb
|
|
140
147
|
- lib/jamm/api/version.rb
|
|
141
148
|
- lib/jamm/api_patches.rb
|
|
142
|
-
- lib/jamm/charge.rb
|
|
143
149
|
- lib/jamm/client.rb
|
|
144
|
-
- lib/jamm/contract.rb
|
|
145
150
|
- lib/jamm/customer.rb
|
|
146
151
|
- lib/jamm/deprecation.rb
|
|
147
152
|
- lib/jamm/errors.rb
|