lunixi-sdk 2.0.2 → 2.2.1
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/CHANGELOG.md +18 -0
- data/README.md +23 -3
- data/README.tr.md +18 -2
- data/docs/card-rewards.md +21 -0
- data/lib/lunixi/bank_connect.rb +132 -15
- data/lib/lunixi/bank_connect_filters.rb +13 -3
- data/lib/lunixi/bank_connect_pos.rb +165 -0
- data/lib/lunixi/bank_connect_values.rb +127 -5
- data/lib/lunixi/card_requests.rb +9 -1
- data/lib/lunixi/client.rb +15 -8
- data/lib/lunixi/direct_method_payment_request.rb +24 -2
- data/lib/lunixi/fraud.rb +3 -2
- data/lib/lunixi/fraud_uk_claims.rb +127 -0
- data/lib/lunixi/fraud_values.rb +46 -0
- data/lib/lunixi/marketplace.rb +2 -0
- data/lib/lunixi/payment_link_rules.rb +13 -1
- data/lib/lunixi/payment_link_values.rb +4 -0
- data/lib/lunixi/payment_links.rb +3 -1
- data/lib/lunixi/payment_values.rb +22 -2
- data/lib/lunixi/payments.rb +28 -5
- data/lib/lunixi/product_webhooks.rb +17 -1
- data/lib/lunixi/route_table.rb +10 -5
- data/lib/lunixi/routing_pin.rb +247 -0
- data/lib/lunixi/sanction.rb +77 -17
- data/lib/lunixi/sanction_batch.rb +215 -0
- data/lib/lunixi/sanction_values.rb +289 -5
- data/lib/lunixi/split_payment.rb +17 -2
- data/lib/lunixi/subscription_routing.rb +70 -0
- data/lib/lunixi/subscription_values.rb +26 -3
- data/lib/lunixi/subscriptions.rb +22 -2
- data/lib/lunixi/version.rb +1 -1
- data/lib/lunixi.rb +6 -0
- metadata +8 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
module Lunixi
|
|
3
|
+
module Lunixi # rubocop:disable Metrics/ModuleLength -- one constant group per catalog value set
|
|
4
4
|
# Subscription values and routes (/api/v1/subscriptions, and the portal-link routes under
|
|
5
5
|
# /api/panel/v1/subscriptions/portal). The same codes as the Node and PHP SDKs.
|
|
6
6
|
|
|
@@ -106,8 +106,16 @@ module Lunixi
|
|
|
106
106
|
PENDING_CHANGE_APPLIED = 'subscription.pending_change_applied'
|
|
107
107
|
PAYMENT_CARD_SWAPPED = 'subscription.payment_card_swapped'
|
|
108
108
|
PAYMENT_METHOD_LOST = 'subscription.payment_method_lost'
|
|
109
|
+
# A charge stopped because of the subscription's routing pin (a STRICT target cannot take it); data:
|
|
110
|
+
# SUBSCRIPTION_ROUTING_PIN_BLOCKED_FIELDS. The subscription waits in PAST_DUE (not canceled, not
|
|
111
|
+
# UNPAID) and the invoice is not retried automatically: change the pin with update_routing (the open
|
|
112
|
+
# invoice is charged again in the next retry round) or, once the connection is fixed, retry the
|
|
113
|
+
# invoice. Sent once per block.
|
|
114
|
+
ROUTING_PIN_BLOCKED = 'subscription.routing_pin_blocked'
|
|
109
115
|
INVOICE_CREATED = 'invoice.created'
|
|
110
116
|
INVOICE_PAID = 'invoice.paid'
|
|
117
|
+
# data.retryable false (with nextRetryAt nil): the charge stopped because of the routing pin and is
|
|
118
|
+
# not retried automatically.
|
|
111
119
|
INVOICE_PAYMENT_FAILED = 'invoice.payment_failed'
|
|
112
120
|
INVOICE_VOIDED = 'invoice.voided'
|
|
113
121
|
CARD_ADDED = 'card.added'
|
|
@@ -117,7 +125,8 @@ module Lunixi
|
|
|
117
125
|
CARD_EXPIRING_SOON = 'card.expiring_soon'
|
|
118
126
|
CARD_EXPIRED = 'card.expired'
|
|
119
127
|
ALL = [CREATED, ACTIVATED, TRIAL_WILL_END, PAUSED, RESUMED, CANCEL_SCHEDULED, CANCELED, UPGRADED, DOWNGRADED, PLAN_CHANGE_SCHEDULED,
|
|
120
|
-
PENDING_CHANGE_APPLIED, PAYMENT_CARD_SWAPPED, PAYMENT_METHOD_LOST, INVOICE_CREATED, INVOICE_PAID,
|
|
128
|
+
PENDING_CHANGE_APPLIED, PAYMENT_CARD_SWAPPED, PAYMENT_METHOD_LOST, ROUTING_PIN_BLOCKED, INVOICE_CREATED, INVOICE_PAID,
|
|
129
|
+
INVOICE_PAYMENT_FAILED,
|
|
121
130
|
INVOICE_VOIDED, CARD_ADDED, CARD_SET_DEFAULT, CARD_UPDATED, CARD_DEACTIVATED, CARD_EXPIRING_SOON, CARD_EXPIRED].freeze
|
|
122
131
|
end
|
|
123
132
|
|
|
@@ -129,6 +138,17 @@ module Lunixi
|
|
|
129
138
|
# Fields of a plan's billing rule.
|
|
130
139
|
SUBSCRIPTION_BILLING_RULE_FIELDS = %w[frequency interval byMonthDay byWeekDay timezone lastDayOfMonthFix count].freeze
|
|
131
140
|
|
|
141
|
+
# Fields of a subscription's routing (only on a subscription with a pin): requested (the pin; a field
|
|
142
|
+
# not given is nil) and blocked (SUBSCRIPTION_ROUTING_BLOCK_FIELDS, or nil).
|
|
143
|
+
SUBSCRIPTION_ROUTING_FIELDS = %w[requested blocked].freeze
|
|
144
|
+
|
|
145
|
+
# Fields of routing.blocked: code (payment.routing.*), reason (a RoutingPinReason value or nil), at
|
|
146
|
+
# (ISO 8601).
|
|
147
|
+
SUBSCRIPTION_ROUTING_BLOCK_FIELDS = %w[code reason at].freeze
|
|
148
|
+
|
|
149
|
+
# Fields of the subscription.routing_pin_blocked event data.
|
|
150
|
+
SUBSCRIPTION_ROUTING_PIN_BLOCKED_FIELDS = %w[subscriptionId invoiceId routing code reason blockedAt].freeze
|
|
151
|
+
|
|
132
152
|
subscriptions_base = '/api/v1/subscriptions'
|
|
133
153
|
portal_panel = '/api/panel/v1/subscriptions/portal'
|
|
134
154
|
cursor_query = %w[pageSize pageToken].freeze
|
|
@@ -144,7 +164,7 @@ module Lunixi
|
|
|
144
164
|
'create' => route.call('POST', "#{subscriptions_base}/subscriptions",
|
|
145
165
|
idempotency_key: 'required', required: %w[customerId planId idempotencyKey],
|
|
146
166
|
optional: %w[paymentCardId paymentMethodId collectionMethod priceUpdatePolicy entitlementPolicy billingTimezone startsAt
|
|
147
|
-
chargeOnCreate billingCycleAnchorOverride skipTrial metadata]),
|
|
167
|
+
chargeOnCreate billingCycleAnchorOverride skipTrial metadata routing]),
|
|
148
168
|
'get' => route.call('GET', "#{subscriptions_base}/subscriptions/:subscriptionId"),
|
|
149
169
|
'list' => route.call('GET', "#{subscriptions_base}/subscriptions", query: %w[customerId status] + cursor_query),
|
|
150
170
|
'cancel' => route.call('POST', "#{subscriptions_base}/subscriptions/:subscriptionId/cancel", required: %w[cancelAtPeriodEnd], optional: %w[reason]),
|
|
@@ -152,6 +172,9 @@ module Lunixi
|
|
|
152
172
|
'resume' => route.call('POST', "#{subscriptions_base}/subscriptions/:subscriptionId/resume"),
|
|
153
173
|
'changePlan' => route.call('POST', "#{subscriptions_base}/subscriptions/:subscriptionId/change-plan",
|
|
154
174
|
idempotency_key: 'optional', required: %w[newPlanId], optional: %w[behavior reason idempotencyKey]),
|
|
175
|
+
# routing nil removes the pin; the key is required (an empty body is 400).
|
|
176
|
+
'updateRouting' => route.call('POST', "#{subscriptions_base}/subscriptions/:subscriptionId/routing",
|
|
177
|
+
required: %w[routing], optional: %w[reason]),
|
|
155
178
|
'auditLogs' => route.call('GET', "#{subscriptions_base}/subscriptions/:subscriptionId/audit-logs", query: %w[limit pageToken]),
|
|
156
179
|
|
|
157
180
|
'plans.create' => route.call('POST', "#{subscriptions_base}/plans",
|
data/lib/lunixi/subscriptions.rb
CHANGED
|
@@ -60,8 +60,11 @@ module Lunixi
|
|
|
60
60
|
|
|
61
61
|
# { customerId, planId, paymentCardId?, paymentMethodId?, collectionMethod?, priceUpdatePolicy?,
|
|
62
62
|
# entitlementPolicy?, billingTimezone?, startsAt?, chargeOnCreate?, billingCycleAnchorOverride?,
|
|
63
|
-
# skipTrial?, metadata? }. The Idempotency-Key is required (idempotency_key: or the request's
|
|
64
|
-
# idempotencyKey; both given, they must agree) and is sent in the body as well.
|
|
63
|
+
# skipTrial?, metadata?, routing? }. The Idempotency-Key is required (idempotency_key: or the request's
|
|
64
|
+
# idempotencyKey; both given, they must agree) and is sent in the body as well. routing
|
|
65
|
+
# ({ providerCode:, credentialId:, mode: }) is stored on the subscription and sent with every period
|
|
66
|
+
# charge and retry; these charges have no 3D Secure step, so a STRICT target that needs it answers
|
|
67
|
+
# 422 payment.routing.pin_not_eligible and the charge is not retried daily.
|
|
65
68
|
def create(request, idempotency_key: nil)
|
|
66
69
|
body = RouteRequest.wire_hash!(request, 'create request')
|
|
67
70
|
key = RouteTable.idempotency_key_of('create', body, idempotency_key)
|
|
@@ -71,6 +74,7 @@ module Lunixi
|
|
|
71
74
|
SubscriptionRules.boolean!(body, 'skipTrial')
|
|
72
75
|
raise ConfigurationError, "'metadata' must be a Hash." if body.key?('metadata') && !body['metadata'].is_a?(Hash)
|
|
73
76
|
|
|
77
|
+
RoutingPin.field!(body)
|
|
74
78
|
@routes.data('create', body: body, idempotency_key: key)
|
|
75
79
|
end
|
|
76
80
|
|
|
@@ -115,6 +119,22 @@ module Lunixi
|
|
|
115
119
|
@routes.data('changePlan', params: { 'subscriptionId' => subscription_id }, body: body, idempotency_key: key)
|
|
116
120
|
end
|
|
117
121
|
|
|
122
|
+
# Changes the routing pin of the subscription's charges (POST …/subscriptions/{id}/routing). routing
|
|
123
|
+
# is a pin Hash ({ providerCode:, credentialId:, mode: }) or nil to remove the pin (normal routing);
|
|
124
|
+
# reason (at most 500 characters) goes to the audit trail. The block mark is cleared and an open
|
|
125
|
+
# invoice held by the old pin is charged again in the next retry round. Returns the subscription
|
|
126
|
+
# (read its pin with Lunixi::SubscriptionRouting.from_subscription).
|
|
127
|
+
def update_routing(subscription_id, routing, reason: nil)
|
|
128
|
+
body = { 'routing' => routing.nil? ? nil : RoutingPin.pin!(routing) }
|
|
129
|
+
unless reason.nil? || reason == ''
|
|
130
|
+
raise ConfigurationError, 'reason must be a String' unless reason.is_a?(String)
|
|
131
|
+
raise ConfigurationError, 'reason must be at most 500 characters' if reason.length > 500
|
|
132
|
+
|
|
133
|
+
body['reason'] = reason
|
|
134
|
+
end
|
|
135
|
+
@routes.data('updateRouting', params: { 'subscriptionId' => subscription_id }, body: body, null_fields: %w[routing])
|
|
136
|
+
end
|
|
137
|
+
|
|
118
138
|
# The audit trail of a subscription; filters limit, pageToken.
|
|
119
139
|
def audit_logs(subscription_id, **filters)
|
|
120
140
|
@routes.token_page('auditLogs', params: { 'subscriptionId' => subscription_id }, query: filters)
|
data/lib/lunixi/version.rb
CHANGED
data/lib/lunixi.rb
CHANGED
|
@@ -9,6 +9,7 @@ require_relative 'lunixi/product_category'
|
|
|
9
9
|
require_relative 'lunixi/signer'
|
|
10
10
|
require_relative 'lunixi/transport'
|
|
11
11
|
require_relative 'lunixi/payment_values'
|
|
12
|
+
require_relative 'lunixi/routing_pin'
|
|
12
13
|
require_relative 'lunixi/order_details'
|
|
13
14
|
require_relative 'lunixi/method_fields'
|
|
14
15
|
require_relative 'lunixi/promissory_note'
|
|
@@ -20,6 +21,8 @@ require_relative 'lunixi/card_requests'
|
|
|
20
21
|
require_relative 'lunixi/payments'
|
|
21
22
|
require_relative 'lunixi/reference'
|
|
22
23
|
require_relative 'lunixi/checkout'
|
|
24
|
+
require_relative 'lunixi/fraud_values'
|
|
25
|
+
require_relative 'lunixi/fraud_uk_claims'
|
|
23
26
|
require_relative 'lunixi/fraud'
|
|
24
27
|
require_relative 'lunixi/payment_link_values'
|
|
25
28
|
require_relative 'lunixi/payment_link_rules'
|
|
@@ -51,7 +54,9 @@ require_relative 'lunixi/wallet_resources'
|
|
|
51
54
|
require_relative 'lunixi/bank_connect_values'
|
|
52
55
|
require_relative 'lunixi/bank_connect_filters'
|
|
53
56
|
require_relative 'lunixi/bank_connect'
|
|
57
|
+
require_relative 'lunixi/bank_connect_pos'
|
|
54
58
|
require_relative 'lunixi/sanction_values'
|
|
59
|
+
require_relative 'lunixi/sanction_batch'
|
|
55
60
|
require_relative 'lunixi/sanction'
|
|
56
61
|
require_relative 'lunixi/insurance_values'
|
|
57
62
|
require_relative 'lunixi/insurance_request'
|
|
@@ -59,6 +64,7 @@ require_relative 'lunixi/insurance'
|
|
|
59
64
|
require_relative 'lunixi/route_table'
|
|
60
65
|
require_relative 'lunixi/subscription_values'
|
|
61
66
|
require_relative 'lunixi/subscriptions'
|
|
67
|
+
require_relative 'lunixi/subscription_routing'
|
|
62
68
|
require_relative 'lunixi/subscription_resources'
|
|
63
69
|
require_relative 'lunixi/kyc_values'
|
|
64
70
|
require_relative 'lunixi/kyc'
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lunixi-sdk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Lunixi
|
|
@@ -106,6 +106,7 @@ files:
|
|
|
106
106
|
- README.tr.md
|
|
107
107
|
- SECURITY.md
|
|
108
108
|
- docs/PUBLISHING.md
|
|
109
|
+
- docs/card-rewards.md
|
|
109
110
|
- docs/rails.en.md
|
|
110
111
|
- docs/rails.tr.md
|
|
111
112
|
- docs/ruby.en.md
|
|
@@ -113,6 +114,7 @@ files:
|
|
|
113
114
|
- lib/lunixi.rb
|
|
114
115
|
- lib/lunixi/bank_connect.rb
|
|
115
116
|
- lib/lunixi/bank_connect_filters.rb
|
|
117
|
+
- lib/lunixi/bank_connect_pos.rb
|
|
116
118
|
- lib/lunixi/bank_connect_values.rb
|
|
117
119
|
- lib/lunixi/bank_transfer.rb
|
|
118
120
|
- lib/lunixi/card_requests.rb
|
|
@@ -122,6 +124,8 @@ files:
|
|
|
122
124
|
- lib/lunixi/enabled_installments.rb
|
|
123
125
|
- lib/lunixi/errors.rb
|
|
124
126
|
- lib/lunixi/fraud.rb
|
|
127
|
+
- lib/lunixi/fraud_uk_claims.rb
|
|
128
|
+
- lib/lunixi/fraud_values.rb
|
|
125
129
|
- lib/lunixi/identity.rb
|
|
126
130
|
- lib/lunixi/identity_values.rb
|
|
127
131
|
- lib/lunixi/insurance.rb
|
|
@@ -166,11 +170,14 @@ files:
|
|
|
166
170
|
- lib/lunixi/route_response.rb
|
|
167
171
|
- lib/lunixi/route_table.rb
|
|
168
172
|
- lib/lunixi/route_value.rb
|
|
173
|
+
- lib/lunixi/routing_pin.rb
|
|
169
174
|
- lib/lunixi/sanction.rb
|
|
175
|
+
- lib/lunixi/sanction_batch.rb
|
|
170
176
|
- lib/lunixi/sanction_values.rb
|
|
171
177
|
- lib/lunixi/signer.rb
|
|
172
178
|
- lib/lunixi/split_payment.rb
|
|
173
179
|
- lib/lunixi/subscription_resources.rb
|
|
180
|
+
- lib/lunixi/subscription_routing.rb
|
|
174
181
|
- lib/lunixi/subscription_values.rb
|
|
175
182
|
- lib/lunixi/subscriptions.rb
|
|
176
183
|
- lib/lunixi/transport.rb
|