jamm 2.1.0 → 2.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b9d9cfa81304a829a1d016ff3a4d2e53fe2b15caf2fa6c4e8513161b16881dff
4
- data.tar.gz: 9f1ffda9436127fa5101cbff162f8ac24f52a8b151ade3c7691a39e9144e52aa
3
+ metadata.gz: 0dc69a9799a5215efa21041879db8ee9d8b67678dc6ac20dc92046c165eec6fd
4
+ data.tar.gz: 33bd5a72e96fdc0212e956762e5bb7983604a5d1a1e9792d577267a61a2d96bd
5
5
  SHA512:
6
- metadata.gz: 8af376c181770bbc2fb93c1002ca29493fde1c6cdf4227475a1ce891fd82d83c073774c7296c67e911ae064d55fa8314fb8550d390dbe9b991d56167ca30e95a
7
- data.tar.gz: 6c8c4ca5abb8f6b4bcc0d94ab15441bfa1ca572e000a4358072bccf340e8493776c7791b6fcb4d798e0dd647ceac2db9c1937720aebcde971d132825f576328b
6
+ metadata.gz: 82fd64ead34ca1e458d831d21874ccb6bd53774e27170944a2c8d4d1532dcad9db4e589ffe55ce4a24b60bbd658f8816aebcc674afc6f5d096ba931ec1ae2806
7
+ data.tar.gz: f8d88d108bcd9822c56a05133248bf759b100f31ef3af3bc5b7f5ed14ea4c7ba5d111ca96a482fec038e5de09ac10d769d7d559ab57ac53dcb64dbbc9ce21785
data/CHANGELOG.md ADDED
@@ -0,0 +1,66 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [2.2.0] - 2026-05-20
9
+
10
+ ### Added
11
+
12
+ - Added `Jamm::Payment.off_session_async` for async off-session charges
13
+ - Auto-fill `idempotency_key` with a UUID when `nil` or blank
14
+
15
+ ## [2.1.0] - 2026-04-06
16
+
17
+ ### Added
18
+
19
+ - Added `ChargeError` details on `ChargeResult` for failed charges
20
+
21
+ ## [2.0.0] - 2026-03-16
22
+
23
+ ### Added
24
+
25
+ - Platform authentication support
26
+ - Refund support and split refund webhook events (succeeded / rejected)
27
+
28
+ ### Changed
29
+
30
+ - Renamed `cancel` operations to `refund` across API and webhooks
31
+
32
+ ## [1.7.0] - 2025-11-11
33
+
34
+ ### Removed
35
+
36
+ - Deprecated legacy contract charge public APIs
37
+
38
+ ## [1.6.0] - 2025-11-11
39
+
40
+ ### Changed
41
+
42
+ - Version bump aligned with other SDKs
43
+
44
+ ## [1.5.0] - 2025-10-09
45
+
46
+ ### Changed
47
+
48
+ - `OnSessionPayment` redirect link is now optional
49
+
50
+ ## [1.4.1] - 2025-08-22
51
+
52
+ ### Changed
53
+
54
+ - Updated RubyGem GitHub source URL
55
+
56
+ ## [1.4.0] - 2025-08-22
57
+
58
+ ### Added
59
+
60
+ - On-session and off-session payment support
61
+
62
+ ## [1.3.0] - 2025-07-08
63
+
64
+ ### Added
65
+
66
+ - Embedded `error.v1` typed errors into OpenAPI proto
data/Gemfile CHANGED
@@ -4,6 +4,7 @@ source 'https://rubygems.org'
4
4
 
5
5
  gemspec
6
6
 
7
+ gem 'base64', '~> 0.2'
7
8
  gem 'rest-client', '~> 2.0'
8
9
  gem 'typhoeus', '~> 1.0', '>= 1.0.1'
9
10
 
data/Gemfile.lock CHANGED
@@ -1,16 +1,18 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- jamm (2.1.0)
4
+ jamm (2.2.0)
5
+ base64 (~> 0.2)
5
6
  rest-client (~> 2.0)
6
7
  typhoeus (~> 1.0, >= 1.0.1)
7
8
 
8
9
  GEM
9
10
  remote: https://rubygems.org/
10
11
  specs:
11
- addressable (2.8.6)
12
- public_suffix (>= 2.0.2, < 6.0)
12
+ addressable (2.9.0)
13
+ public_suffix (>= 2.0.2, < 8.0)
13
14
  ast (2.4.2)
15
+ base64 (0.3.0)
14
16
  bigdecimal (3.1.7)
15
17
  coderay (1.1.3)
16
18
  concurrent-ruby (1.3.4)
@@ -47,7 +49,7 @@ GEM
47
49
  pry (0.14.2)
48
50
  coderay (~> 1.1)
49
51
  method_source (~> 1.0)
50
- public_suffix (5.0.5)
52
+ public_suffix (5.1.1)
51
53
  racc (1.7.3)
52
54
  rainbow (3.1.1)
53
55
  rake (13.2.1)
@@ -90,6 +92,7 @@ PLATFORMS
90
92
  x86_64-linux
91
93
 
92
94
  DEPENDENCIES
95
+ base64 (~> 0.2)
93
96
  faker
94
97
  gimei
95
98
  jamm!
data/jamm.gemspec CHANGED
@@ -15,6 +15,7 @@ Gem::Specification.new do |s|
15
15
  s.homepage = 'https://jamm-pay.jp'
16
16
  s.license = 'MIT'
17
17
 
18
+ s.add_dependency('base64', '~> 0.2')
18
19
  s.add_dependency('rest-client', '~> 2.0')
19
20
  s.add_dependency('typhoeus', '~> 1.0', '>= 1.0.1')
20
21
 
@@ -89,7 +89,7 @@ module Api
89
89
 
90
90
  # Initiate async off-session payment
91
91
  # Starts asynchronous off-session payment processing and returns request tracking information.
92
- # @param body [OffSessionPaymentAsyncRequest] This message represents a request to process an off-session payment asynchronously. It contains the customer ID and the amount to charge.
92
+ # @param body [OffSessionPaymentAsyncRequest] This message represents a request to process an off-session payment asynchronously. It contains the customer ID and the amount to charge. Supports triggerError in charge.metadata for test error simulation. See InitialCharge.metadata.
93
93
  # @param [Hash] opts the optional parameters
94
94
  # @return [OffSessionPaymentAsyncResponse]
95
95
  def async_off_session_payment(body, opts = {})
@@ -99,7 +99,7 @@ module Api
99
99
 
100
100
  # Initiate async off-session payment
101
101
  # Starts asynchronous off-session payment processing and returns request tracking information.
102
- # @param body [OffSessionPaymentAsyncRequest] This message represents a request to process an off-session payment asynchronously. It contains the customer ID and the amount to charge.
102
+ # @param body [OffSessionPaymentAsyncRequest] This message represents a request to process an off-session payment asynchronously. It contains the customer ID and the amount to charge. Supports triggerError in charge.metadata for test error simulation. See InitialCharge.metadata.
103
103
  # @param [Hash] opts the optional parameters
104
104
  # @return [Array<(OffSessionPaymentAsyncResponse, Integer, Hash)>] OffSessionPaymentAsyncResponse data, response status code and response headers
105
105
  def async_off_session_payment_with_http_info(body, opts = {})
@@ -425,7 +425,7 @@ module Api
425
425
 
426
426
  # Initiate async withdraw (internal)
427
427
  # Internal-only endpoint for initiating asynchronous withdrawal processing.
428
- # @param body [WithdrawAsyncRequest] This message represents a request to withdraw money from a customer asynchronously. It contains the customer ID and the amount to withdraw.
428
+ # @param body [WithdrawAsyncRequest] This message represents a request to withdraw money from a customer asynchronously. It contains the customer ID and the amount to withdraw. Supports triggerError in charge.metadata for test error simulation. See InitialCharge.metadata.
429
429
  # @param [Hash] opts the optional parameters
430
430
  # @return [WithdrawAsyncResponse]
431
431
  def internal_withdraw_async(body, opts = {})
@@ -435,7 +435,7 @@ module Api
435
435
 
436
436
  # Initiate async withdraw (internal)
437
437
  # Internal-only endpoint for initiating asynchronous withdrawal processing.
438
- # @param body [WithdrawAsyncRequest] This message represents a request to withdraw money from a customer asynchronously. It contains the customer ID and the amount to withdraw.
438
+ # @param body [WithdrawAsyncRequest] This message represents a request to withdraw money from a customer asynchronously. It contains the customer ID and the amount to withdraw. Supports triggerError in charge.metadata for test error simulation. See InitialCharge.metadata.
439
439
  # @param [Hash] opts the optional parameters
440
440
  # @return [Array<(WithdrawAsyncResponse, Integer, Hash)>] WithdrawAsyncResponse data, response status code and response headers
441
441
  def internal_withdraw_async_with_http_info(body, opts = {})
@@ -561,7 +561,7 @@ module Api
561
561
 
562
562
  # Process payment directly without redirect
563
563
  # Execute a payment off-session within your application without redirecting to a payment page.
564
- # @param body [OffSessionPaymentRequest] This message represents a request to process a payment directly within the application. It contains the customer ID and charge details to be processed.
564
+ # @param body [OffSessionPaymentRequest] This message represents a request to process a payment directly within the application. It contains the customer ID and charge details to be processed. Supports triggerError in charge.metadata for test error simulation. See InitialCharge.metadata.
565
565
  # @param [Hash] opts the optional parameters
566
566
  # @return [OffSessionPaymentResponse]
567
567
  def off_session_payment(body, opts = {})
@@ -571,7 +571,7 @@ module Api
571
571
 
572
572
  # Process payment directly without redirect
573
573
  # Execute a payment off-session within your application without redirecting to a payment page.
574
- # @param body [OffSessionPaymentRequest] This message represents a request to process a payment directly within the application. It contains the customer ID and charge details to be processed.
574
+ # @param body [OffSessionPaymentRequest] This message represents a request to process a payment directly within the application. It contains the customer ID and charge details to be processed. Supports triggerError in charge.metadata for test error simulation. See InitialCharge.metadata.
575
575
  # @param [Hash] opts the optional parameters
576
576
  # @return [Array<(OffSessionPaymentResponse, Integer, Hash)>] OffSessionPaymentResponse data, response status code and response headers
577
577
  def off_session_payment_with_http_info(body, opts = {})
@@ -629,7 +629,7 @@ module Api
629
629
 
630
630
  # Process payment with optional redirect
631
631
  # Unified interface for creating payments - supports existing customers, new customers with charges, and contract-only creation.
632
- # @param body [OnSessionPaymentRequest] Request message for the unified payment interface. The system intelligently routes the request to the appropriate payment method based on the provided parameters.
632
+ # @param body [OnSessionPaymentRequest] Request message for the unified payment interface. The system intelligently routes the request to the appropriate payment method based on the provided parameters. Supports triggerError for test error simulation via the core InitiatePayment/ApprovePayment flow. See InitialCharge.metadata for details on behavior differences by stage.
633
633
  # @param [Hash] opts the optional parameters
634
634
  # @return [OnSessionPaymentResponse]
635
635
  def on_session_payment(body, opts = {})
@@ -639,7 +639,7 @@ module Api
639
639
 
640
640
  # Process payment with optional redirect
641
641
  # Unified interface for creating payments - supports existing customers, new customers with charges, and contract-only creation.
642
- # @param body [OnSessionPaymentRequest] Request message for the unified payment interface. The system intelligently routes the request to the appropriate payment method based on the provided parameters.
642
+ # @param body [OnSessionPaymentRequest] Request message for the unified payment interface. The system intelligently routes the request to the appropriate payment method based on the provided parameters. Supports triggerError for test error simulation via the core InitiatePayment/ApprovePayment flow. See InitialCharge.metadata for details on behavior differences by stage.
643
643
  # @param [Hash] opts the optional parameters
644
644
  # @return [Array<(OnSessionPaymentResponse, Integer, Hash)>] OnSessionPaymentResponse data, response status code and response headers
645
645
  def on_session_payment_with_http_info(body, opts = {})
@@ -765,7 +765,7 @@ module Api
765
765
 
766
766
  # Withdraw money from customer immediately, without redirect
767
767
  # This call is synchronous. The money will be withdrawn immediately.
768
- # @param body [WithdrawRequest] This message represents a request to withdraw money from a customer. It contains the customer ID and the amount to withdraw.
768
+ # @param body [WithdrawRequest] This message represents a request to withdraw money from a customer. It contains the customer ID and the amount to withdraw. Supports triggerError in charge.metadata for test error simulation. See InitialCharge.metadata.
769
769
  # @param [Hash] opts the optional parameters
770
770
  # @return [WithdrawResponse]
771
771
  def withdraw(body, opts = {})
@@ -775,7 +775,7 @@ module Api
775
775
 
776
776
  # Withdraw money from customer immediately, without redirect
777
777
  # This call is synchronous. The money will be withdrawn immediately.
778
- # @param body [WithdrawRequest] This message represents a request to withdraw money from a customer. It contains the customer ID and the amount to withdraw.
778
+ # @param body [WithdrawRequest] This message represents a request to withdraw money from a customer. It contains the customer ID and the amount to withdraw. Supports triggerError in charge.metadata for test error simulation. See InitialCharge.metadata.
779
779
  # @param [Hash] opts the optional parameters
780
780
  # @return [Array<(WithdrawResponse, Integer, Hash)>] WithdrawResponse data, response status code and response headers
781
781
  def withdraw_with_http_info(body, opts = {})
@@ -35,6 +35,8 @@ module Api
35
35
  PAYMENT_CHARGE_SUBSCRIPTION_EXPIRED = "ERROR_TYPE_PAYMENT_CHARGE_SUBSCRIPTION_EXPIRED".freeze
36
36
  PAYMENT_LINK_EXPIRED = "ERROR_TYPE_PAYMENT_LINK_EXPIRED".freeze
37
37
  PAYMENT_CHARGE_INSUFFICIENT_FUNDS = "ERROR_TYPE_PAYMENT_CHARGE_INSUFFICIENT_FUNDS".freeze
38
+ PAYMENT_CUSTOMER_NOT_FOUND = "ERROR_TYPE_PAYMENT_CUSTOMER_NOT_FOUND".freeze
39
+ PAYMENT_CUSTOMER_INACTIVE = "ERROR_TYPE_PAYMENT_CUSTOMER_INACTIVE".freeze
38
40
  CSV_VALIDATION_FAILED = "ERROR_TYPE_CSV_VALIDATION_FAILED".freeze
39
41
  CSV_TOTP_REQUIRED = "ERROR_TYPE_CSV_TOTP_REQUIRED".freeze
40
42
  CSV_TOTP_INVALID = "ERROR_TYPE_CSV_TOTP_INVALID".freeze
@@ -52,7 +54,7 @@ module Api
52
54
  TOTP_DISABLE_FAILED = "ERROR_TYPE_TOTP_DISABLE_FAILED".freeze
53
55
 
54
56
  def self.all_vars
55
- @all_vars ||= [UNSPECIFIED, AUTH_FAILED, AUTH_REJECTED, ACCOUNT_CREATION_FAILED, ACCOUNT_MODIFICATION_FAILED, ACCOUNT_DELETION_FAILED, ACCOUNT_BANK_REGISTRATION_FAILED, KYC_REJECTED, NOTIFICATION_WEBHOOK_FAILED, NOTIFICATION_EMAIL_FAILED, NOTIFICATION_SMS_FAILED, PAYMENT_GATEWAY_UNAVAILABLE, PAYMENT_GATEWAY_FAILED, PAYMENT_VALIDATION_FAILED, PAYMENT_CHARGE_FAILED, PAYMENT_CHARGE_REJECTED, PAYMENT_CHARGE_OVER_LIMIT, PAYMENT_CHARGE_SUBSCRIPTION_EXPIRED, PAYMENT_LINK_EXPIRED, PAYMENT_CHARGE_INSUFFICIENT_FUNDS, CSV_VALIDATION_FAILED, CSV_TOTP_REQUIRED, CSV_TOTP_INVALID, CSV_TOTP_EXPIRED, CSV_TOTP_LOCKED, CSV_BATCH_TOO_LARGE, CSV_CUSTOMER_NOT_FOUND, CSV_PROCESSING_FAILED, CSV_CHALLENGE_NOT_FOUND, CSV_DUPLICATE_USER, TOTP_SETUP_FAILED, TOTP_ALREADY_ENABLED, TOTP_NOT_ENABLED, TOTP_SETUP_INVALID, TOTP_DISABLE_FAILED].freeze
57
+ @all_vars ||= [UNSPECIFIED, AUTH_FAILED, AUTH_REJECTED, ACCOUNT_CREATION_FAILED, ACCOUNT_MODIFICATION_FAILED, ACCOUNT_DELETION_FAILED, ACCOUNT_BANK_REGISTRATION_FAILED, KYC_REJECTED, NOTIFICATION_WEBHOOK_FAILED, NOTIFICATION_EMAIL_FAILED, NOTIFICATION_SMS_FAILED, PAYMENT_GATEWAY_UNAVAILABLE, PAYMENT_GATEWAY_FAILED, PAYMENT_VALIDATION_FAILED, PAYMENT_CHARGE_FAILED, PAYMENT_CHARGE_REJECTED, PAYMENT_CHARGE_OVER_LIMIT, PAYMENT_CHARGE_SUBSCRIPTION_EXPIRED, PAYMENT_LINK_EXPIRED, PAYMENT_CHARGE_INSUFFICIENT_FUNDS, PAYMENT_CUSTOMER_NOT_FOUND, PAYMENT_CUSTOMER_INACTIVE, CSV_VALIDATION_FAILED, CSV_TOTP_REQUIRED, CSV_TOTP_INVALID, CSV_TOTP_EXPIRED, CSV_TOTP_LOCKED, CSV_BATCH_TOO_LARGE, CSV_CUSTOMER_NOT_FOUND, CSV_PROCESSING_FAILED, CSV_CHALLENGE_NOT_FOUND, CSV_DUPLICATE_USER, TOTP_SETUP_FAILED, TOTP_ALREADY_ENABLED, TOTP_NOT_ENABLED, TOTP_SETUP_INVALID, TOTP_DISABLE_FAILED].freeze
56
58
  end
57
59
 
58
60
  # Builds the enum from string
@@ -22,7 +22,7 @@ module Api
22
22
  # Description is an arbitrary string for merchant to track the charge. This information is displayed on Merchant Dashboard. 決済の説明。ショップが決済を追跡するための任意の文字列です。 @gotags: validate:\"required,max=1024\"
23
23
  attr_accessor :description
24
24
 
25
- # Arbitrary key-value additional information about the charge. You can see this information in our merchant dashboard. Chargeに関する任意のキーと値の追加情報。 加盟店ダッシュボードで確認できます。
25
+ # Arbitrary key-value additional information about the charge. You can see this information in our merchant dashboard. ## Testing with triggerError Set the key \"triggerError\" to a valid ERROR_TYPE_* enum name (e.g. \"ERROR_TYPE_PAYMENT_CHARGE_FAILED\") to simulate a payment failure. Behavior differs by flow: Off-session (Withdraw, WithdrawAsync, OffSessionPayment, OffSessionPaymentAsync): Reads triggerError from this field (charge.metadata). Creates a failed transaction record and sends a failure webhook. Returns transport-level 400 for ERROR_TYPE_PAYMENT_VALIDATION_FAILED, 500 for all other ERROR_TYPE_* values. On-session (InitiatePayment / ApprovePayment — consumer-facing core service): Reads triggerError from the payment's stored metadata (charge or merchant-customer). Initiate stage: only ERROR_TYPE_PAYMENT_VALIDATION_FAILED and ERROR_TYPE_PAYMENT_LINK_EXPIRED are honored; other types are ignored. No failed transaction or webhook is created. Returns 200 OK with an embedded InitiatePaymentError payload. Approve stage: all ERROR_TYPE_* values are honored. Creates workflow-specific failure records (cancelled contract and/or failed transaction depending on the workflow type). Returns 200 OK with an embedded ApprovePaymentError payload. Note: CreateContractWithoutCharge has no charge, so this field does not apply. On-session triggerError for that flow is read from merchant-customer metadata instead. ## Error types by payment stage Initiate (payment session setup, workflow creation): - ERROR_TYPE_PAYMENT_VALIDATION_FAILED — invalid request - ERROR_TYPE_PAYMENT_LINK_EXPIRED — payment link expired Approve (pre-charge validation + BankPay charge execution): - ERROR_TYPE_PAYMENT_VALIDATION_FAILED — invalid request (e.g. deleted/inactive customer) - ERROR_TYPE_PAYMENT_CHARGE_REJECTED — KYC not approved - ERROR_TYPE_PAYMENT_CHARGE_OVER_LIMIT — charge exceeds bank quota - ERROR_TYPE_PAYMENT_LINK_EXPIRED — payment link expired - ERROR_TYPE_PAYMENT_GATEWAY_UNAVAILABLE — BankPay/bank under maintenance - ERROR_TYPE_PAYMENT_CHARGE_INSUFFICIENT_FUNDS — insufficient funds in customer's account - ERROR_TYPE_PAYMENT_GATEWAY_FAILED — BankPay rejected the charge - ERROR_TYPE_PAYMENT_CHARGE_FAILED — generic charge failure (internal, not found, etc.) Chargeに関する任意のキーと値の追加情報。 加盟店ダッシュボードで確認できます。 テスト環境では、\"triggerError\" キーに ERROR_TYPE_* の列挙名を設定すると 決済エラーをシミュレートできます。動作はフローによって異なります。 詳細は上記の英語コメントを参照してください。
26
26
  attr_accessor :metadata
27
27
 
28
28
  # Fee charged by the platform (in JPY). Must be >= the Jamm fee for the merchant. Only meaningful when the caller is a platform. Ignored for direct merchant calls. プラットフォームが徴収する手数料(日本円)。加盟店のJamm手数料以上である必要があります。
@@ -14,17 +14,21 @@ require 'date'
14
14
  require 'time'
15
15
 
16
16
  module Api
17
- # This message represents a request to process an off-session payment asynchronously. It contains the customer ID and the amount to charge.
17
+ # This message represents a request to process an off-session payment asynchronously. It contains the customer ID and the amount to charge. Supports triggerError in charge.metadata for test error simulation. See InitialCharge.metadata.
18
18
  class OffSessionPaymentAsyncRequest
19
19
  attr_accessor :customer
20
20
 
21
21
  attr_accessor :charge
22
22
 
23
+ # Merchant-supplied idempotency key for retry safety. When present, a retry with the same (merchant, idempotency_key) returns the original charge instead of creating a new one. When absent (empty), the server generates a UUID per call (current behavior). ASCII only, 1-255 chars matching ^[a-zA-Z0-9_\\-]{1,255}$.
24
+ attr_accessor :idempotency_key
25
+
23
26
  # Attribute mapping from ruby-style variable name to JSON key.
24
27
  def self.attribute_map
25
28
  {
26
29
  :'customer' => :'customer',
27
- :'charge' => :'charge'
30
+ :'charge' => :'charge',
31
+ :'idempotency_key' => :'idempotencyKey'
28
32
  }
29
33
  end
30
34
 
@@ -37,7 +41,8 @@ module Api
37
41
  def self.openapi_types
38
42
  {
39
43
  :'customer' => :'String',
40
- :'charge' => :'InitialCharge'
44
+ :'charge' => :'InitialCharge',
45
+ :'idempotency_key' => :'String'
41
46
  }
42
47
  end
43
48
 
@@ -69,6 +74,10 @@ module Api
69
74
  if attributes.key?(:'charge')
70
75
  self.charge = attributes[:'charge']
71
76
  end
77
+
78
+ if attributes.key?(:'idempotency_key')
79
+ self.idempotency_key = attributes[:'idempotency_key']
80
+ end
72
81
  end
73
82
 
74
83
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -92,7 +101,8 @@ module Api
92
101
  return true if self.equal?(o)
93
102
  self.class == o.class &&
94
103
  customer == o.customer &&
95
- charge == o.charge
104
+ charge == o.charge &&
105
+ idempotency_key == o.idempotency_key
96
106
  end
97
107
 
98
108
  # @see the `==` method
@@ -104,7 +114,7 @@ module Api
104
114
  # Calculates hash code according to all attributes.
105
115
  # @return [Integer] Hash code
106
116
  def hash
107
- [customer, charge].hash
117
+ [customer, charge, idempotency_key].hash
108
118
  end
109
119
 
110
120
  # Builds the object from hash
@@ -14,7 +14,7 @@ require 'date'
14
14
  require 'time'
15
15
 
16
16
  module Api
17
- # This message represents a request to process a payment directly within the application. It contains the customer ID and charge details to be processed.
17
+ # This message represents a request to process a payment directly within the application. It contains the customer ID and charge details to be processed. Supports triggerError in charge.metadata for test error simulation. See InitialCharge.metadata.
18
18
  class OffSessionPaymentRequest
19
19
  attr_accessor :customer
20
20
 
@@ -14,7 +14,7 @@ require 'date'
14
14
  require 'time'
15
15
 
16
16
  module Api
17
- # Request message for the unified payment interface. The system intelligently routes the request to the appropriate payment method based on the provided parameters.
17
+ # Request message for the unified payment interface. The system intelligently routes the request to the appropriate payment method based on the provided parameters. Supports triggerError for test error simulation via the core InitiatePayment/ApprovePayment flow. See InitialCharge.metadata for details on behavior differences by stage.
18
18
  class OnSessionPaymentRequest
19
19
  attr_accessor :customer
20
20
 
@@ -14,17 +14,21 @@ require 'date'
14
14
  require 'time'
15
15
 
16
16
  module Api
17
- # This message represents a request to withdraw money from a customer asynchronously. It contains the customer ID and the amount to withdraw.
17
+ # This message represents a request to withdraw money from a customer asynchronously. It contains the customer ID and the amount to withdraw. Supports triggerError in charge.metadata for test error simulation. See InitialCharge.metadata.
18
18
  class WithdrawAsyncRequest
19
19
  attr_accessor :customer
20
20
 
21
21
  attr_accessor :charge
22
22
 
23
+ # Merchant-supplied idempotency key for retry safety. When present, a retry with the same (merchant, idempotency_key) returns the original charge instead of creating a new one. When absent (empty), the server generates a UUID per call (current behavior). ASCII only, 1-255 chars matching ^[a-zA-Z0-9_\\-]{1,255}$.
24
+ attr_accessor :idempotency_key
25
+
23
26
  # Attribute mapping from ruby-style variable name to JSON key.
24
27
  def self.attribute_map
25
28
  {
26
29
  :'customer' => :'customer',
27
- :'charge' => :'charge'
30
+ :'charge' => :'charge',
31
+ :'idempotency_key' => :'idempotencyKey'
28
32
  }
29
33
  end
30
34
 
@@ -37,7 +41,8 @@ module Api
37
41
  def self.openapi_types
38
42
  {
39
43
  :'customer' => :'String',
40
- :'charge' => :'InitialCharge'
44
+ :'charge' => :'InitialCharge',
45
+ :'idempotency_key' => :'String'
41
46
  }
42
47
  end
43
48
 
@@ -69,6 +74,10 @@ module Api
69
74
  if attributes.key?(:'charge')
70
75
  self.charge = attributes[:'charge']
71
76
  end
77
+
78
+ if attributes.key?(:'idempotency_key')
79
+ self.idempotency_key = attributes[:'idempotency_key']
80
+ end
72
81
  end
73
82
 
74
83
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -92,7 +101,8 @@ module Api
92
101
  return true if self.equal?(o)
93
102
  self.class == o.class &&
94
103
  customer == o.customer &&
95
- charge == o.charge
104
+ charge == o.charge &&
105
+ idempotency_key == o.idempotency_key
96
106
  end
97
107
 
98
108
  # @see the `==` method
@@ -104,7 +114,7 @@ module Api
104
114
  # Calculates hash code according to all attributes.
105
115
  # @return [Integer] Hash code
106
116
  def hash
107
- [customer, charge].hash
117
+ [customer, charge, idempotency_key].hash
108
118
  end
109
119
 
110
120
  # Builds the object from hash
@@ -14,7 +14,7 @@ require 'date'
14
14
  require 'time'
15
15
 
16
16
  module Api
17
- # This message represents a request to withdraw money from a customer. It contains the customer ID and the amount to withdraw.
17
+ # This message represents a request to withdraw money from a customer. It contains the customer ID and the amount to withdraw. Supports triggerError in charge.metadata for test error simulation. See InitialCharge.metadata.
18
18
  class WithdrawRequest
19
19
  attr_accessor :customer
20
20
 
data/lib/jamm/payment.rb CHANGED
@@ -3,6 +3,7 @@
3
3
  require 'rest-client'
4
4
  require 'json'
5
5
  require 'base64'
6
+ require 'securerandom'
6
7
  require 'jamm/errors'
7
8
 
8
9
  module Jamm
@@ -50,6 +51,29 @@ module Jamm
50
51
  raise Jamm::ApiError.from_error(e)
51
52
  end
52
53
 
54
+ # Auto-fills idempotency_key with a UUID when the caller did not supply one,
55
+ # so every async charge is retry-safe by default. A caller-supplied key is
56
+ # left untouched so explicit retries reuse the same value.
57
+ def self.off_session_async(customer:, charge:, idempotency_key: nil, merchant: nil)
58
+ key =
59
+ if idempotency_key.nil? || idempotency_key.strip.empty?
60
+ SecureRandom.uuid
61
+ else
62
+ idempotency_key
63
+ end
64
+
65
+ request = Jamm::OpenAPI::OffSessionPaymentAsyncRequest.new(
66
+ customer: customer,
67
+ charge: charge,
68
+ idempotency_key: key
69
+ )
70
+
71
+ handler = Jamm::Client.handler(merchant: merchant)
72
+ Jamm::OpenAPI::PaymentApi.new(handler).async_off_session_payment(request)
73
+ rescue Jamm::OpenAPI::ApiError => e
74
+ raise Jamm::ApiError.from_error(e)
75
+ end
76
+
53
77
  def self.get(charge_id, merchant: nil)
54
78
  handler = Jamm::Client.handler(merchant: merchant)
55
79
 
data/lib/jamm/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jamm
4
- VERSION = '2.1.0'
4
+ VERSION = '2.2.0'
5
5
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jamm
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.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-04-06 00:00:00.000000000 Z
11
+ date: 2026-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: base64
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.2'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rest-client
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -52,6 +66,7 @@ extra_rdoc_files: []
52
66
  files:
53
67
  - ".gitignore"
54
68
  - ".rubocop.yml"
69
+ - CHANGELOG.md
55
70
  - Gemfile
56
71
  - Gemfile.lock
57
72
  - LICENSE