From 23ba42d07eec77129828690252cd379871cff4af Mon Sep 17 00:00:00 2001 From: rodrigojara-cko Date: Tue, 3 Nov 2026 10:48:37 +0100 Subject: [PATCH 1/5] feat(payment-setups): type and document Tamara risk_assessment Document payment_methods.tamara (initialization and risk_assessment with its four fields, plus the readOnly status and flags) in the create and update JSDoc, add the Tamara and TamaraRiskAssessment declaration types, and cover both requests with unit tests on the literal wire keys. --- src/api/payment-setups/payment-setups.js | 33 +++++++ test/payment-setups/payment-setups-unit.js | 91 +++++++++++++++++++ .../api/payment-setups/payment-setups.d.ts | 27 +++++- 3 files changed, 150 insertions(+), 1 deletion(-) diff --git a/src/api/payment-setups/payment-setups.js b/src/api/payment-setups/payment-setups.js index 42eb7af7..11e5fb25 100644 --- a/src/api/payment-setups/payment-setups.js +++ b/src/api/payment-setups/payment-setups.js @@ -60,6 +60,24 @@ export default class PaymentSetups { * not an array despite the plural name), insurance (object, added 2026-09-08: type [string], company [string], * price [{ amount: number, currency: string (3-letter ISO) }]). * + * Tamara (per the `Tamara` spec): + * - payment_methods.tamara: optional Tamara, the Tamara payment method's details and configuration. + * The key is `tamara`. Fields you send: + * - initialization: The initialization state of the payment method. When you create a Payment Setup, + * this defaults to disabled. [Optional]. Enum: "disabled" "enabled". Default "disabled". + * - risk_assessment: Risk signals about the customer, forwarded to Tamara with the payment. + * [Optional]. Object: + * - premium_customer: Specifies whether the customer is a premium customer. [Optional]. boolean. + * - risk_score: The customer's risk score. [Optional]. integer. + * - order_count_last24h: The number of orders the customer has made in the last 24 hours. + * [Optional]. integer. + * - linked_device_count: The number of devices linked to the customer. [Optional]. integer. + * Fields the response returns (readOnly, do not send them): + * - status: The payment method status. [Optional]. readOnly. + * Enum: "unavailable" "action_required" "ready" "initialization_required" "invalid". + * - flags: The list of error codes or indicators that highlight missing or invalid information. + * [Optional]. readOnly. Array of string. + * * Cash App Pay and customer (per the `PaymentSetup` specs): * - payment_methods.cashapp: optional CashApp, the Cash App payment method's details and configuration. * The key is `cashapp`, one lowercase word (not `cash_app`, not `cashApp`). Fields you send: @@ -161,6 +179,21 @@ export default class PaymentSetups { * refundable, delivery_recipient, host; PaymentSetupAirline.ancillaries, delivery_recipient, * insurance, refundable, total_number_of_passengers, travel_type, trip_type. * + * Tamara (per the `Tamara` spec): + * - payment_methods.tamara: optional Tamara, the Tamara payment method's details and configuration. + * The key is `tamara`. Fields you send: + * - initialization: The initialization state of the payment method. When you create a Payment Setup, + * this defaults to disabled. [Optional]. Enum: "disabled" "enabled". Default "disabled". + * - risk_assessment: Risk signals about the customer, forwarded to Tamara with the payment. + * [Optional]. Object: + * - premium_customer: Specifies whether the customer is a premium customer. [Optional]. boolean. + * - risk_score: The customer's risk score. [Optional]. integer. + * - order_count_last24h: The number of orders the customer has made in the last 24 hours. + * [Optional]. integer. + * - linked_device_count: The number of devices linked to the customer. [Optional]. integer. + * The response also returns the readOnly status and flags. See `createAPaymentSetup` for their + * full description. + * * Cash App Pay and customer (per the `PaymentSetup` specs): * - payment_methods.cashapp: optional CashApp, the Cash App payment method's details and configuration. * The key is `cashapp`, one lowercase word (not `cash_app`, not `cashApp`). Fields you send: diff --git a/test/payment-setups/payment-setups-unit.js b/test/payment-setups/payment-setups-unit.js index 715186d4..203d3d22 100644 --- a/test/payment-setups/payment-setups-unit.js +++ b/test/payment-setups/payment-setups-unit.js @@ -3572,4 +3572,95 @@ describe('Unit::Payment-Setups', () => { expect(result.customer.merchant_account.last_payment_amount).to.equal(55.99); }); }); + + describe('Tamara initialization and risk_assessment', () => { + const host = 'https://123456789.api.sandbox.checkout.com'; + const setupId = 'psu_wmakpe4nrza3rv2vhtwzoszja'; + + const tamaraRequest = { + processing_channel_id: 'pc_aaaaaaaaaaaaaaaaaaaaaaaaaa', + amount: 1000, + currency: 'SAR', + payment_methods: { + tamara: { + initialization: 'enabled', + risk_assessment: { + premium_customer: false, + risk_score: 42, + order_count_last24h: 0, + linked_device_count: 2 + } + } + } + }; + + const setupResponse = { + id: setupId, + processing_channel_id: 'pc_aaaaaaaaaaaaaaaaaaaaaaaaaa', + amount: 1000, + currency: 'SAR', + payment_methods: { + tamara: { + status: 'ready', + flags: [], + ...tamaraRequest.payment_methods.tamara + } + } + }; + + const expectTamaraWireKeys = (received) => { + const wire = JSON.stringify(received); + expect(wire).to.include('"tamara":{"initialization":"enabled","risk_assessment":{'); + expect(wire).to.include('"premium_customer":false'); + expect(wire).to.include('"risk_score":42'); + expect(wire).to.include('"order_count_last24h":0'); + expect(wire).to.include('"linked_device_count":2'); + expect(wire).to.not.include('riskAssessment'); + expect(wire).to.not.include('orderCountLast24h'); + }; + + it('should send payment_methods.tamara with initialization and risk_assessment unchanged on create', async () => { + // Arrange + let received; + const scope = nock(host) + .post('/payments/setups', (body) => { + received = body; + return true; + }) + .reply(200, setupResponse); + + const cko = new Checkout('sk_test_xxx', { subdomain: '123456789' }); + + // Act + const result = await cko.paymentSetups.createAPaymentSetup(tamaraRequest); + + // Assert + expect(scope.isDone()).to.be.true; + expect(received).to.deep.equal(tamaraRequest); + expectTamaraWireKeys(received); + expect(result).to.deep.equal(setupResponse); + }); + + it('should send payment_methods.tamara with initialization and risk_assessment unchanged on update', async () => { + // Arrange + let received; + const scope = nock(host) + .put(`/payments/setups/${setupId}`, (body) => { + received = body; + return true; + }) + .reply(200, setupResponse); + + const cko = new Checkout('sk_test_xxx', { subdomain: '123456789' }); + + // Act + const result = await cko.paymentSetups.updateAPaymentSetup(setupId, tamaraRequest); + + // Assert + expect(scope.isDone()).to.be.true; + expect(received).to.deep.equal(tamaraRequest); + expectTamaraWireKeys(received); + expect(result).to.deep.equal(setupResponse); + }); + }); }); diff --git a/types/dist/api/payment-setups/payment-setups.d.ts b/types/dist/api/payment-setups/payment-setups.d.ts index 969a0ce9..54dff5af 100644 --- a/types/dist/api/payment-setups/payment-setups.d.ts +++ b/types/dist/api/payment-setups/payment-setups.d.ts @@ -158,9 +158,34 @@ export type CashApp = { action?: CashAppAction; }; -/** The payment methods of a Payment Setup. Only cashapp is typed here; other methods pass through. */ +/** Risk signals about the customer, forwarded to Tamara with the payment (Tamara.risk_assessment). */ +export type TamaraRiskAssessment = { + /** Specifies whether the customer is a premium customer. */ + premium_customer?: boolean; + /** The customer's risk score. Integer. */ + risk_score?: number; + /** The number of orders the customer has made in the last 24 hours. Integer. */ + order_count_last24h?: number; + /** The number of devices linked to the customer. Integer. */ + linked_device_count?: number; +}; + +/** The Tamara payment method's details and configuration (Tamara). Sent under payment_methods.tamara. */ +export type Tamara = { + /** The payment method status. Response only. */ + status?: PaymentSetupPaymentMethodStatus; + /** The list of error codes or indicators that highlight missing or invalid information. Response only. */ + flags?: string[]; + /** The initialization state of the payment method. Default "disabled". */ + initialization?: PaymentSetupPaymentMethodInitialization; + /** Risk signals about the customer, forwarded to Tamara with the payment. */ + risk_assessment?: TamaraRiskAssessment; +}; + +/** The payment methods of a Payment Setup. Only cashapp and tamara are typed here; other methods pass through. */ export type PaymentSetupPaymentMethods = { cashapp?: CashApp; + tamara?: Tamara; [paymentMethod: string]: unknown; }; From e0f97bbef4dddc6b48e0eaf104418e7f7d8827d2 Mon Sep 17 00:00:00 2001 From: rodrigojara-cko Date: Tue, 3 Nov 2026 13:26:16 +0100 Subject: [PATCH 2/5] test(payment-setups): read Tamara on get and confirm, add sandbox test Cover payment_methods.tamara on the get and confirm responses (status, flags, initialization and the four risk_assessment fields) and add an integration test that creates a Tamara payment setup, skipped when Tamara is not enabled on the sandbox channel. --- test/payment-setups/payment-setups-it.js | 33 +++++++++++++++ test/payment-setups/payment-setups-unit.js | 48 ++++++++++++++++++++++ 2 files changed, 81 insertions(+) diff --git a/test/payment-setups/payment-setups-it.js b/test/payment-setups/payment-setups-it.js index 99b78ed9..7c3790aa 100644 --- a/test/payment-setups/payment-setups-it.js +++ b/test/payment-setups/payment-setups-it.js @@ -231,6 +231,39 @@ describe('Integration::Payment-Setups', () => { expect(cashapp.customer_profile_sharing).to.equal(true); expect(cashapp.status).to.be.oneOf(["unavailable", "action_required", "ready", "initialization_required", "invalid"]); }); + + it('should create a Tamara payment setup with risk_assessment and read the tamara payment method', async function () { + const riskAssessment = { + premium_customer: false, + risk_score: 42, + order_count_last24h: 0, + linked_device_count: 2 + }; + const response = await cko.paymentSetups.createAPaymentSetup({ + processing_channel_id: processingChannelId, + amount: 1000, + currency: "SAR", + reference: `TEST-REF-TAMARA-${Date.now()}`, + payment_methods: { + tamara: { + initialization: "enabled", + risk_assessment: riskAssessment + } + } + }); + + if (!(response.available_payment_methods || []).includes("tamara")) { + this.test.title += ' (skipped: Tamara is not enabled on the sandbox processing channel)'; + this.skip(); + } + + const fetched = await cko.paymentSetups.getAPaymentSetup(response.id); + const tamara = fetched.payment_methods.tamara; + expect(tamara).to.be.an('object'); + expect(tamara.initialization).to.equal("enabled"); + expect(tamara.risk_assessment).to.deep.equal(riskAssessment); + expect(tamara.status).to.be.oneOf(["unavailable", "action_required", "ready", "initialization_required", "invalid"]); + }); }); describe('Error handling', () => { diff --git a/test/payment-setups/payment-setups-unit.js b/test/payment-setups/payment-setups-unit.js index 203d3d22..57231ff7 100644 --- a/test/payment-setups/payment-setups-unit.js +++ b/test/payment-setups/payment-setups-unit.js @@ -3662,5 +3662,53 @@ describe('Unit::Payment-Setups', () => { expectTamaraWireKeys(received); expect(result).to.deep.equal(setupResponse); }); + + it('should read tamara status, flags, initialization and risk_assessment from get', async () => { + // Arrange + const getResponse = { + ...setupResponse, + payment_methods: { + tamara: { ...setupResponse.payment_methods.tamara, status: 'action_required', flags: ['example_flag'] } + } + }; + const scope = nock(host) + .get(`/payments/setups/${setupId}`) + .reply(200, getResponse); + + const cko = new Checkout('sk_test_xxx', { subdomain: '123456789' }); + + // Act + const result = await cko.paymentSetups.getAPaymentSetup(setupId); + + // Assert + expect(scope.isDone()).to.be.true; + expect(result).to.deep.equal(getResponse); + const tamara = result.payment_methods.tamara; + expect(Object.keys(tamara)).to.have.lengthOf(4); + expect(tamara.status).to.equal('action_required'); + expect(tamara.flags).to.deep.equal(['example_flag']); + expect(tamara.initialization).to.equal('enabled'); + expect(Object.keys(tamara.risk_assessment)).to.have.lengthOf(4); + expect(tamara.risk_assessment.premium_customer).to.equal(false); + expect(tamara.risk_assessment.risk_score).to.equal(42); + expect(tamara.risk_assessment.order_count_last24h).to.equal(0); + expect(tamara.risk_assessment.linked_device_count).to.equal(2); + }); + + it('should confirm with "tamara" on payments/setups/{id}/confirm/tamara and read the tamara response', async () => { + // Arrange + const scope = nock(host) + .post(`/payments/setups/${setupId}/confirm/tamara`) + .reply(200, setupResponse); + + const cko = new Checkout('sk_test_xxx', { subdomain: '123456789' }); + + // Act + const result = await cko.paymentSetups.confirmAPaymentSetup(setupId, 'tamara'); + + // Assert + expect(scope.isDone()).to.be.true; + expect(result.payment_methods.tamara).to.deep.equal(setupResponse.payment_methods.tamara); + }); }); }); From abf34c409b163d9fd60ce7e0bc1a3681fad28fde Mon Sep 17 00:00:00 2001 From: rodrigojara-cko Date: Wed, 4 Nov 2026 09:24:23 +0100 Subject: [PATCH 3/5] test(payment-setups): stop expecting risk_assessment on the Tamara get --- test/payment-setups/payment-setups-it.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/payment-setups/payment-setups-it.js b/test/payment-setups/payment-setups-it.js index 7c3790aa..0644c779 100644 --- a/test/payment-setups/payment-setups-it.js +++ b/test/payment-setups/payment-setups-it.js @@ -261,7 +261,7 @@ describe('Integration::Payment-Setups', () => { const tamara = fetched.payment_methods.tamara; expect(tamara).to.be.an('object'); expect(tamara.initialization).to.equal("enabled"); - expect(tamara.risk_assessment).to.deep.equal(riskAssessment); + // The sandbox accepts risk_assessment on create but does not return it on get. expect(tamara.status).to.be.oneOf(["unavailable", "action_required", "ready", "initialization_required", "invalid"]); }); }); From 78e7c5211cf089ec61f2e845a1b548ab9c9ac4cc Mon Sep 17 00:00:00 2001 From: rodrigojara-cko Date: Wed, 4 Nov 2026 09:42:35 +0100 Subject: [PATCH 4/5] docs(payment-setups): document Tamara on get and confirm --- src/api/payment-setups/payment-setups.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/api/payment-setups/payment-setups.js b/src/api/payment-setups/payment-setups.js index 11e5fb25..99c79cd8 100644 --- a/src/api/payment-setups/payment-setups.js +++ b/src/api/payment-setups/payment-setups.js @@ -317,6 +317,17 @@ export default class PaymentSetups { * - customer_since: The date and time the customer's Cash App account was created. [Optional]. * Format: date-time. Returned as a string; the provider's format varies. * + * Tamara (per the `Tamara` spec), under payment_methods.tamara (key `tamara`): + * - status: The payment method status. [Optional]. readOnly. + * Enum: "unavailable" "action_required" "ready" "initialization_required" "invalid". + * - flags: The list of error codes or indicators that highlight missing or invalid information. + * [Optional]. readOnly. Array of string. + * - initialization: The initialization state of the payment method. [Optional]. + * Enum: "disabled" "enabled". Default "disabled". + * - risk_assessment: Risk signals about the customer, forwarded to Tamara with the payment. + * [Optional]. Part of the `Tamara` schema, but the sandbox does not return it on get. Its four + * fields are described on `createAPaymentSetup`. + * * The response's customer carries id, country (min 2 characters, max 2 characters), email, name, * tax_number, phone, device (locale, fingerprint, ipv4, ipv6, client, os) and merchant_account, * as described on `createAPaymentSetup`. @@ -365,6 +376,9 @@ export default class PaymentSetups { * subsequent response omits it. See `getAPaymentSetup` for its 13 fields and the 8 address fields. * - status, flags, initialization and customer_profile_sharing, as described on `getAPaymentSetup`. * + * Tamara (per the `Tamara` spec): the response's payment_methods.tamara carries status, flags, + * initialization and risk_assessment, as described on `getAPaymentSetup`. + * * The response's customer carries id, country (min 2 characters, max 2 characters), email, name, * tax_number, phone, device (locale, fingerprint, ipv4, ipv6, client, os) and merchant_account, * as described on `createAPaymentSetup`. From 89bca82d31c06ba39585953fa7dc98410acffd9e Mon Sep 17 00:00:00 2001 From: rodrigojara-cko Date: Wed, 4 Nov 2026 10:30:11 +0100 Subject: [PATCH 5/5] docs(payment-setups): list tamara as a confirm payment method example --- src/api/payment-setups/payment-setups.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api/payment-setups/payment-setups.js b/src/api/payment-setups/payment-setups.js index 99c79cd8..33819aa6 100644 --- a/src/api/payment-setups/payment-setups.js +++ b/src/api/payment-setups/payment-setups.js @@ -385,7 +385,7 @@ export default class PaymentSetups { * * @memberof PaymentSetups * @param {string} id - The unique identifier of the Payment Setup. - * @param {string} payment_method_name - The name of the payment method to process the payment with (e.g. "tabby", "klarna", "card", "cashapp"). + * @param {string} payment_method_name - The name of the payment method to process the payment with (e.g. "tabby", "klarna", "card", "cashapp", "tamara"). * @returns {Promise} A promise to the Confirm a Payment Setup response */ async confirmAPaymentSetup(id, payment_method_name) {