jamm 1.7.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 +1 -1
- data/lib/jamm/api/api/payment_api.rb +136 -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_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_refund_request.rb +226 -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 +5 -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 +3 -2
- data/lib/jamm.rb +16 -7
- metadata +7 -4
- data/lib/jamm/charge.rb +0 -65
- data/lib/jamm/contract.rb +0 -39
|
@@ -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
|
@@ -36,6 +36,7 @@ require 'jamm/api/models/v1_charge'
|
|
|
36
36
|
require 'jamm/api/models/v1_charge_message'
|
|
37
37
|
require 'jamm/api/models/v1_charge_message_status'
|
|
38
38
|
require 'jamm/api/models/v1_charge_result'
|
|
39
|
+
require 'jamm/api/models/v1_charge_status'
|
|
39
40
|
require 'jamm/api/models/v1_contract'
|
|
40
41
|
require 'jamm/api/models/v1_contract_message'
|
|
41
42
|
require 'jamm/api/models/v1_contract_status'
|
|
@@ -65,6 +66,8 @@ 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,6 +79,8 @@ 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'
|
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,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,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:
|
|
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: 2026-
|
|
11
|
+
date: 2026-03-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rest-client
|
|
@@ -86,6 +86,7 @@ files:
|
|
|
86
86
|
- lib/jamm/api/models/v1_charge_message.rb
|
|
87
87
|
- lib/jamm/api/models/v1_charge_message_status.rb
|
|
88
88
|
- lib/jamm/api/models/v1_charge_result.rb
|
|
89
|
+
- lib/jamm/api/models/v1_charge_status.rb
|
|
89
90
|
- lib/jamm/api/models/v1_contract.rb
|
|
90
91
|
- lib/jamm/api/models/v1_contract_message.rb
|
|
91
92
|
- lib/jamm/api/models/v1_contract_status.rb
|
|
@@ -115,6 +116,8 @@ files:
|
|
|
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,6 +129,8 @@ 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
|
|
@@ -139,9 +144,7 @@ files:
|
|
|
139
144
|
- lib/jamm/api/models/v1_withdraw_response.rb
|
|
140
145
|
- lib/jamm/api/version.rb
|
|
141
146
|
- lib/jamm/api_patches.rb
|
|
142
|
-
- lib/jamm/charge.rb
|
|
143
147
|
- lib/jamm/client.rb
|
|
144
|
-
- lib/jamm/contract.rb
|
|
145
148
|
- lib/jamm/customer.rb
|
|
146
149
|
- lib/jamm/deprecation.rb
|
|
147
150
|
- lib/jamm/errors.rb
|
data/lib/jamm/charge.rb
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'rest-client'
|
|
4
|
-
require 'json'
|
|
5
|
-
require 'base64'
|
|
6
|
-
require 'jamm/errors'
|
|
7
|
-
|
|
8
|
-
module Jamm
|
|
9
|
-
module Charge
|
|
10
|
-
# DEPRECATED, use Jamm::Payment.on_session
|
|
11
|
-
def self.create_with_redirect(customer:, charge:, redirect: nil)
|
|
12
|
-
Jamm::Deprecation.warn('Jamm::Charge.create_with_redirect')
|
|
13
|
-
|
|
14
|
-
request = Jamm::OpenAPI::AddChargeRequest.new(
|
|
15
|
-
customer: customer,
|
|
16
|
-
charge: charge,
|
|
17
|
-
redirect: redirect
|
|
18
|
-
)
|
|
19
|
-
|
|
20
|
-
Jamm::OpenAPI::PaymentApi.new(Jamm::Client.handler).add_charge(request)
|
|
21
|
-
rescue Jamm::OpenAPI::ApiError => e
|
|
22
|
-
raise Jamm::ApiError.from_error(e)
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
# DEPRECATED, use Jamm::Payment.off_session
|
|
26
|
-
def self.create_without_redirect(customer:, charge:)
|
|
27
|
-
Jamm::Deprecation.warn('Jamm::Charge.create_without_redirect')
|
|
28
|
-
|
|
29
|
-
request = Jamm::OpenAPI::WithdrawRequest.new(
|
|
30
|
-
customer: customer,
|
|
31
|
-
charge: charge
|
|
32
|
-
)
|
|
33
|
-
|
|
34
|
-
Jamm::OpenAPI::PaymentApi.new(Jamm::Client.handler).withdraw(request)
|
|
35
|
-
rescue Jamm::OpenAPI::ApiError => e
|
|
36
|
-
raise Jamm::ApiError.from_error(e)
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
# DEPRECATED, use Jamm::Payment.get
|
|
40
|
-
def self.get(charge_id)
|
|
41
|
-
Jamm::Deprecation.warn('Jamm::Charge.get')
|
|
42
|
-
|
|
43
|
-
Jamm::OpenAPI::PaymentApi.new(Jamm::Client.handler).get_charge(charge_id)
|
|
44
|
-
rescue Jamm::OpenAPI::ApiError => e
|
|
45
|
-
return nil if e.code == 404
|
|
46
|
-
|
|
47
|
-
raise Jamm::ApiError.from_error(e)
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
# DEPRECATED, use Jamm::Payment.list
|
|
51
|
-
def self.list(customer:, pagination: nil)
|
|
52
|
-
Jamm::Deprecation.warn('Jamm::Charge.list')
|
|
53
|
-
|
|
54
|
-
Jamm::OpenAPI::PaymentApi.new(Jamm::Client.handler).get_charges(customer, pagination.nil? ? {} : pagination)
|
|
55
|
-
rescue Jamm::OpenAPI::ApiError => e
|
|
56
|
-
if [404].include?(e.code)
|
|
57
|
-
nil
|
|
58
|
-
else
|
|
59
|
-
{
|
|
60
|
-
charges: []
|
|
61
|
-
}
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
end
|
data/lib/jamm/contract.rb
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'rest-client'
|
|
4
|
-
require 'json'
|
|
5
|
-
require 'base64'
|
|
6
|
-
require 'jamm/errors'
|
|
7
|
-
|
|
8
|
-
module Jamm
|
|
9
|
-
module Contract
|
|
10
|
-
def self.create_with_charge(buyer:, charge:, redirect: nil)
|
|
11
|
-
request = Jamm::OpenAPI::CreateContractWithChargeRequest.new(
|
|
12
|
-
buyer: buyer,
|
|
13
|
-
charge: charge,
|
|
14
|
-
redirect: redirect
|
|
15
|
-
)
|
|
16
|
-
|
|
17
|
-
Jamm::OpenAPI::PaymentApi.new(Jamm::Client.handler).create_contract_with_charge(request)
|
|
18
|
-
rescue Jamm::OpenAPI::ApiError => e
|
|
19
|
-
raise Jamm::ApiError.from_error(e)
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def self.create_without_charge(buyer:, redirect: nil)
|
|
23
|
-
request = Jamm::OpenAPI::CreateContractWithoutChargeRequest.new(
|
|
24
|
-
buyer: buyer,
|
|
25
|
-
redirect: redirect
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
Jamm::OpenAPI::PaymentApi.new(Jamm::Client.handler).create_contract_without_charge(request)
|
|
29
|
-
rescue Jamm::OpenAPI::ApiError => e
|
|
30
|
-
raise Jamm::ApiError.from_error(e)
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def self.get(customer_id)
|
|
34
|
-
Jamm::OpenAPI::CustomerApi.new(Jamm::Client.handler).get_contract(customer_id)
|
|
35
|
-
rescue Jamm::OpenAPI::ApiError => e
|
|
36
|
-
[404].include?(e.code) ? nil : Jamm::ApiError.from_error(e)
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
end
|