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
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 15d0bfe9861d614a8fbd5b4ba72ca9d9257409abab50470417e79ebfb645c5da
|
|
4
|
+
data.tar.gz: f3f689285448bd4795fe36566d69db76d7fd515b3b12e3e856cdea0d5a46baef
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7d918280c8b8f693dbcd4afb36c6d98ca511ee2eb38bc0499e3fc488a19806edc3201309f66314da019dba11ef9bec3d6d29ad0268f04bde184a1484cf753249
|
|
7
|
+
data.tar.gz: 5224e1fae4f1c61a0b0f3dcd33d5bbde4c5f9f8db7179936ef7daa284da023e5894a326446b4e7fb1d6ae18f4cd2dcdf301129a8ca686f5ca56fa88354c3fdfb
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.2.1 — 2026-12-03
|
|
4
|
+
|
|
5
|
+
- Development dependencies: `websocket-driver` 0.9.2 (0.8.2 has a critical advisory, GHSA-pf93-24xc-xgxc). The gem itself is unchanged.
|
|
6
|
+
|
|
7
|
+
## 2.2.0 — 2026-12-03
|
|
8
|
+
|
|
9
|
+
- Bank transfers: route preview `bank_connect.transfers.preview(accountId:, amountMinor:, receiverIban: | recipientId: | receiverAccountId:, currency: nil)` (`POST /api/v1/bank-connect/transfers/preview`) answers `rail`, `arrival`, `receiverBank`, `receiverIbanMasked`, `ownAccount`, `fastStatus` and `notes`; it stores nothing. `transfers.create` takes exactly one receiver — `receiverIban`, `recipientId` (a saved recipient) or `receiverAccountId` (your own account on the same connection: internal transfer) —, `receiverName` is required only with `receiverIban`, and `saveRecipient: { nickname: }` saves the receiver once the bank accepts the transfer; checked before sending. A transfer carries `plannedRail`, `railFallbackFrom`, `recipientId` and `receiverAccountId`. Saved recipients on `bank_connect.transfer_recipients` (`Lunixi::BankConnectTransferRecipients`): `list` / `iterate(q:, limit:, cursor:)`, `create(iban:, name:, nickname: nil)` (409 `bank_connect.transfer.recipient_exists`), `update(recipient_id, name:, nickname:)` (`nickname: ''` removes it), `delete(recipient_id)`. New values `BankTransferArrival`, `BankFastStatus`, `BankTransferPreviewNote`, `BANK_TRANSFER_RECEIVER_FIELDS`, `BANK_TRANSFER_RECIPIENT_NICKNAME_MAX`, `BANK_TRANSFER_RECIPIENT_SEARCH_MAX`; `BANK_TRANSFER_ROUTES` gains `previewTransfer`, `listTransferRecipients`, `createTransferRecipient`, `updateTransferRecipient`, `deleteTransferRecipient`.
|
|
10
|
+
- Bank accounts: POS accounts on `bank_connect.pos_accounts` (`Lunixi::BankConnectPosAccounts`) — the bank's merchant (POS) records on connections with the new capability `BankCapability::POS_ACQUIRING`: `list_accounts` / `iterate_accounts(connectionId:)`, `get_account`, `list_terminals` / `iterate_terminals`, `list_transactions` / `iterate_transactions(pos_account_id, terminalId:, from:, to:, type:, cardBrand:, minAmountMinor:, maxAmountMinor:, provisional:)` (`from`/`to` at most 92 days apart, checked before sending), `list_statement` / `iterate_statement` (value dates `YYYY-MM-DD`, both inclusive), `get_day_summary(pos_account_id, business_date)`, `request_sync`. Fields without a value are `nil`. New values `BankPosTransactionType`, `BankPosChannel`, `BankPosTransactionSource`, `BankPosRecordStatus`, `BankPosDayStatus`, `BANK_POS_FILTERS`, `BANK_POS_CARD_BRAND_PATTERN`, `BANK_POS_TRANSACTION_RANGE_MAX_DAYS`; webhook event `BankPosEvents::DAY_CLOSED` (`bank_pos.day_closed`, `BankPosEvents::PATTERN` `bank_pos.*`), read with `Lunixi::BankPosWebhook.parse` (data `BANK_POS_DAY_CLOSED_FIELDS`).
|
|
11
|
+
- Payments: `void` on a `PROCESSING` payment with an open request waiting for the buyer (Request to Pay approval, bank transfer instruction, QR) cancels the request; the answer's `code` is a `Lunixi::PaymentPendingActionCode` value (`payment.pending_action.cancelled`, `already_completed`, `not_cancellable`, `cancel_unconfirmed`, `not_open`, `busy`). Request to Pay can also run on DenizBank (`providerCode` `DENIZBANK_REQUEST_TO_PAY`, read it from the method list).
|
|
12
|
+
|
|
13
|
+
## 2.1.0 — 2026-12-01
|
|
14
|
+
|
|
15
|
+
- Sanction: country risk and website screening. `screen_name` accepts `nationality`, `residenceCountry` and `registrationCountry` (ISO 3166-1 alpha-2, country risk only); the answer carries `jurisdictionRisk`. New `screen_website` (`POST /api/v1/sanction/screening/website`, `website` + optional `customerReference`). Bulk rows and column mapping take the same three fields (`SanctionBatchMappingField::NATIONALITY`, `RESIDENCE_COUNTRY`, `REGISTRATION_COUNTRY`). New values `SanctionJurisdictionListCode`, `SanctionJurisdictionRiskEffect`, `SanctionJurisdictionRiskStatus`, `SanctionWebsiteMatchType`, `SanctionCoverageReason`, `SanctionBatchReasonCode::REVIEW_HIGH_RISK_JURISDICTION`; webhook event `SanctionEvents::MONITORING_JURISDICTION_RISK_FOUND` (`sanction.monitoring.jurisdiction_risk_found`).
|
|
16
|
+
- Sanction: `screen_name`, `screen_wallet`, `screen_website`, `screen_account`, `screen_transaction` and `screen_public_procurement_ban` take an optional `idempotency_key:`, sent as the `Idempotency-Key` header (8–120 printable ASCII characters, checked before sending; the gateway answers 400 `sanction.idempotency_key.invalid`); braceless keyword calls (`screen_name(name: 'X')`) keep working. A row of `get_batch_result_row` may carry `jurisdictionRisk` (`field`, `country`, `listCode`, `listName`, `effect`, `listDate`).
|
|
17
|
+
- Payments: routing pin. `routing: { providerCode:, credentialId:, mode: }` on `DirectMethodPaymentRequest#with_routing`, `InstallmentOptionsRequest#with_routing`, `payments.create_intent` / `create_marketplace_intent`, `payments.split` legs, `payment_links.create` / `update` as `checkout.routing`, `subscriptions.create` and the marketplace checkout intent and card charges, checked before sending (`Lunixi::RoutingPin.pin!`: at least one of `providerCode` / `credentialId`, `credentialId` a uuid, `mode` `PREFER` | `STRICT`, no unknown field; a non-card block's `providerCode` must equal `routing.providerCode`; no `routing` with `BANK_TRANSFER`). New `payments.connections.list(payment_method: nil)` (`GET /api/v1/payments/connections`, signed), `RoutingPin.result(response)` of a payment or an installment quote (an unknown `reason` is kept; `outcome` nil in a quote the `STRICT` target does not offer), `PaymentConnectionStatusChanged.from_event` (the whole payload, `deleted?`). New `subscriptions.update_routing(id, routing | nil, reason:)` (`POST /api/v1/subscriptions/subscriptions/{id}/routing`; nil removes the pin), `SubscriptionRouting.from_subscription`, `SubscriptionRoutingPinBlocked.from_event`, `SubscriptionEvents::ROUTING_PIN_BLOCKED` (`subscription.routing_pin_blocked`), `SUBSCRIPTION_ROUTING_FIELDS`, `SUBSCRIPTION_ROUTING_BLOCK_FIELDS`, `SUBSCRIPTION_ROUTING_PIN_BLOCKED_FIELDS`. New values `RoutingPinMode`, `RoutingPinOutcome`, `RoutingPinReason`, `RoutingPinErrorCode` (with `PIN_VIOLATION`), `RoutingPinMismatch` (`details.mismatch`), `ROUTING_PIN_FIELDS`, `ROUTING_PIN_RESULT_FIELDS`, `PaymentConnectionStatus` (with `DELETED`, in the event only), `PaymentConnectionEnvironment`, `PAYMENT_CONNECTION_FIELDS`, `PAYMENT_CONNECTION_STATUS_CHANGED_FIELDS`, `PAYMENT_LINK_CREATE_ONLY_FIELDS` (`environment`); webhook event `PaymentConnectionEvents::STATUS_CHANGED` (`payment.connection.status_changed`).
|
|
18
|
+
- Card rewards: signed option and balance reads, approved string-minor selections on existing direct and split card payments, and original-sale allocation reporting. Availability follows the connected payment programme.
|
|
19
|
+
- Fraud: `fraud.uk_claims.open(claim, actor_id:)` records a UK APP reimbursement claim (`POST /api/v1/fraud/uk-claims`) and returns the claim view. `actor_id` is sent as `X-Actor-Id` (the analyst recording the claim, required with an API key; 1-64 characters of letters, digits and `. _ @ + -`); unknown fields, numeric amounts and non-GBP claims are rejected before sending. New values `UK_CLAIM_FIELDS`, `UK_CLAIM_PAYMENT_FIELDS`, `UK_CLAIM_ROLES`, `UK_CLAIM_PAYER_TYPES`, `UK_CLAIM_REPORTED_BY`, `UK_CLAIM_SCAM_TYPES`, `UK_CLAIM_SCHEMES`, `UK_CLAIM_DEADLINE_KINDS`; fraud webhook event types `Lunixi::FraudWebhookEvents` / `FRAUD_EVENT_TYPES`, with the new `FraudWebhookEvents::UK_CLAIM_DEADLINE` (`fraud.uk_claim.deadline`).
|
|
20
|
+
|
|
3
21
|
## 2.0.2 — 2026-11-20
|
|
4
22
|
|
|
5
23
|
- The 2.0.0 and 2.0.1 releases did not reach RubyGems; this version carries the same changes. The Rails sample's development server `puma` moves to 8.0.4 (security advisories in 8.0.2); the gem has no runtime dependency on it.
|
data/README.md
CHANGED
|
@@ -113,8 +113,9 @@ The shared Lunixi form owns enabled payment methods and supports the methods con
|
|
|
113
113
|
| Physical POS management | `physical_pos_management` stores, registers, terminals (bank and provider rows, device links), devices and identity keys, end-of-day policies, catalog and overview |
|
|
114
114
|
| Wallet | `wallet.ping`, `wallet.end_users`, `wallets`, `deposits`, `corporate`, `fees`, `transfers`, `withdrawals`, `operations`, `topups`, `payments`, `qr`, `bulk_payouts` |
|
|
115
115
|
| Bank accounts | `bank_connect.list_banks`, `list_connections`, `get_connection`, `list_accounts`, `get_account`, `request_sync`, `list_balances`, `list_transactions`, `get_transaction` |
|
|
116
|
-
| Bank transfers and FX | `bank_connect.transfers.list_purposes`, `create(request, idempotency_key: nil)`, `list`, `get`; `bank_connect.fx.list_rates`, `create_quote`, `create_order(request, idempotency_key: nil)`, `list_orders`, `get_order` |
|
|
117
|
-
|
|
|
116
|
+
| Bank transfers and FX | `bank_connect.transfers.list_purposes`, `preview(request)`, `create(request, idempotency_key: nil)`, `list`, `get`; `bank_connect.transfer_recipients.list`, `iterate`, `create`, `update(recipient_id, changes)`, `delete`; `bank_connect.fx.list_rates`, `create_quote`, `create_order(request, idempotency_key: nil)`, `list_orders`, `get_order` |
|
|
117
|
+
| POS accounts (bank records) | `bank_connect.pos_accounts.list_accounts`, `get_account`, `list_terminals`, `list_transactions`, `list_statement`, `get_day_summary(pos_account_id, business_date)`, `request_sync` (and the `iterate_*` forms) |
|
|
118
|
+
| Sanctions screening | `sanction.screen_name`, `screen_wallet`, `screen_website`, `screen_account`, `screen_transaction`, `screen_public_procurement_ban`, `screen_adverse_media`, monitoring, entity intelligence, `list_blacklist_entries`, `Lunixi::Sanction.clear_screening?(result)` |
|
|
118
119
|
| Insurance | `insurance.list_products`, `search_products`, `create_quote`, `create_order`, `bind_payment`, `confirm_payment`, `issue_policy`, `cancel_order`, `refund_premium`, policy files, reconciliation, leads |
|
|
119
120
|
| Subscriptions | `subscriptions.create(request, idempotency_key:)`, `get`, `list`, `cancel`, `pause`, `resume`, `change_plan`, `audit_logs`; sub-clients `plans`, `customers`, `cards`, `invoices`, `portal`, `products`, `features`, `addons`, `usage` |
|
|
120
121
|
| KYC / KYB / evidence | `kyc.create_session`, `get_session`, `list_sessions`, `set_jurisdiction`, `set_primary_document`, `upload_document`, `timeline`, `submit`, `manual_review`, `evidence_request`, merchant policy, webhook outbox, erasure requests |
|
|
@@ -290,7 +291,7 @@ transfer = lunixi.bank_connect.transfers.create(
|
|
|
290
291
|
)
|
|
291
292
|
```
|
|
292
293
|
|
|
293
|
-
`transfers` and `fx` need the `bank-connect:transfer` scope and a key with an IP allowlist. `transfers.create` and `fx.create_order` retry a network error or a 5xx with the same key and body; pass your own key to retry safely across processes (the same key and body answer the existing record with `replayed: true`). An answered error carries the key as `idempotency_key`. `fx.create_quote` takes exactly one of `sourceAmountMinor` / `targetAmountMinor`.
|
|
294
|
+
`transfers` and `fx` need the `bank-connect:transfer` scope and a key with an IP allowlist. `transfers.create` and `fx.create_order` retry a network error or a 5xx with the same key and body; pass your own key to retry safely across processes (the same key and body answer the existing record with `replayed: true`). An answered error carries the key as `idempotency_key`. `fx.create_quote` takes exactly one of `sourceAmountMinor` / `targetAmountMinor`. A transfer's receiver is exactly one of `receiverIban` (with `receiverName`), `recipientId` (a saved recipient of `transfer_recipients`) or `receiverAccountId` (your own account, internal transfer); `transfers.preview` shows the rail and arrival before sending.
|
|
294
295
|
|
|
295
296
|
## Sanctions screening
|
|
296
297
|
|
|
@@ -303,6 +304,21 @@ review!(result) unless Lunixi::Sanction.clear_screening?(result)
|
|
|
303
304
|
|
|
304
305
|
Screening returns matches, not verdicts. A result is clear only when it has no match or hit, no blocking flag or decision and, when it reports coverage, `coverageStatus` is `COMPLETE`; a screening that could not run raises `ApiError` and never looks like an empty result.
|
|
305
306
|
|
|
307
|
+
Country risk: name screening also takes `nationality`, `residenceCountry` (a person) and `registrationCountry` (an organization), ISO 3166-1 alpha-2, compared only with the country risk lists and never read by name matching. The answer's `jurisdictionRisk` holds `ruleVersion`, `status` (`ASSESSED`, `NO_COUNTRY`, `UNAVAILABLE`), `subjectCountries`, `matches`, `lists`, `effect` (`REVIEW`, `INFO`, `NONE`) and `decisionRaised`. A country on the FATF call-for-action list (`FATF_CALL_FOR_ACTION`) turns an `allow` into a `review` (`REVIEW_HIGH_RISK_JURISDICTION`); the FATF increased-monitoring list (`FATF_INCREASED_MONITORING`) and the EU high-risk third countries (`EU_HIGH_RISK_THIRD_COUNTRIES`) are information only; a country never blocks. A field that does not apply to the subject type, or an invalid code, is refused with 400 `sanction.screen_name.failed` (`details.issues[].code`: `FIELD_NOT_APPLICABLE_FOR_SUBJECT_TYPE`, `NATIONALITY_INVALID`, `RESIDENCE_COUNTRY_INVALID`, `REGISTRATION_COUNTRY_INVALID`). Bulk rows and column mapping take the same three fields.
|
|
308
|
+
|
|
309
|
+
```ruby
|
|
310
|
+
result = lunixi.sanction.screen_name(name: 'Customer Name', subjectType: 'person', nationality: 'TR')
|
|
311
|
+
risk = result['jurisdictionRisk'] # nil on older screenings
|
|
312
|
+
review!(result) if risk && risk['effect'] == Lunixi::SanctionJurisdictionRiskEffect::REVIEW
|
|
313
|
+
site = lunixi.sanction.screen_website(website: 'https://www.example.com/path', customerReference: customer.id,
|
|
314
|
+
idempotency_key: "site-check-#{customer.id}")
|
|
315
|
+
# site['domain'], site['hits'][i]['matchType'] (Lunixi::SanctionWebsiteMatchType), site['decision']
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
Website screening compares the host in canonical form with the websites on the lists: the listed host itself (`EXACT_HOST`) or a subdomain of it (`PARENT_DOMAIN`). The decision is `review` or `allow`, never a block. Webhook `sanction.monitoring.jurisdiction_risk_found`: a monitored subject's country entered the FATF call-for-action list.
|
|
319
|
+
|
|
320
|
+
The name, wallet, website, account, transaction and public procurement ban screenings take an optional idempotency key, sent as the `Idempotency-Key` header (8–120 printable ASCII characters without spaces; otherwise 400 `sanction.idempotency_key.invalid`); without one no header is sent. A bulk result row read one by one may carry `jurisdictionRisk[]` (`field`, `country`, `listCode`, `listName`, `effect`, `listDate`); the row list does not.
|
|
321
|
+
|
|
306
322
|
## Insurance
|
|
307
323
|
|
|
308
324
|
`client.insurance` offers, sells and services insurance for your basket items (I1–I22). Every call is signed. `create_order`, `confirm_payment`, `issue_policy`, `cancel_order`, `refund_premium` and `create_lead` require an `Idempotency-Key` (8–200 printable ASCII); `create_quote` and `bind_payment` take one optionally. The basket of a quote is either `paymentIntentId` or `context.items`, never both; the fields of an insurance type's own object are validated by the gateway (422 `insurance.validation.invalid` with every field at once).
|
|
@@ -430,3 +446,7 @@ Historical focused 0.1.2 verification: 24 Rails form/return/URL/CSP security tes
|
|
|
430
446
|
The checkout page’s CSP permits form POSTs only to `'self'` and the configured gateway origin (default `https://api-gateway.lunixi.com`). This preserves wallet/provider and legacy POST handoffs supported by the browser SDK. For another reviewed provider, set server-only `LUNIXI_FORM_ACTION_ORIGINS` to a comma-separated list of exact HTTPS origins, without spaces, paths, trailing slashes, credentials, query, fragment or wildcards. Invalid configuration fails closed; gateway responses and browser fields never expand this list. Script nonces, frame/connect restrictions and informational return handling remain in force.
|
|
431
447
|
|
|
432
448
|
Before upgrading from 0.x, follow [the money-string migration](MIGRATION-1.0.md).
|
|
449
|
+
|
|
450
|
+
### Card rewards
|
|
451
|
+
|
|
452
|
+
See [Card rewards](docs/card-rewards.md) for signed balance queries, approved reward selections on direct or split payments, and allocation reporting.
|
data/README.tr.md
CHANGED
|
@@ -111,8 +111,9 @@ HTTP 2xx, token, dönüş sayfası veya devam eden split durumu tahsilat kanıt
|
|
|
111
111
|
| Fiziki POS yönetimi | `physical_pos_management` mağazalar, kasalar, terminaller (banka ve sağlayıcı satırları, cihaz bağlantıları), cihazlar ve kimlik anahtarları, gün sonu politikaları, katalog ve genel görünüm |
|
|
112
112
|
| Cüzdan | `wallet.ping`, `wallet.end_users`, `wallets`, `deposits`, `corporate`, `fees`, `transfers`, `withdrawals`, `operations`, `topups`, `payments`, `qr`, `bulk_payouts` |
|
|
113
113
|
| Banka hesapları | `bank_connect.list_banks`, `list_connections`, `get_connection`, `list_accounts`, `get_account`, `request_sync`, `list_balances`, `list_transactions`, `get_transaction` |
|
|
114
|
-
| Banka transferleri ve döviz | `bank_connect.transfers.list_purposes`, `create(request, idempotency_key: nil)`, `list`, `get`; `bank_connect.fx.list_rates`, `create_quote`, `create_order(request, idempotency_key: nil)`, `list_orders`, `get_order` |
|
|
115
|
-
|
|
|
114
|
+
| Banka transferleri ve döviz | `bank_connect.transfers.list_purposes`, `preview(request)`, `create(request, idempotency_key: nil)`, `list`, `get`; `bank_connect.transfer_recipients.list`, `iterate`, `create`, `update(recipient_id, changes)`, `delete`; `bank_connect.fx.list_rates`, `create_quote`, `create_order(request, idempotency_key: nil)`, `list_orders`, `get_order` |
|
|
115
|
+
| POS hesapları (banka kayıtları) | `bank_connect.pos_accounts.list_accounts`, `get_account`, `list_terminals`, `list_transactions`, `list_statement`, `get_day_summary(pos_account_id, business_date)`, `request_sync` (ve `iterate_*` biçimleri) |
|
|
116
|
+
| Yaptırım taraması | `sanction.screen_name`, `screen_wallet`, `screen_website`, `screen_account`, `screen_transaction`, `screen_public_procurement_ban`, `screen_adverse_media`, izleme, varlık istihbaratı, `list_blacklist_entries`, `Lunixi::Sanction.clear_screening?(result)` |
|
|
116
117
|
| Sigorta | `insurance.list_products`, `search_products`, `create_quote`, `create_order`, `bind_payment`, `confirm_payment`, `issue_policy`, `cancel_order`, `refund_premium`, poliçe dosyaları, mutabakat, potansiyel müşteriler |
|
|
117
118
|
| Abonelik | `subscriptions.create(request, idempotency_key:)`, `get`, `list`, `cancel`, `pause`, `resume`, `change_plan`, `audit_logs`; alt istemciler `plans`, `customers`, `cards`, `invoices`, `portal`, `products`, `features`, `addons`, `usage` |
|
|
118
119
|
| KYC / KYB / kanıt | `kyc.create_session`, `get_session`, `list_sessions`, `set_jurisdiction`, `set_primary_document`, `upload_document`, `timeline`, `submit`, `manual_review`, `evidence_request`, üye işyeri politikası, webhook kuyruğu, silme talepleri |
|
|
@@ -294,6 +295,21 @@ review!(result) unless Lunixi::Sanction.clear_screening?(result)
|
|
|
294
295
|
|
|
295
296
|
Tarama karar değil eşleşme döndürür. Sonuç yalnız eşleşme veya isabet, engelleyici işaret veya karar yoksa ve kapsam bildiriyorsa `coverageStatus` değeri `COMPLETE` ise temizdir; çalıştırılamayan tarama `ApiError` oluşturur ve hiçbir zaman boş sonuç gibi görünmez.
|
|
296
297
|
|
|
298
|
+
Ülke riski: isim taraması ayrıca `nationality`, `residenceCountry` (kişi) ve `registrationCountry` (kurum) alanlarını ISO 3166-1 alpha-2 kodla alır. Bu alanlar yalnız ülke riski listeleriyle karşılaştırılır, isim eşleştirmesini etkilemez. Yanıttaki `jurisdictionRisk` nesnesi `ruleVersion`, `status` (`ASSESSED`, `NO_COUNTRY`, `UNAVAILABLE`), `subjectCountries`, `matches`, `lists`, `effect` (`REVIEW`, `INFO`, `NONE`) ve `decisionRaised` alanlarını taşır. FATF karşı tedbir çağrısı listesindeki (`FATF_CALL_FOR_ACTION`) ülke "izin ver" kararını incelemeye çevirir (`REVIEW_HIGH_RISK_JURISDICTION`); FATF artırılmış izleme listesi (`FATF_INCREASED_MONITORING`) ve AB yüksek riskli üçüncü ülkeler (`EU_HIGH_RISK_THIRD_COUNTRIES`) yalnız bilgidir. Ülke tek başına engelleme üretmez. Kişi ya da kuruma uymayan alan ve geçersiz kod 400 `sanction.screen_name.failed` ile reddedilir (`details.issues[].code`: `FIELD_NOT_APPLICABLE_FOR_SUBJECT_TYPE`, `NATIONALITY_INVALID`, `RESIDENCE_COUNTRY_INVALID`, `REGISTRATION_COUNTRY_INVALID`). Toplu taramada satırlar ve sütun eşlemesi aynı üç alanı alır.
|
|
299
|
+
|
|
300
|
+
```ruby
|
|
301
|
+
result = lunixi.sanction.screen_name(name: 'Customer Name', subjectType: 'person', nationality: 'TR')
|
|
302
|
+
risk = result['jurisdictionRisk'] # nil on older screenings
|
|
303
|
+
review!(result) if risk && risk['effect'] == Lunixi::SanctionJurisdictionRiskEffect::REVIEW
|
|
304
|
+
site = lunixi.sanction.screen_website(website: 'https://www.example.com/path', customerReference: customer.id,
|
|
305
|
+
idempotency_key: "site-check-#{customer.id}")
|
|
306
|
+
# site['domain'], site['hits'][i]['matchType'] (Lunixi::SanctionWebsiteMatchType), site['decision']
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
Web sitesi taraması host'u kanonik biçimde listelerdeki web siteleriyle karşılaştırır: listelenen host'un kendisi (`EXACT_HOST`) ya da onun alt alan adı (`PARENT_DOMAIN`). Karar `review` ya da `allow` olur, engelleme yoktur. Webhook `sanction.monitoring.jurisdiction_risk_found`: izlediğiniz kişi ya da kurumun ülkesi FATF karşı tedbir çağrısı listesine girdi.
|
|
310
|
+
|
|
311
|
+
İsim, cüzdan, web sitesi, hesap, işlem ve kamu ihalesi yasağı taramaları isteğe bağlı bir idempotency anahtarı alır; anahtar `Idempotency-Key` başlığıyla gider (boşluksuz 8–120 yazdırılabilir ASCII karakter; aksi hâlde 400 `sanction.idempotency_key.invalid`). Anahtar vermezseniz başlık gönderilmez. Toplu taramada tek tek okunan satır sonucu `jurisdictionRisk[]` (`field`, `country`, `listCode`, `listName`, `effect`, `listDate`) taşıyabilir; satır listesinde bu alan yoktur.
|
|
312
|
+
|
|
297
313
|
## Sigorta
|
|
298
314
|
|
|
299
315
|
`client.insurance` sepet kalemleriniz için sigorta sunar, satar ve yönetir (I1–I22). Her çağrı imzalıdır. `create_order`, `confirm_payment`, `issue_policy`, `cancel_order`, `refund_premium` ve `create_lead` bir `Idempotency-Key` ister (8–200 yazdırılabilir ASCII); `create_quote` ve `bind_payment` isteğe bağlı anahtar alır. Teklifin sepeti ya `paymentIntentId` ya da `context.items` olur, ikisi birden olmaz; bir sigorta türünün kendi nesnesinin alanlarını gateway doğrular (bütün alanlar tek seferde 422 `insurance.validation.invalid` ile).
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Card rewards
|
|
2
|
+
|
|
3
|
+
Use the reward-options and reward-query methods of the payments client. These are signed server-side reads; query results do not reserve a balance. Send money as string minor units, for example `"10000"` for TRY 100.
|
|
4
|
+
|
|
5
|
+
Attach the selected `cardRewardSelection` (`selectionId`, `amountMinor`) to the existing direct payment or an eligible new-card split leg. Keep the full order or leg amount unchanged. Reuse the query's order, card, currency, installment and quote. Reuse the payment's idempotency key when retrying the same request.
|
|
6
|
+
|
|
7
|
+
The checkout displays this flow under **Points / Gift vouchers**. It does not add a points control to the ordinary card form. A non-card voucher uses its own method fields.
|
|
8
|
+
|
|
9
|
+
A selection expires and is scoped to the merchant and environment. A 2D-only reward selection cannot be changed into a 3D Secure payment or preauthorization. An unknown payment outcome must be checked using the existing payment ID; do not create a new charge.
|
|
10
|
+
|
|
11
|
+
The optional `cardRewardAllocation` response separates the requested amounts from the provider-confirmed original-sale amounts. Missing `actual` is unknown, never zero. A refund does not imply that points were restored in the original proportions.
|
|
12
|
+
|
|
13
|
+
For request examples and the current contract, see [Card rewards](https://docs.lunixi.com/en/payments/card-rewards).
|
|
14
|
+
|
|
15
|
+
## SDK methods
|
|
16
|
+
|
|
17
|
+
- `list_card_rewards(body)`
|
|
18
|
+
- `query_card_rewards(body)`
|
|
19
|
+
- `with_card_reward_selection(selection_id, amount_minor)`
|
|
20
|
+
|
|
21
|
+
A split leg carries `cardRewardSelection` in the existing split request body. It does not create a separate points payment.
|
data/lib/lunixi/bank_connect.rb
CHANGED
|
@@ -16,19 +16,23 @@ module Lunixi
|
|
|
16
16
|
# outside its set, limit outside 1–100, more than 100 account ids, a malformed amount or a bad date
|
|
17
17
|
# window raises ConfigurationError. Filter keys are the wire names (snake_case works too).
|
|
18
18
|
#
|
|
19
|
-
# Money movement is on transfers (Lunixi::BankConnectTransfers)
|
|
20
|
-
#
|
|
19
|
+
# Money movement is on transfers (Lunixi::BankConnectTransfers), transfer_recipients
|
|
20
|
+
# (Lunixi::BankConnectTransferRecipients) and fx (Lunixi::BankConnectFx), for a connection whose
|
|
21
|
+
# capabilities include OUTGOING_TRANSFER / FX_EXCHANGE. The bank's merchant (POS) records are read on
|
|
22
|
+
# pos_accounts (Lunixi::BankConnectPosAccounts) for a connection with POS_ACQUIRING.
|
|
21
23
|
#
|
|
22
24
|
# Answers are the envelope's data; lists return a Lunixi::ListPage.
|
|
23
25
|
class BankConnect
|
|
24
26
|
BASE = '/api/v1/bank-connect'
|
|
25
|
-
attr_reader :transfers, :fx
|
|
27
|
+
attr_reader :transfers, :fx, :transfer_recipients, :pos_accounts
|
|
26
28
|
|
|
27
29
|
def initialize(client, max_retries:, backoff:)
|
|
28
30
|
@client = client
|
|
29
31
|
invoker = BankTransferInvoker.new(client, max_retries: max_retries, backoff: backoff)
|
|
30
32
|
@transfers = BankConnectTransfers.new(invoker)
|
|
31
33
|
@fx = BankConnectFx.new(invoker)
|
|
34
|
+
@transfer_recipients = BankConnectTransferRecipients.new(invoker)
|
|
35
|
+
@pos_accounts = BankConnectPosAccounts.new(client)
|
|
32
36
|
end
|
|
33
37
|
|
|
34
38
|
# The bank catalogue: whether each bank can be connected and what is read from it.
|
|
@@ -129,8 +133,13 @@ module Lunixi
|
|
|
129
133
|
# Every route, reads included, is signed and needs bank-connect:transfer; the key must have an IP
|
|
130
134
|
# allowlist and the request must come from a listed IP (403 bank_connect.auth.ip_allowlist_required /
|
|
131
135
|
# ip_not_allowed). With an API key there is no e-mail code: create answers SUBMITTED and the transfer
|
|
132
|
-
# is queued for the bank. Follow it with get or the bank_transfer.* webhooks. The
|
|
133
|
-
#
|
|
136
|
+
# is queued for the bank. Follow it with get or the bank_transfer.* webhooks. The rail (own account,
|
|
137
|
+
# same bank, FAST or EFT) is set when the transfer is created; preview shows it beforehand. Lunixi does
|
|
138
|
+
# not check the balance.
|
|
139
|
+
#
|
|
140
|
+
# The receiver is exactly one of receiverIban (typed IBAN), recipientId (a saved recipient, see
|
|
141
|
+
# bank_connect.transfer_recipients) or receiverAccountId (your own account on the same connection:
|
|
142
|
+
# internal transfer).
|
|
134
143
|
class BankConnectTransfers
|
|
135
144
|
def initialize(invoker)
|
|
136
145
|
@invoker = invoker
|
|
@@ -142,10 +151,26 @@ module Lunixi
|
|
|
142
151
|
@invoker.data('listTransferPurposes', query: { 'connectionId' => RouteValue.text!(connection_id, 'connectionId') })
|
|
143
152
|
end
|
|
144
153
|
|
|
145
|
-
#
|
|
146
|
-
#
|
|
147
|
-
#
|
|
148
|
-
#
|
|
154
|
+
# Route preview: { rail, arrival, receiverBank, receiverIbanMasked, ownAccount, fastStatus, notes }.
|
|
155
|
+
# Stores nothing and sends nothing to the bank. request: accountId, amountMinor, exactly one receiver
|
|
156
|
+
# field (receiverIban | recipientId | receiverAccountId), optional currency. rail UNKNOWN: the bank
|
|
157
|
+
# offers no preview; the transfer can still be sent. Creating the transfer applies the same rule
|
|
158
|
+
# (transfer.plannedRail). notes are BankTransferPreviewNote codes.
|
|
159
|
+
def preview(request)
|
|
160
|
+
body = @invoker.body!('previewTransfer', request)
|
|
161
|
+
BankTransferInvoker.check_receiver!('previewTransfer', body)
|
|
162
|
+
body['currency'] = RouteValue.currency!(body['currency'], 'currency') if body.key?('currency')
|
|
163
|
+
@invoker.post('previewTransfer', body)
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
# Creates an outgoing transfer (HTTP 201): { transfer, stepUp, replayed }. request: accountId, exactly
|
|
167
|
+
# one receiver field — receiverIban (TR IBAN, at most 42 characters), recipientId (saved recipient) or
|
|
168
|
+
# receiverAccountId (your own account, internal transfer) —, receiverName (2–140 characters; required
|
|
169
|
+
# with receiverIban, otherwise the saved / account name is used when left out), amountMinor (a
|
|
170
|
+
# positive minor-unit string: "150075" = 1,500.75 TRY), optional currency, paymentPurpose, description
|
|
171
|
+
# (at most 140 characters) and saveRecipient ({ nickname: }: add or update the receiver in your saved
|
|
172
|
+
# recipients once the bank accepts the transfer; ignored with receiverAccountId). The transfer
|
|
173
|
+
# carries plannedRail, railFallbackFrom, recipientId and receiverAccountId.
|
|
149
174
|
#
|
|
150
175
|
# idempotency_key (8–200 printable ASCII) is generated (UUID v4) when nil; a network error or a 5xx
|
|
151
176
|
# is retried with the same key and body. Keep your own key (e.g. your payout id) to retry safely
|
|
@@ -178,6 +203,57 @@ module Lunixi
|
|
|
178
203
|
end
|
|
179
204
|
end
|
|
180
205
|
|
|
206
|
+
# bank_connect.transfer_recipients: saved recipients (/api/v1/bank-connect/transfer-recipients). Same
|
|
207
|
+
# scope and IP allowlist rule as transfers. The full IBAN is never returned (only ibanMasked); send
|
|
208
|
+
# money to a saved recipient with transfers.create(recipientId: ...). One recipient per IBAN and
|
|
209
|
+
# environment: creating an existing IBAN is 409 bank_connect.transfer.recipient_exists
|
|
210
|
+
# (details.recipientId).
|
|
211
|
+
class BankConnectTransferRecipients
|
|
212
|
+
def initialize(invoker)
|
|
213
|
+
@invoker = invoker
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
# Saved recipients, newest first. Filters: q (1–64 characters; name, nickname or bank name), limit
|
|
217
|
+
# 1–100, cursor.
|
|
218
|
+
def list(**filters)
|
|
219
|
+
@invoker.page('listTransferRecipients', query: BankConnectFilters.transfer_query!(filters, 'listTransferRecipients'))
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
def iterate(**filters, &block)
|
|
223
|
+
RouteResponse.each_item(filters, block) { |query| list(**query) }
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
# Adds a recipient (HTTP 201). request: iban (TR IBAN), name (2–140 characters), optional nickname (at
|
|
227
|
+
# most 64 characters).
|
|
228
|
+
def create(request)
|
|
229
|
+
body = @invoker.body!('createTransferRecipient', request)
|
|
230
|
+
body['name'] = BankTransferInvoker.name!('name', body['name'])
|
|
231
|
+
body['nickname'] = BankTransferInvoker.nickname!(body['nickname']) if body.key?('nickname')
|
|
232
|
+
@invoker.post('createTransferRecipient', body)
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
# Changes name and/or nickname; the IBAN cannot change. nickname: '' removes the nickname (sent as is).
|
|
236
|
+
def update(recipient_id, changes)
|
|
237
|
+
given = RouteRequest.wire_keys!(changes, %w[name nickname], 'updateTransferRecipient')
|
|
238
|
+
body = {}
|
|
239
|
+
body['name'] = BankTransferInvoker.name!('name', given['name']) if given.key?('name')
|
|
240
|
+
body['nickname'] = BankTransferInvoker.nickname!(given['nickname']) if given.key?('nickname')
|
|
241
|
+
raise ConfigurationError, 'updateTransferRecipient needs name or nickname.' if body.empty?
|
|
242
|
+
|
|
243
|
+
@invoker.post('updateTransferRecipient', body, params: { 'recipientId' => recipient_id })
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
# Removes a recipient: { deleted: true }. Past transfers are not affected and the IBAN can be added
|
|
247
|
+
# again.
|
|
248
|
+
def delete(recipient_id)
|
|
249
|
+
@invoker.data('deleteTransferRecipient', params: { 'recipientId' => recipient_id })
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
def inspect
|
|
253
|
+
'#<Lunixi::BankConnectTransferRecipients>'
|
|
254
|
+
end
|
|
255
|
+
end
|
|
256
|
+
|
|
181
257
|
# bank_connect.fx: currency exchange between two active accounts of one connection in different
|
|
182
258
|
# currencies (/api/v1/bank-connect/fx). Same scope and IP allowlist rule as transfers.
|
|
183
259
|
#
|
|
@@ -239,12 +315,27 @@ module Lunixi
|
|
|
239
315
|
# take the caller's key (checked) or a new UUID v4, and are retried with the same key and body after
|
|
240
316
|
# a network error or a 5xx. Not a public API.
|
|
241
317
|
class BankTransferInvoker
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
318
|
+
# Exactly one of receiverIban / recipientId / receiverAccountId (the gateway answers 400
|
|
319
|
+
# receiver.exactly_one_required otherwise); returns the receiver field.
|
|
320
|
+
def self.check_receiver!(name, body)
|
|
321
|
+
given = BANK_TRANSFER_RECEIVER_FIELDS.select { |key| body.key?(key) }
|
|
322
|
+
raise ConfigurationError, "#{name} takes exactly one of #{BANK_TRANSFER_RECEIVER_FIELDS.join(', ')}." unless given.length == 1
|
|
323
|
+
|
|
324
|
+
field = given.first
|
|
325
|
+
body[field] = RouteValue.text!(body[field], field)
|
|
326
|
+
if field == 'receiverIban' && body[field].length > BANK_TRANSFER_IBAN_MAX
|
|
327
|
+
raise ConfigurationError, "'receiverIban' must be at most #{BANK_TRANSFER_IBAN_MAX} characters."
|
|
246
328
|
end
|
|
247
329
|
|
|
330
|
+
field
|
|
331
|
+
end
|
|
332
|
+
|
|
333
|
+
def self.check_transfer!(body)
|
|
334
|
+
receiver = check_receiver!('createTransfer', body)
|
|
335
|
+
raise ConfigurationError, 'createTransfer requires receiverName with receiverIban.' if receiver == 'receiverIban' && !body.key?('receiverName')
|
|
336
|
+
|
|
337
|
+
body['receiverName'] = name!('receiverName', body['receiverName']) if body.key?('receiverName')
|
|
338
|
+
body['saveRecipient'] = save_recipient!(body['saveRecipient']) if body.key?('saveRecipient')
|
|
248
339
|
body['currency'] = RouteValue.currency!(body['currency'], 'currency') if body.key?('currency')
|
|
249
340
|
if body.key?('paymentPurpose') && !(body['paymentPurpose'].is_a?(String) && body['paymentPurpose'].match?(BANK_TRANSFER_PAYMENT_PURPOSE_PATTERN))
|
|
250
341
|
raise ConfigurationError, "'paymentPurpose' must be a code from list_purposes (letters, digits, underscore; at most 64)."
|
|
@@ -254,6 +345,31 @@ module Lunixi
|
|
|
254
345
|
body
|
|
255
346
|
end
|
|
256
347
|
|
|
348
|
+
# A receiver or recipient name: 2–140 characters, trimmed.
|
|
349
|
+
def self.name!(field, value)
|
|
350
|
+
name = RouteValue.text!(value, field)
|
|
351
|
+
return name if name.length.between?(BANK_TRANSFER_RECEIVER_NAME_MIN, BANK_TRANSFER_RECEIVER_NAME_MAX)
|
|
352
|
+
|
|
353
|
+
raise ConfigurationError, "'#{field}' must be #{BANK_TRANSFER_RECEIVER_NAME_MIN}-#{BANK_TRANSFER_RECEIVER_NAME_MAX} characters."
|
|
354
|
+
end
|
|
355
|
+
|
|
356
|
+
# A saved recipient nickname: a String of at most 64 characters, trimmed ('' is kept).
|
|
357
|
+
def self.nickname!(value)
|
|
358
|
+
return value.strip if value.is_a?(String) && value.strip.length <= BANK_TRANSFER_RECIPIENT_NICKNAME_MAX
|
|
359
|
+
|
|
360
|
+
raise ConfigurationError, "'nickname' must be a string of at most #{BANK_TRANSFER_RECIPIENT_NICKNAME_MAX} characters."
|
|
361
|
+
end
|
|
362
|
+
|
|
363
|
+
# saveRecipient: a Hash with an optional nickname; sent as {} or { 'nickname' => ... }.
|
|
364
|
+
def self.save_recipient!(value)
|
|
365
|
+
unless value.is_a?(Hash) && value.keys.all? { |key| key.to_s == 'nickname' }
|
|
366
|
+
raise ConfigurationError, "'saveRecipient' must be a Hash with an optional nickname."
|
|
367
|
+
end
|
|
368
|
+
|
|
369
|
+
nickname = value.find { |key, _| key.to_s == 'nickname' }&.last
|
|
370
|
+
nickname.nil? || nickname == '' ? {} : { 'nickname' => nickname!(nickname) }
|
|
371
|
+
end
|
|
372
|
+
|
|
257
373
|
def self.check_description!(value)
|
|
258
374
|
return if value.is_a?(String) && value.length <= BANK_TRANSFER_DESCRIPTION_MAX
|
|
259
375
|
|
|
@@ -297,8 +413,9 @@ module Lunixi
|
|
|
297
413
|
RouteResponse.page(@client.request(route['method'], route['path'], query: query))
|
|
298
414
|
end
|
|
299
415
|
|
|
300
|
-
def post(name, body)
|
|
301
|
-
|
|
416
|
+
def post(name, body, params: {})
|
|
417
|
+
route = BANK_TRANSFER_ROUTES.fetch(name)
|
|
418
|
+
RouteResponse.unwrap(@client.request(route['method'], RouteRequest.path!(route['path'], params), body: body))
|
|
302
419
|
end
|
|
303
420
|
|
|
304
421
|
# 1 + max_retries attempts with the same key and body; a network error or a 5xx is retried, anything
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Lunixi
|
|
4
|
-
# Local checks of the bank-connect read filters (BANK_CONNECT_FILTERS) and of the transfer and
|
|
5
|
-
# filters (BANK_TRANSFER_ROUTES query lists). Not a public API
|
|
4
|
+
# Local checks of the bank-connect read filters (BANK_CONNECT_FILTERS) and of the transfer, recipient and
|
|
5
|
+
# FX list filters (BANK_TRANSFER_ROUTES query lists). Not a public API; the POS account filters are in
|
|
6
|
+
# BankPosFilters.
|
|
6
7
|
module BankConnectFilters
|
|
7
8
|
DAY_SECONDS = 24 * 60 * 60
|
|
8
9
|
AMOUNT_FILTERS = %w[minAmountMinor maxAmountMinor].freeze
|
|
@@ -21,7 +22,7 @@ module Lunixi
|
|
|
21
22
|
query
|
|
22
23
|
end
|
|
23
24
|
|
|
24
|
-
# The query of listTransfers / listFxOrders.
|
|
25
|
+
# The query of listTransfers / listFxOrders / listTransferRecipients.
|
|
25
26
|
def transfer_query!(filters, route)
|
|
26
27
|
given = RouteRequest.wire_keys!(filters || {}, BANK_TRANSFER_ROUTES.fetch(route)['query'], 'bank-connect transfer', 'filter')
|
|
27
28
|
given.each_with_object({}) do |(key, value), out|
|
|
@@ -48,10 +49,19 @@ module Lunixi
|
|
|
48
49
|
when 'limit', 'cursor' then page_value(key, value)
|
|
49
50
|
when 'status' then list_of(key, value, route == 'listFxOrders' ? BankFxOrderStatus::ALL : BankTransferStatus::ALL)
|
|
50
51
|
when 'accountId' then RouteValue.text!(value, key)
|
|
52
|
+
when 'q' then search(value)
|
|
51
53
|
else RouteValue.iso_time!(value, key)
|
|
52
54
|
end
|
|
53
55
|
end
|
|
54
56
|
|
|
57
|
+
def search(value)
|
|
58
|
+
unless value.is_a?(String) && !value.strip.empty? && value.strip.length <= BANK_TRANSFER_RECIPIENT_SEARCH_MAX
|
|
59
|
+
raise ConfigurationError, "'q' must be 1-#{BANK_TRANSFER_RECIPIENT_SEARCH_MAX} characters."
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
value.strip
|
|
63
|
+
end
|
|
64
|
+
|
|
55
65
|
def page_value(key, value)
|
|
56
66
|
if key == 'limit'
|
|
57
67
|
unless value.is_a?(Integer) && value.between?(1, BANK_CONNECT_MAX_LIMIT)
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Lunixi
|
|
4
|
+
# bank_connect.pos_accounts: your merchant (acquiring) records at a connected bank
|
|
5
|
+
# (/api/v1/bank-connect/pos-accounts) — merchant accounts, terminals, POS transactions, the value date
|
|
6
|
+
# calendar and the end-of-day summary.
|
|
7
|
+
#
|
|
8
|
+
# These are the bank's records: every terminal of yours at the bank is included (other devices, virtual
|
|
9
|
+
# POS, e-commerce). They are read only on a connection whose capabilities has POS_ACQUIRING. Card
|
|
10
|
+
# numbers are masked; amounts are minor-unit strings; a field without a value is nil.
|
|
11
|
+
#
|
|
12
|
+
# Scopes: bank-connect:view for accounts, terminals and request_sync; bank-connect:transactions:view for
|
|
13
|
+
# transactions, the statement and the day summary. Every call is signed, reads included. 404
|
|
14
|
+
# bank_connect.acquiring_account.not_found for an unknown POS account; 400
|
|
15
|
+
# bank_connect.acquiring.range_invalid for a range the service rejects. Filters are checked against
|
|
16
|
+
# BANK_POS_FILTERS before anything is sent.
|
|
17
|
+
class BankConnectPosAccounts
|
|
18
|
+
BASE = '/api/v1/bank-connect/pos-accounts'
|
|
19
|
+
|
|
20
|
+
def initialize(client)
|
|
21
|
+
@client = client
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Your POS accounts. connectionId narrows to one connection.
|
|
25
|
+
def list_accounts(**filters)
|
|
26
|
+
page('', 'listPosAccounts', filters)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def iterate_accounts(**filters, &block)
|
|
30
|
+
RouteResponse.each_item(filters, block) { |query| list_accounts(**query) }
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# 404 bank_connect.acquiring_account.not_found for an unknown POS account.
|
|
34
|
+
def get_account(pos_account_id)
|
|
35
|
+
read(account_path(pos_account_id))
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def list_terminals(pos_account_id, **filters)
|
|
39
|
+
page("#{account_path(pos_account_id)}/terminals", 'listPosTerminals', filters)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def iterate_terminals(pos_account_id, **filters, &block)
|
|
43
|
+
RouteResponse.each_item(filters, block) { |query| list_terminals(pos_account_id, **query) }
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# POS transactions (bank-connect:transactions:view). from (inclusive) / to (exclusive) filter on the
|
|
47
|
+
# transaction time: a Time or an ISO 8601 string with a time zone, at most 92 days apart; without them
|
|
48
|
+
# the last 30 days. type takes one value or an Array of BankPosTransactionType. minAmountMinor /
|
|
49
|
+
# maxAmountMinor are non-negative minor-unit strings. provisional true returns only intraday rows,
|
|
50
|
+
# false only final ones; an intraday row is updated in place by the bank's end-of-day record.
|
|
51
|
+
def list_transactions(pos_account_id, **filters)
|
|
52
|
+
page("#{account_path(pos_account_id)}/transactions", 'listPosTransactions', filters)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def iterate_transactions(pos_account_id, **filters, &block)
|
|
56
|
+
RouteResponse.each_item(filters, block) { |query| list_transactions(pos_account_id, **query) }
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# The value date calendar: amounts to be credited per value date (gross, commission, service fee,
|
|
60
|
+
# net), oldest value date first. from / to are YYYY-MM-DD value dates, both inclusive; without from
|
|
61
|
+
# today, without to 60 days after today.
|
|
62
|
+
def list_statement(pos_account_id, **filters)
|
|
63
|
+
page("#{account_path(pos_account_id)}/statement", 'listPosStatement', filters)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def iterate_statement(pos_account_id, **filters, &block)
|
|
67
|
+
RouteResponse.each_item(filters, block) { |query| list_statement(pos_account_id, **query) }
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# End-of-day status and totals of one day (YYYY-MM-DD, Turkey time).
|
|
71
|
+
def get_day_summary(pos_account_id, business_date)
|
|
72
|
+
day = BankPosFilters.day!(business_date, 'businessDate')
|
|
73
|
+
read("#{account_path(pos_account_id)}/days/#{day}")
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# Brings the intraday read forward (no body, no Idempotency-Key). SCHEDULED with scheduledAt when the
|
|
77
|
+
# bank's read interval has not passed; a request while one is waiting joins it (coalesced: true).
|
|
78
|
+
def request_sync(pos_account_id)
|
|
79
|
+
RouteResponse.unwrap(@client.request('POST', "#{BASE}#{account_path(pos_account_id)}/sync"))
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def inspect
|
|
83
|
+
'#<Lunixi::BankConnectPosAccounts>'
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
private
|
|
87
|
+
|
|
88
|
+
def page(path, route, filters)
|
|
89
|
+
RouteResponse.page(@client.request('GET', BASE + path, query: BankPosFilters.query!(filters, route)))
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def read(path)
|
|
93
|
+
RouteResponse.unwrap(@client.request('GET', BASE + path))
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def account_path(pos_account_id)
|
|
97
|
+
"/#{RouteRequest.path!(':posAccountId', 'posAccountId' => pos_account_id)}"
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# Local checks of the POS account filters (BANK_POS_FILTERS). Not a public API.
|
|
102
|
+
module BankPosFilters
|
|
103
|
+
DAY = /\A[0-9]{4}-[0-9]{2}-[0-9]{2}\z/
|
|
104
|
+
|
|
105
|
+
module_function
|
|
106
|
+
|
|
107
|
+
# The query of a POS account list: unknown filters, a type outside BankPosTransactionType, a bad card
|
|
108
|
+
# brand, a negative or malformed amount, a non-boolean provisional, limit outside 1–100 or a from … to
|
|
109
|
+
# window over 92 days raise ConfigurationError. The statement's from / to are YYYY-MM-DD value dates.
|
|
110
|
+
def query!(filters, route)
|
|
111
|
+
given = RouteRequest.wire_keys!(filters || {}, BANK_POS_FILTERS.fetch(route), 'POS account', 'filter')
|
|
112
|
+
query = given.each_with_object({}) do |(key, value), out|
|
|
113
|
+
out[key] = filter_value(key, value, route) if RouteRequest.present?(value)
|
|
114
|
+
end
|
|
115
|
+
check_window!(query) if route == 'listPosTransactions'
|
|
116
|
+
query
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
# A YYYY-MM-DD date (trimmed).
|
|
120
|
+
def day!(value, field)
|
|
121
|
+
raise ConfigurationError, "'#{field}' must be a date in YYYY-MM-DD form." unless value.is_a?(String) && value.strip.match?(DAY)
|
|
122
|
+
|
|
123
|
+
value.strip
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def filter_value(key, value, route)
|
|
127
|
+
case key
|
|
128
|
+
when 'limit', 'cursor' then BankConnectFilters.page_value(key, value)
|
|
129
|
+
when 'connectionId', 'terminalId' then RouteValue.text!(value, key)
|
|
130
|
+
when 'from', 'to' then route == 'listPosStatement' ? day!(value, key) : RouteValue.iso_time!(value, key)
|
|
131
|
+
when 'type' then BankConnectFilters.list_of(key, value, BankPosTransactionType::ALL)
|
|
132
|
+
when 'cardBrand' then card_brand(value)
|
|
133
|
+
when 'provisional'
|
|
134
|
+
raise ConfigurationError, "'provisional' must be true or false." unless [true, false].include?(value)
|
|
135
|
+
|
|
136
|
+
value.to_s
|
|
137
|
+
else BankConnectFilters.amount(key, value)
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
def card_brand(value)
|
|
142
|
+
unless value.is_a?(String) && value.strip.match?(BANK_POS_CARD_BRAND_PATTERN)
|
|
143
|
+
raise ConfigurationError, "'cardBrand' must be a card brand such as VISA, MASTERCARD, TROY or AMEX."
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
value.strip
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
# When both are readable from <= to and at most 92 days apart; minAmountMinor <= maxAmountMinor.
|
|
150
|
+
def check_window!(query)
|
|
151
|
+
from = RouteValue.instant(query['from'])
|
|
152
|
+
to = RouteValue.instant(query['to'])
|
|
153
|
+
if from && to
|
|
154
|
+
raise ConfigurationError, "'from' must not be after 'to'." if from > to
|
|
155
|
+
if to - from > BANK_POS_TRANSACTION_RANGE_MAX_DAYS * BankConnectFilters::DAY_SECONDS
|
|
156
|
+
raise ConfigurationError, "'from' and 'to' may be at most #{BANK_POS_TRANSACTION_RANGE_MAX_DAYS} days apart."
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
return unless query.key?('minAmountMinor') && query.key?('maxAmountMinor')
|
|
160
|
+
return unless query['minAmountMinor'].to_i > query['maxAmountMinor'].to_i
|
|
161
|
+
|
|
162
|
+
raise ConfigurationError, "'minAmountMinor' must not be greater than 'maxAmountMinor'."
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
end
|