lunixi-sdk 2.0.2 → 2.3.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.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +28 -0
  3. data/README.md +43 -4
  4. data/README.tr.md +28 -3
  5. data/docs/card-rewards.md +21 -0
  6. data/lib/lunixi/bank_connect.rb +132 -15
  7. data/lib/lunixi/bank_connect_filters.rb +13 -3
  8. data/lib/lunixi/bank_connect_pos.rb +165 -0
  9. data/lib/lunixi/bank_connect_values.rb +127 -5
  10. data/lib/lunixi/card_requests.rb +9 -1
  11. data/lib/lunixi/client.rb +38 -14
  12. data/lib/lunixi/direct_method_payment_request.rb +24 -2
  13. data/lib/lunixi/errors.rb +49 -0
  14. data/lib/lunixi/fraud.rb +3 -2
  15. data/lib/lunixi/fraud_uk_claims.rb +127 -0
  16. data/lib/lunixi/fraud_values.rb +46 -0
  17. data/lib/lunixi/marketplace.rb +2 -0
  18. data/lib/lunixi/payment_link_rules.rb +13 -1
  19. data/lib/lunixi/payment_link_values.rb +4 -0
  20. data/lib/lunixi/payment_links.rb +3 -1
  21. data/lib/lunixi/payment_values.rb +22 -2
  22. data/lib/lunixi/payments.rb +62 -6
  23. data/lib/lunixi/product_webhooks.rb +17 -1
  24. data/lib/lunixi/refund_to_wallet.rb +94 -0
  25. data/lib/lunixi/route_table.rb +10 -5
  26. data/lib/lunixi/routing_pin.rb +247 -0
  27. data/lib/lunixi/sanction.rb +77 -17
  28. data/lib/lunixi/sanction_batch.rb +215 -0
  29. data/lib/lunixi/sanction_values.rb +289 -5
  30. data/lib/lunixi/split_payment.rb +17 -2
  31. data/lib/lunixi/subscription_routing.rb +70 -0
  32. data/lib/lunixi/subscription_values.rb +26 -3
  33. data/lib/lunixi/subscriptions.rb +22 -2
  34. data/lib/lunixi/version.rb +1 -1
  35. data/lib/lunixi/wallet.rb +43 -7
  36. data/lib/lunixi/wallet_customer_sessions.rb +75 -0
  37. data/lib/lunixi/wallet_customer_tokens.rb +238 -0
  38. data/lib/lunixi/wallet_portal.rb +340 -0
  39. data/lib/lunixi/wallet_portal_routes.rb +171 -0
  40. data/lib/lunixi/wallet_routes.rb +28 -3
  41. data/lib/lunixi/wallet_rules.rb +131 -0
  42. data/lib/lunixi/wallet_values.rb +151 -0
  43. data/lib/lunixi.rb +12 -0
  44. metadata +14 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 73d1ce64a84a138f96e6544080db54e8fed28926a6f7494de342c526bfe1bd8d
4
- data.tar.gz: a9317c55a9380c04fc18854cbd9d86dcc228b1f27e1032f34b4eec27e5f0f1fd
3
+ metadata.gz: a49ede00de8d815ca3caedfbaa55b3c0274835bf5248fcc0832556e8e5715cfb
4
+ data.tar.gz: af2c21da9fc7e9c640864e946acd84e5e264f368d3654535f877a17080b61288
5
5
  SHA512:
6
- metadata.gz: 45e22e8ea9fc3bec466ae81ca048f7d1f0a8513c164c934cee2f4d93e8febcd9f93cdd78bf45ca55378b9017033efe404a604d5bbe35eb097684c0ec8de4a18f
7
- data.tar.gz: d74659f7ecbbcc7c3d95e40e299731ee8264d0f50dae98ad9ff58c548a25ba8e99514e3ced679ef7c83051224c841026e0c87527c0515ffa8261b1a6c59ee2b2
6
+ metadata.gz: 7d7940dc59fbba9f8c5408c9cb649361c16105b205dc3f5aba7064f4ab96957e3f70acc7364760539167dec7797251ab50b5d53910c0e611081234f9130e33d3
7
+ data.tar.gz: 9d4c4d24a52f0b47e82c32146926924408de946d775435e0129619dfd6e675ce924916ac62fcf3afbbd941bbacd055fdb43b1f8ba655ab39eeedce6708c35b6c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.3.0 — 2026-12-03
4
+
5
+ - Payments: refund to wallet. `payments.refund_to_wallet(payment_id, { amount:, reason:, programId:, customerId: }, idempotency_key:)` (`POST /api/v1/payments/{id}/refund-to-wallet`, permission `payment:refund-to-wallet`, signed, key required as for `refund`; `amount` a positive minor-unit string, left out = the remaining refundable amount and no body is sent; no wallet user found → the refund goes to the card; marketplace / split payments refused) and the read-only `payments.refund_to_wallet_eligibility(payment_id, { customerId:, programId: })` (`POST …/refund-to-wallet/eligibility`, no key, an empty request sends `{}`) → `{ eligible, matchedBy, matchStrength, maskedTarget, defaultDestination, reason }`. Keys are String or Symbol, camelCase or snake_case; other fields raise `ConfigurationError` before sending. New `Lunixi::REFUND_TO_WALLET_FIELDS`, `Lunixi::REFUND_TO_WALLET_ELIGIBILITY_FIELDS`, `Lunixi::RefundToWalletMatchStrength`, `Lunixi::RefundToWalletMatchedBy`, `Lunixi::RefundToWalletEligibilityReason`, `Lunixi::WALLET_PARTIAL_REFUND_UNSUPPORTED` (`payment.refund.wallet_partial_unsupported`: a payment paid with the wallet is refunded only in full).
6
+ - Wallet: `wallet.end_users.create` takes `customerContact: { email: }`; it pins the address the customer session code goes to (requires `externalCustomerId` and `accountType: PERSONAL`; checked before sending). The answer adds `customerContact` and `enrollment` (`Lunixi::WalletCustomerEnrollmentStatus`).
7
+ - Wallet: new `wallet.customer_sessions` (permission `wallet:customer-session:create`): `start` (Idempotency-Key required), `resend`, `complete`, `refresh`, `revoke` for `/api/v1/wallet/customer-sessions`, with `end_user_ip:` (`X-Lunixi-End-User-Ip`). Fields are checked before sending (`Lunixi::WALLET_CUSTOMER_SESSION_RULES`); there is no channel parameter. All five calls are sent once (no automatic retry after a 5xx or a network error) and none answers a 401 by sending again. `revoke` is a signed `DELETE` with the target in the query.
8
+ - Wallet: new portal client `wallet.portal(customer_key:, token_store:, refresh_skew_seconds: 30)` for the customer's own routes (`/api/portal/v1/wallet/me/*`, `Lunixi::WALLET_PORTAL_ROUTES`): every call carries `Authorization: Bearer <accessToken>` and the Ed25519 signature of the same key, never the merchant token. Bodies are taken whole and checked against the route table (an unknown field, or a key on a route that takes none, raises `ConfigurationError`). Account, balances, wallets, limits, KYC level, operations and receipts, card top-up, wallet-to-wallet transfer with the password + operation-code step-up, QR payment, payment code, loyalty, cashback, tier, phone verification by SMS and the wallet e-mail change (`start_email_change`, `get_email_change`, `resend_email_change`, `verify_current_email_change`, `complete_email_change`; a `reauthRequired: true` completion deletes the stored session). `end_user_ip:` / `with_end_user_ip` sends `X-Lunixi-End-User-Ip` on every portal call.
9
+ - Wallet: pluggable token store (`get` / `set` / `delete`, optional `with_lock`; you encrypt the records), `Lunixi::InMemoryWalletCustomerTokenStore`, and automatic refresh, one at a time per customer; a 409 `AUTH_REFRESH_IN_PROGRESS` waits for the other process (0.25 / 0.5 / 1 / 1.5 s) instead of sending the refresh token again.
10
+ - New errors `WalletCustomerSessionError` (`session_ended?`, `customer_key`), `WalletCustomerSessionBindingError`, `WalletCustomerRefreshReusedError`, `WalletCustomerSessionExpiredError`, `WalletCustomerSessionNotIssuedError`, `WalletCustomerRevokeIncompleteError`; values `WalletCustomerSessionErrorCode` (only the codes the gateway returns, `AUTH_UPSTREAM_ERROR` included), `WALLET_CUSTOMER_PASSWORD_POLICY_CODES`, `WalletCustomerSessionRevokeReason`, `WalletCustomerSessionDeliveryChannel`, `WalletCustomerSessionOtpPurpose`, `WalletCustomerIdentityStatus`, `WalletCustomerAttachStatus`.
11
+ - `Client#request` takes `bearer:`, `reauth:` and `end_user_ip:`.
12
+
13
+ ## 2.2.1 — 2026-12-03
14
+
15
+ - Development dependencies: `websocket-driver` 0.9.2 (0.8.2 has a critical advisory, GHSA-pf93-24xc-xgxc). The gem itself is unchanged.
16
+
17
+ ## 2.2.0 — 2026-12-03
18
+
19
+ - 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`.
20
+ - 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`).
21
+ - 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).
22
+
23
+ ## 2.1.0 — 2026-12-01
24
+
25
+ - 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`).
26
+ - 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`).
27
+ - 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`).
28
+ - 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.
29
+ - 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`).
30
+
3
31
  ## 2.0.2 — 2026-11-20
4
32
 
5
33
  - 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
@@ -96,6 +96,7 @@ The shared Lunixi form owns enabled payment methods and supports the methods con
96
96
  | Address dictionary | `reference.list_provinces`, `reference.list_districts(province_code)`, `reference.list_neighborhoods(district_code)` |
97
97
  | Capture/preauthorization | `payments.capture(id, idempotency_key:)` |
98
98
  | Full/partial refund | `payments.refund(id, idempotency_key:, reason: nil)` |
99
+ | Refund to wallet | `payments.refund_to_wallet(id, { amount:, reason:, programId:, customerId: }, idempotency_key:)` (POST `/payments/{id}/refund-to-wallet`, signed, permission `payment:refund-to-wallet`; a captured LIVE payment to the buyer's wallet; `customerId` = STRONG match, else the order's phone = WEAK; no wallet user → card; marketplace / split refused; empty request = remaining amount, no body), `payments.refund_to_wallet_eligibility(id, { customerId:, programId: })` (POST `…/refund-to-wallet/eligibility`, signed, read-only, no key) → `eligible`, `matchedBy`, `matchStrength`, `maskedTarget`, `defaultDestination` (`CARD`), `reason` |
99
100
  | Void authorization | `payments.void(id, idempotency_key:)` |
100
101
  | Split payment (1–5 legs) | `payments.split(body, idempotency_key:)` |
101
102
  | Split status/list/refund | `payments.get_split(id)`, `payments.list_splits(**filters)`, `payments.refund_split(id, amount:, idempotency_key:, reason: nil)` |
@@ -111,10 +112,11 @@ The shared Lunixi form owns enabled payment methods and supports the methods con
111
112
  | Physical POS payments | `physical_pos.create_payment(request, idempotency_key:)`, `create_reversal(payment_id, request, idempotency_key:)`, `cancel_payment`, `get_payment`, `list_payments`, `list_transactions`, `get_transaction`, `list_ambiguous_payments` |
112
113
  | Physical POS reports and end-of-day | `physical_pos.get_sales_summary`, `get_tax_summary`, `list_settlements`, `start_settlement(device_id, idempotency_key: nil)`, `list_settlement_runs`, `get_settlement_run` |
113
114
  | 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
- | Wallet | `wallet.ping`, `wallet.end_users`, `wallets`, `deposits`, `corporate`, `fees`, `transfers`, `withdrawals`, `operations`, `topups`, `payments`, `qr`, `bulk_payouts` |
115
+ | Wallet | `wallet.ping`, `wallet.end_users`, `wallets`, `deposits`, `corporate`, `fees`, `transfers`, `withdrawals`, `operations`, `topups`, `payments`, `qr`, `bulk_payouts`, `customer_sessions`, `wallet.portal` |
115
116
  | 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
- | Sanctions screening | `sanction.screen_name`, `screen_wallet`, `screen_account`, `screen_transaction`, `screen_public_procurement_ban`, `screen_adverse_media`, monitoring, entity intelligence, `list_blacklist_entries`, `Lunixi::Sanction.clear_screening?(result)` |
117
+ | 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` |
118
+ | 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) |
119
+ | 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
120
  | 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
121
  | 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
122
  | 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 |
@@ -278,6 +280,24 @@ lunixi.wallet.transfers.complete_w2w(step['operationId'], { endUserId: end_user_
278
280
 
279
281
  Money moves in two steps: `initiate_*` reserves the limit, `complete_*` commits it with the same `integrityHash` and `nonce` (the SDK puts `operationId` in the body). Lists return `Lunixi::ListPage` (`items`, `next_cursor`, `has_more?`); `iterate` walks every page. `qr.image` returns the image bytes. `end_users.freeze_end_user(end_user_id, ...)` freezes an end user (named so that `Object#freeze` keeps its meaning).
280
282
 
283
+ ### Customer session and portal
284
+
285
+ An end user created with `customerContact: { email: }` (requires `externalCustomerId` and `accountType: 'PERSONAL'`; the address is pinned for good) can open a merchant-vouched customer session. The key needs `wallet:customer-session:create`; a missing permission is 403 `auth.permission.forbidden`. The code goes to the pinned contact over the channel the platform picks: there is no channel parameter.
286
+
287
+ ```ruby
288
+ target = { programId: program_id, externalCustomerId: customer.id, clientInstanceId: installation_id }
289
+ started = lunixi.wallet.customer_sessions.start(target.merge(clientLabel: 'Mağaza: example.com', locale: 'tr'),
290
+ idempotency_key: login.key, end_user_ip: request.remote_ip)
291
+ tokens = lunixi.wallet.customer_sessions.complete(target.merge(challengeId: started['challengeId'], code: params[:code]))
292
+ portal = lunixi.wallet.portal(customer_key: "#{program_id}:#{customer.id}", token_store: MyEncryptedTokenStore.new)
293
+ portal.save_session(tokens)
294
+ portal.get_balances
295
+ ```
296
+
297
+ `start` requires an `Idempotency-Key`; `resend` and `complete` send one only when you pass it; `refresh` and `revoke` take none. All five calls are sent once (no automatic retry after a 5xx or a network error) and none answers a 401 by sending again. `revoke(target.merge(reason: Lunixi::WalletCustomerSessionRevokeReason::USER_DELETED))` is a signed `DELETE` with the target in the query. Fields are checked before sending (`Lunixi::WALLET_CUSTOMER_SESSION_RULES`: uuids, `clientInstanceId`, `clientLabel`, `locale`, `code` 4–10 digits, `password` 1–256, `newPassword` 8–256, `refreshToken`, `reason`); an unknown field such as `otpChannel` raises `ConfigurationError`.
298
+
299
+ `wallet.portal` calls `/api/portal/v1/wallet/me/*` (`/api/portal/v1/wallet/auth/email-change` too, `Lunixi::WALLET_PORTAL_ROUTES`; bodies are taken whole and checked against it: an unknown field, or a key on a route that takes none, raises `ConfigurationError`) with `Authorization: Bearer <accessToken>` and the signature of the same key; the merchant token is never sent. `end_user_ip:` (or `portal.with_end_user_ip(ip)`) sends the end user's IP as `X-Lunixi-End-User-Ip` on every call. The wallet e-mail change runs `start_email_change` (wallet password, a key of 16–64 `[A-Za-z0-9_-]`) → `verify_current_email_change` (code to the current address) → `complete_email_change` (code to the new address); its `reauthRequired: true` answer deletes the stored session (sign in again). The token store implements `get(customer_key)`, `set(customer_key, record)`, `delete(customer_key)` and, when several processes share it, `with_lock(customer_key) { … }`; encrypt the records yourself (`Lunixi::InMemoryWalletCustomerTokenStore` is for tests and single processes). The access token is refreshed `refresh_skew_seconds` (default 30) before it expires or after a 401 `AUTH_CUSTOMER_SESSION_INVALID`, one refresh at a time per customer; a 409 `AUTH_REFRESH_IN_PROGRESS` waits for the other process instead of sending the refresh token again. Errors: `WalletCustomerSessionExpiredError` and `WalletCustomerRefreshReusedError` (`session_ended?`: the record is deleted, start a new session), `WalletCustomerSessionBindingError` (signed with another key; the record is kept), `WalletCustomerSessionNotIssuedError` (503: start again), `WalletCustomerRevokeIncompleteError` (503: send the same revoke again). Codes are in `Lunixi::WalletCustomerSessionErrorCode`.
300
+
281
301
  ## Bank accounts, transfers and FX
282
302
 
283
303
  `client.bank_connect` reads your connected bank accounts, balances and transactions; bank connections are made in the Lunixi dashboard. Every call is signed and the key decides the environment. Filters are checked before sending: values in their sets, `limit` 1–100, at most 100 account ids, minor-unit strings for `minAmountMinor` / `maxAmountMinor`, and `bookedFrom` (inclusive) / `bookedTo` (exclusive) at most 92 days apart, `bookedTo` only with `bookedFrom`.
@@ -290,7 +310,7 @@ transfer = lunixi.bank_connect.transfers.create(
290
310
  )
291
311
  ```
292
312
 
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`.
313
+ `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
314
 
295
315
  ## Sanctions screening
296
316
 
@@ -303,6 +323,21 @@ review!(result) unless Lunixi::Sanction.clear_screening?(result)
303
323
 
304
324
  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
325
 
326
+ 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.
327
+
328
+ ```ruby
329
+ result = lunixi.sanction.screen_name(name: 'Customer Name', subjectType: 'person', nationality: 'TR')
330
+ risk = result['jurisdictionRisk'] # nil on older screenings
331
+ review!(result) if risk && risk['effect'] == Lunixi::SanctionJurisdictionRiskEffect::REVIEW
332
+ site = lunixi.sanction.screen_website(website: 'https://www.example.com/path', customerReference: customer.id,
333
+ idempotency_key: "site-check-#{customer.id}")
334
+ # site['domain'], site['hits'][i]['matchType'] (Lunixi::SanctionWebsiteMatchType), site['decision']
335
+ ```
336
+
337
+ 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.
338
+
339
+ 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.
340
+
306
341
  ## Insurance
307
342
 
308
343
  `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 +465,7 @@ Historical focused 0.1.2 verification: 24 Rails form/return/URL/CSP security tes
430
465
  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
466
 
432
467
  Before upgrading from 0.x, follow [the money-string migration](MIGRATION-1.0.md).
468
+
469
+ ### Card rewards
470
+
471
+ 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
@@ -94,6 +94,7 @@ HTTP 2xx, token, dönüş sayfası veya devam eden split durumu tahsilat kanıt
94
94
  | Adres sözlüğü | `reference.list_provinces`, `reference.list_districts(province_code)`, `reference.list_neighborhoods(district_code)` |
95
95
  | Capture | `payments.capture(id, idempotency_key:)` |
96
96
  | Tam/kısmi iade | `payments.refund(id, idempotency_key:, reason: nil)` |
97
+ | Cüzdana iade | `payments.refund_to_wallet(id, { amount:, reason:, programId:, customerId: }, idempotency_key:)` (POST `/payments/{id}/refund-to-wallet`, imzalı, `payment:refund-to-wallet` izni; tahsil edilmiş LIVE ödemeyi alıcının cüzdanına iade eder; `customerId` = STRONG eşleşme, yoksa siparişteki telefon = WEAK; cüzdan kullanıcısı bulunamazsa iade karta gider; marketplace / split ödemeler reddedilir; boş istek = kalan tutar, gövde gönderilmez), `payments.refund_to_wallet_eligibility(id, { customerId:, programId: })` (POST `…/refund-to-wallet/eligibility`, imzalı, salt okuma, anahtarsız) → `eligible`, `matchedBy`, `matchStrength`, `maskedTarget`, `defaultDestination` (`CARD`), `reason` |
97
98
  | Provizyon iptali | `payments.void(id, idempotency_key:)` |
98
99
  | Çoklu ödeme | `payments.split(body, idempotency_key:)` |
99
100
  | Split durum/liste/iade | `payments.get_split(id)`, `payments.list_splits(**filters)`, `payments.refund_split(id, amount:, idempotency_key:, reason: nil)` |
@@ -109,10 +110,11 @@ HTTP 2xx, token, dönüş sayfası veya devam eden split durumu tahsilat kanıt
109
110
  | Fiziki POS ödemeleri | `physical_pos.create_payment(request, idempotency_key:)`, `create_reversal(payment_id, request, idempotency_key:)`, `cancel_payment`, `get_payment`, `list_payments`, `list_transactions`, `get_transaction`, `list_ambiguous_payments` |
110
111
  | Fiziki POS raporları ve gün sonu | `physical_pos.get_sales_summary`, `get_tax_summary`, `list_settlements`, `start_settlement(device_id, idempotency_key: nil)`, `list_settlement_runs`, `get_settlement_run` |
111
112
  | 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
- | Cüzdan | `wallet.ping`, `wallet.end_users`, `wallets`, `deposits`, `corporate`, `fees`, `transfers`, `withdrawals`, `operations`, `topups`, `payments`, `qr`, `bulk_payouts` |
113
+ | Cüzdan | `wallet.ping`, `wallet.end_users`, `wallets`, `deposits`, `corporate`, `fees`, `transfers`, `withdrawals`, `operations`, `topups`, `payments`, `qr`, `bulk_payouts`, `customer_sessions`, `wallet.portal` |
113
114
  | 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
- | Yaptırım taraması | `sanction.screen_name`, `screen_wallet`, `screen_account`, `screen_transaction`, `screen_public_procurement_ban`, `screen_adverse_media`, izleme, varlık istihbaratı, `list_blacklist_entries`, `Lunixi::Sanction.clear_screening?(result)` |
115
+ | 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` |
116
+ | 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) |
117
+ | 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
118
  | 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
119
  | 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
120
  | 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 |
@@ -269,6 +271,14 @@ lunixi.wallet.transfers.complete_w2w(step['operationId'], { endUserId: end_user_
269
271
 
270
272
  Para iki adımda hareket eder: `initiate_*` limiti ayırır, `complete_*` aynı `integrityHash` ve `nonce` ile kesinleştirir (SDK `operationId` değerini gövdeye koyar). Listeler `Lunixi::ListPage` döndürür (`items`, `next_cursor`, `has_more?`); `iterate` bütün sayfaları gezer. `qr.image` görsel baytlarını döndürür. `end_users.freeze_end_user(end_user_id, ...)` bir son kullanıcıyı dondurur (`Object#freeze` anlamını korusun diye bu adı taşır).
271
273
 
274
+ ### Müşteri oturumu ve portal
275
+
276
+ `customerContact: { email: }` ile oluşturulan son kullanıcı (`externalCustomerId` ve `accountType: 'PERSONAL'` gerekir; adres kalıcı olarak sabitlenir) tüccar onaylı bir müşteri oturumu açabilir. Anahtarın `wallet:customer-session:create` yetkisi olmalıdır; eksik yetki 403 `auth.permission.forbidden` döner. Kod, platformun seçtiği kanaldan sabitlenen adrese gider; kanal parametresi yoktur.
277
+
278
+ `wallet.customer_sessions.start` `Idempotency-Key` ister; `resend` ve `complete` anahtarı yalnız verdiğinizde gönderir; `refresh` ve `revoke` anahtar almaz. Beş çağrının hepsi tek kez gönderilir (5xx veya ağ hatasında otomatik yeniden deneme yoktur) ve hiçbiri 401'i yeniden göndererek yanıtlamaz. `revoke` hedefi sorguda taşıyan imzalı bir `DELETE` isteğidir. Alanlar göndermeden önce denetlenir (`Lunixi::WALLET_CUSTOMER_SESSION_RULES`); `otpChannel` gibi bilinmeyen bir alan `ConfigurationError` oluşturur.
279
+
280
+ `wallet.portal(customer_key:, token_store:)` `/api/portal/v1/wallet/me/*` rotalarını (`Lunixi::WALLET_PORTAL_ROUTES`) `Authorization: Bearer <accessToken>` ve aynı anahtarın imzasıyla çağırır; tüccar token'ı gönderilmez. `end_user_ip:` (ya da `portal.with_end_user_ip(ip)`) son kullanıcının IP'sini her çağrıda `X-Lunixi-End-User-Ip` olarak gönderir. Cüzdan e-posta değişikliği `start_email_change` (cüzdan parolası, 16–64 karakterlik `[A-Za-z0-9_-]` anahtar) → `verify_current_email_change` (mevcut adrese giden kod) → `complete_email_change` (yeni adrese giden kod) sırasıyla yürür; `reauthRequired: true` yanıtı saklı oturumu siler (yeniden giriş gerekir). Jeton deposu `get`, `set`, `delete` ve birden fazla süreç paylaşıyorsa `with_lock(customer_key) { … }` uygular; kayıtları siz şifrelersiniz (`Lunixi::InMemoryWalletCustomerTokenStore` yalnız test ve tek süreç içindir). Erişim token'ı süresi dolmadan `refresh_skew_seconds` (varsayılan 30) önce ya da 401 `AUTH_CUSTOMER_SESSION_INVALID` sonrasında, müşteri başına tek seferde yenilenir; 409 `AUTH_REFRESH_IN_PROGRESS` aynı refresh token'ı yeniden göndermez, diğer sürecin kaydını bekler. Hatalar: `WalletCustomerSessionExpiredError` ve `WalletCustomerRefreshReusedError` (`session_ended?`: kayıt silinir, yeni oturum başlatın), `WalletCustomerSessionBindingError` (başka anahtarla imzalandı; kayıt korunur), `WalletCustomerSessionNotIssuedError` (503: yeniden başlatın), `WalletCustomerRevokeIncompleteError` (503: aynı revoke çağrısını yeniden gönderin).
281
+
272
282
  ## Banka hesapları, transferler ve döviz
273
283
 
274
284
  `client.bank_connect` bağlı banka hesaplarınızı, bakiyelerinizi ve hesap hareketlerinizi okur; banka bağlantıları Lunixi panelinden kurulur. Her çağrı imzalıdır ve ortamı anahtar belirler. Filtreler göndermeden önce denetlenir: kümelerindeki değerler, 1–100 arası `limit`, en fazla 100 hesap kimliği, `minAmountMinor` / `maxAmountMinor` için küçük birim string'leri, en fazla 92 gün arayla `bookedFrom` (dahil) / `bookedTo` (hariç) ve yalnız `bookedFrom` ile birlikte `bookedTo`.
@@ -294,6 +304,21 @@ review!(result) unless Lunixi::Sanction.clear_screening?(result)
294
304
 
295
305
  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
306
 
307
+ Ü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.
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
+ 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.
319
+
320
+ İ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.
321
+
297
322
  ## Sigorta
298
323
 
299
324
  `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.
@@ -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) and fx (Lunixi::BankConnectFx), for a
20
- # connection whose capabilities include OUTGOING_TRANSFER / FX_EXCHANGE.
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 bank chooses the rail;
133
- # Lunixi does not check the balance.
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
- # Creates an outgoing transfer (HTTP 201): { transfer, stepUp, replayed }. request: accountId,
146
- # receiverIban (TR IBAN, at most 42 characters), receiverName (2–140 characters), amountMinor (a
147
- # positive minor-unit string: "150075" = 1,500.75 TRY), optional currency, paymentPurpose and
148
- # description (at most 140 characters).
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
- def self.check_transfer!(body)
243
- raise ConfigurationError, "'receiverIban' must be at most #{BANK_TRANSFER_IBAN_MAX} characters." if body['receiverIban'].length > BANK_TRANSFER_IBAN_MAX
244
- unless body['receiverName'].length.between?(BANK_TRANSFER_RECEIVER_NAME_MIN, BANK_TRANSFER_RECEIVER_NAME_MAX)
245
- raise ConfigurationError, "'receiverName' must be #{BANK_TRANSFER_RECEIVER_NAME_MIN}-#{BANK_TRANSFER_RECEIVER_NAME_MAX} characters."
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
- RouteResponse.unwrap(@client.request('POST', BANK_TRANSFER_ROUTES.fetch(name)['path'], body: body))
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 FX list
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)