From c8ee498d203bc506912105ec7a98983e97b31484 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ertu=C4=9Frul=20Berat=20ALLAHVERD=C4=B0?= Date: Thu, 22 Jan 2026 11:19:42 +0300 Subject: [PATCH 1/2] Added Tokenflex APM --- .../payment/CompleteTokenflexApmPayment.js | 16 +++++++++ .../CompleteTokenflexGiftApmPayment.js | 16 +++++++++ samples/payment/InitTokenflexApmPayment.js | 36 +++++++++++++++++++ .../payment/InitTokenflexGiftApmPayment.js | 36 +++++++++++++++++++ src/model/ApmType.ts | 4 ++- src/model/PaymentProvider.ts | 3 +- 6 files changed, 109 insertions(+), 2 deletions(-) create mode 100644 samples/payment/CompleteTokenflexApmPayment.js create mode 100644 samples/payment/CompleteTokenflexGiftApmPayment.js create mode 100644 samples/payment/InitTokenflexApmPayment.js create mode 100644 samples/payment/InitTokenflexGiftApmPayment.js diff --git a/samples/payment/CompleteTokenflexApmPayment.js b/samples/payment/CompleteTokenflexApmPayment.js new file mode 100644 index 0000000..509ee80 --- /dev/null +++ b/samples/payment/CompleteTokenflexApmPayment.js @@ -0,0 +1,16 @@ +const Craftgate = require('../../dist'); + +const craftgate = new Craftgate.Client({ + apiKey: 'api-key', + secretKey: 'secret-key', + baseUrl: 'https://sandbox-api.craftgate.io' +}); + +const request = { + paymentId: 1, + additionalParams: {"otpCode": "784294"} +}; + +craftgate.payment().completeApmPayment(request) + .then(result => console.info('Tokenflex Apm complete payment successful', result)) + .catch(err => console.error('Failed to complete Tokenflex Apm payment', err)); diff --git a/samples/payment/CompleteTokenflexGiftApmPayment.js b/samples/payment/CompleteTokenflexGiftApmPayment.js new file mode 100644 index 0000000..aadc895 --- /dev/null +++ b/samples/payment/CompleteTokenflexGiftApmPayment.js @@ -0,0 +1,16 @@ +const Craftgate = require('../../dist'); + +const craftgate = new Craftgate.Client({ + apiKey: 'api-key', + secretKey: 'secret-key', + baseUrl: 'https://sandbox-api.craftgate.io' +}); + +const request = { + paymentId: 1, + additionalParams: {"otpCode": "784294"} +}; + +craftgate.payment().completeApmPayment(request) + .then(result => console.info('Tokenflex Gift Apm complete payment successful', result)) + .catch(err => console.error('Failed to complete Tokenflex Gift Apm payment', err)); diff --git a/samples/payment/InitTokenflexApmPayment.js b/samples/payment/InitTokenflexApmPayment.js new file mode 100644 index 0000000..f1c3e2e --- /dev/null +++ b/samples/payment/InitTokenflexApmPayment.js @@ -0,0 +1,36 @@ +const Craftgate = require('../../dist'); + +const craftgate = new Craftgate.Client({ + apiKey: 'api-key', + secretKey: 'secret-key', + baseUrl: 'https://sandbox-api.craftgate.io' +}); + +const request = { + apmType: Craftgate.Model.ApmType.Tokenflex, + price: 1.0, + paidPrice: 1.0, + currency: Craftgate.Model.Currency.TRY, + paymentGroup: Craftgate.Model.PaymentGroup.ListingOrSubscription, + conversationId: '456d1297-908e-4bd6-a13b-4be31a6e47d5', + callbackUrl: 'https://www.your-website.com/craftgate-apm-callback', + additionalParams: { + paymentCode: 123456 + }, + items: [ + { + name: 'Item 1', + price: 0.4, + externalId: '123d1297-839e-4bd6-a13b-4be31a6e12a8' + }, + { + name: 'Item 2', + price: 0.6, + externalId: '789d1297-839e-4bd6-a13b-4be31a6e13f7' + } + ] +}; + +craftgate.payment().initApmPayment(request) + .then(result => console.info('Tokenflex Apm init payment successful', result)) + .catch(err => console.error('Failed to init Tokenflex Apm payment', err)); diff --git a/samples/payment/InitTokenflexGiftApmPayment.js b/samples/payment/InitTokenflexGiftApmPayment.js new file mode 100644 index 0000000..32782cd --- /dev/null +++ b/samples/payment/InitTokenflexGiftApmPayment.js @@ -0,0 +1,36 @@ +const Craftgate = require('../../dist'); + +const craftgate = new Craftgate.Client({ + apiKey: 'api-key', + secretKey: 'secret-key', + baseUrl: 'https://sandbox-api.craftgate.io' +}); + +const request = { + apmType: Craftgate.Model.ApmType.TokenflexGift, + price: 1.0, + paidPrice: 1.0, + currency: Craftgate.Model.Currency.TRY, + paymentGroup: Craftgate.Model.PaymentGroup.ListingOrSubscription, + conversationId: '456d1297-908e-4bd6-a13b-4be31a6e47d5', + callbackUrl: 'https://www.your-website.com/craftgate-apm-callback', + additionalParams: { + paymentCode: 123456 + }, + items: [ + { + name: 'Item 1', + price: 0.4, + externalId: '123d1297-839e-4bd6-a13b-4be31a6e12a8' + }, + { + name: 'Item 2', + price: 0.6, + externalId: '789d1297-839e-4bd6-a13b-4be31a6e13f7' + } + ] +}; + +craftgate.payment().initApmPayment(request) + .then(result => console.info('Tokenflex Gift Apm init payment successful', result)) + .catch(err => console.error('Failed to init Tokenflex Gift Apm payment', err)); diff --git a/src/model/ApmType.ts b/src/model/ApmType.ts index 5174f43..bd21e16 100644 --- a/src/model/ApmType.ts +++ b/src/model/ApmType.ts @@ -4,8 +4,10 @@ enum ApmType { Sodexo = 'SODEXO', SodexoGift = 'SODEXO_GIFT', Edenred = 'EDENRED', - Setcard = 'SETCARD', EdenredGift = 'EDENRED_GIFT', + Tokenflex = 'TOKENFLEX', + TokenflexGift = 'TOKENFLEX_GIFT', + Setcard = 'SETCARD', Metropol = 'METROPOL', PayPal = 'PAYPAL', Klarna = 'KLARNA', diff --git a/src/model/PaymentProvider.ts b/src/model/PaymentProvider.ts index a5d7e79..2e56b49 100644 --- a/src/model/PaymentProvider.ts +++ b/src/model/PaymentProvider.ts @@ -8,8 +8,9 @@ enum PaymentProvider { Sodexo = 'SODEXO', Edenred = 'EDENRED', Metropol = 'METROPOL', + Tokenflex = 'TOKENFLEX', Kaspi = 'KASPI', - InstantTransfer = 'INSTANTA_TRANSFER', + InstantTransfer = 'INSTANT_TRANSFER', Tompay = 'TOMPAY', YkbWorldPay = 'YKB_WORLD_PAY', ApplePay = 'APPLEPAY', From db9eafa83a10e88b0f05abd02eb2786fa5b5094f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ertu=C4=9Frul=20Berat=20ALLAHVERD=C4=B0?= Date: Thu, 22 Jan 2026 11:48:37 +0300 Subject: [PATCH 2/2] update --- src/model/PaymentMethod.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/model/PaymentMethod.ts b/src/model/PaymentMethod.ts index 8094547..240f423 100644 --- a/src/model/PaymentMethod.ts +++ b/src/model/PaymentMethod.ts @@ -7,6 +7,8 @@ enum PaymentMethod { SodexoGift = 'SODEXO_GIFT', Edenred = 'EDENRED', EdenredGift = 'EDENRED_GIFT', + Tokenflex = 'TOKENFLEX', + TokenflexGift = 'TOKENFLEX_GIFT', Alipay = 'ALIPAY', Paypal = 'PAYPAL', Klarna = 'KLARNA',