From 9eeafe980478e562356639fbb08b937c60e377d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alican=20Akku=C5=9F?= Date: Fri, 9 Feb 2024 11:42:38 +0300 Subject: [PATCH 1/3] adds haso bnpl (#171) --- src/model/ApmType.ts | 3 ++- src/model/PaymentProvider.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/model/ApmType.ts b/src/model/ApmType.ts index 4eed7bf..cee037f 100644 --- a/src/model/ApmType.ts +++ b/src/model/ApmType.ts @@ -14,7 +14,8 @@ enum ApmType { CashOnDelivery = 'CASH_ON_DELIVERY', Maslak = 'MASLAK', ALFABANK = 'ALFABANK', - TomFinance = 'TOM_FINANCE' + TomFinance = 'TOM_FINANCE', + Haso = 'HASO' } export default ApmType; diff --git a/src/model/PaymentProvider.ts b/src/model/PaymentProvider.ts index 7025670..33398b4 100644 --- a/src/model/PaymentProvider.ts +++ b/src/model/PaymentProvider.ts @@ -12,7 +12,8 @@ enum PaymentProvider { YkbWorldPay = 'YKB_WORLD_PAY', ApplePay = 'APPLEPAY', GooglePay = 'GOOGLEPAY', - Stripe = 'STRIPE' + Stripe = 'STRIPE', + Haso = 'HASO' } export default PaymentProvider; From 277e711913a1e6f99efe462010a8f46a9a774e4d Mon Sep 17 00:00:00 2001 From: emircan gundem Date: Fri, 9 Feb 2024 12:16:01 +0300 Subject: [PATCH 2/3] Create InitThreeDsPreauthPayment.js (#169) --- samples/payment/InitThreeDsPreauthPayment.js | 48 ++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 samples/payment/InitThreeDsPreauthPayment.js diff --git a/samples/payment/InitThreeDsPreauthPayment.js b/samples/payment/InitThreeDsPreauthPayment.js new file mode 100644 index 0000000..05fbe93 --- /dev/null +++ b/samples/payment/InitThreeDsPreauthPayment.js @@ -0,0 +1,48 @@ +const Craftgate = require('@craftgate/craftgate'); + +const craftgate = new Craftgate.Client({ + apiKey: 'sandbox-YEhueLgomBjqsnvBlWVVuFsVhlvJlMHE', + secretKey: 'sandbox-tBdcdKVGmGupzfaWcULcwDLMoglZZvTz', + baseUrl: 'https://sandbox-api.craftgate.io' +}); + +const request = { + price: 100.0, + paidPrice: 100.0, + walletPrice: 0.0, + installment: 1, + conversationId: '456d1297-908e-4bd6-a13b-4be31a6e47d5', + currency: Craftgate.Model.Currency.TRY, + paymentGroup: Craftgate.Model.PaymentGroup.ListingOrSubscription, + callbackUrl: 'https://www.your-website.com/craftgate-3DSecure-callback', + paymentPhase: Craftgate.Model.PaymentPhase.PreAuth, + + card: { + cardHolderName: 'Haluk Demir', + cardNumber: '5258640000000001', + expireYear: '2044', + expireMonth: '07', + cvc: '000' + }, + items: [ + { + name: 'Item 1', + price: 30.0, + externalId: '123d1297-839e-4bd6-a13b-4be31a6e12a8' + }, + { + name: 'Item 2', + price: 50.0, + externalId: '789d1297-839e-4bd6-a13b-4be31a6e13f7' + }, + { + name: 'Item 3', + price: 20.0, + externalId: '3a1d1297-839e-4bd6-a13b-4be31a6e18e6' + } + ] +}; + +craftgate.payment().init3DSPayment(request) + .then(result => console.info('Init 3ds payment successful', result)) + .catch(err => console.error('Failed to init 3ds payment', err)); From 56a1cbcddc8510a5d4dc91a628f13f6b24ad1494 Mon Sep 17 00:00:00 2001 From: Beran Santur Date: Tue, 13 Feb 2024 15:40:10 +0300 Subject: [PATCH 3/3] Adds Juzdan integration to Node.js client (#173) --- samples/juzdan/InitJuzdanPayment.js | 33 +++++++++++++++++++++++ samples/juzdan/RetrieveJuzdanPayment.js | 13 +++++++++ src/CraftgateClient.ts | 7 +++++ src/adapter/JuzdanPaymentAdapter.ts | 20 ++++++++++++++ src/model/ClientType.ts | 6 +++++ src/model/index.ts | 4 ++- src/request/InitJuzdanPaymentRequest.ts | 24 +++++++++++++++++ src/response/InitJuzdanPaymentResponse.ts | 6 +++++ 8 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 samples/juzdan/InitJuzdanPayment.js create mode 100644 samples/juzdan/RetrieveJuzdanPayment.js create mode 100644 src/adapter/JuzdanPaymentAdapter.ts create mode 100644 src/model/ClientType.ts create mode 100644 src/request/InitJuzdanPaymentRequest.ts create mode 100644 src/response/InitJuzdanPaymentResponse.ts diff --git a/samples/juzdan/InitJuzdanPayment.js b/samples/juzdan/InitJuzdanPayment.js new file mode 100644 index 0000000..3a93f4a --- /dev/null +++ b/samples/juzdan/InitJuzdanPayment.js @@ -0,0 +1,33 @@ +const Craftgate = require("../../dist"); + +const craftgate = new Craftgate.Client({ + apiKey: "api-key", + secretKey: "secret-key", + baseUrl: "https://sandbox-api.craftgate.io" +}); + +const request = { + price: 100.0, + paidPrice: 100.0, + currency: Craftgate.Model.Currency.TRY, + paymentGroup: Craftgate.Model.PaymentGroup.ListingOrSubscription, + conversationId: '456d1297-908e-4bd6-a13b-4be31a6e47d5', + externalId: 'testExternalId', + callbackUrl: 'https://www.your-website.com/juzdan-payment-callback', + paymentPhase: Craftgate.Model.PaymentPhase.Auth, + paymentChannel: 'testPaymentChannel', + bankOrderId: 'testBankOrderID', + items: [ + { + name: 'Item 1', + price: 30.0, + externalId: '123d1297-839e-4bd6-a13b-4be31a6e12a8' + } + ], + clientType: Craftgate.Model.ClientType.W, + loanCampaignId: 1 +}; + +craftgate.juzdan().initJuzdanPayment(request) + .then(result => console.info("Juzdan Payment init successful, qrUrl is generated", result)) + .catch(err => console.error("Juzdan Payment init failed", err)); diff --git a/samples/juzdan/RetrieveJuzdanPayment.js b/samples/juzdan/RetrieveJuzdanPayment.js new file mode 100644 index 0000000..f28509b --- /dev/null +++ b/samples/juzdan/RetrieveJuzdanPayment.js @@ -0,0 +1,13 @@ +const Craftgate = require("../../dist"); + +const craftgate = new Craftgate.Client({ + apiKey: "api-key", + secretKey: "secret-key", + baseUrl: "https://sandbox-api.craftgate.io" +}); + +const referenceId = "testReferenceId" + +craftgate.juzdan().retrieveJuzdanPayment(referenceId) + .then(result => console.info("Retrieve Juzdan payment is successful", result)) + .catch(err => console.error("Retrieve Juzdan payment failed", err)); diff --git a/src/CraftgateClient.ts b/src/CraftgateClient.ts index cd9a54e..f8d6a62 100644 --- a/src/CraftgateClient.ts +++ b/src/CraftgateClient.ts @@ -14,6 +14,7 @@ import SettlementAdapter from './adapter/SettlementAdapter'; import SettlementReportingAdapter from './adapter/SettlementReportingAdapter'; import WalletAdapter from './adapter/WalletAdapter'; import {ClientCreationOptions} from './lib/HttpClient'; +import JuzdanPaymentAdapter from './adapter/JuzdanPaymentAdapter'; export default class CraftgateAdapter extends BaseAdapter { private _installmentAdapter: InstallmentAdapter; @@ -30,6 +31,7 @@ export default class CraftgateAdapter extends BaseAdapter { private _masterpassPaymentAdapter: MasterpassPaymentAdapter; private _bankAccountTrackingAdapter: BankAccountTrackingAdapter; private _merchantAdapter: MerchantAdapter; + private _juzdanPaymentAdapter: JuzdanPaymentAdapter; constructor(options: ClientCreationOptions) { super(options); @@ -47,6 +49,7 @@ export default class CraftgateAdapter extends BaseAdapter { this._masterpassPaymentAdapter = new MasterpassPaymentAdapter(options); this._bankAccountTrackingAdapter = new BankAccountTrackingAdapter(options); this._merchantAdapter = new MerchantAdapter(options); + this._juzdanPaymentAdapter = new JuzdanPaymentAdapter(options); } installment(): InstallmentAdapter { @@ -104,4 +107,8 @@ export default class CraftgateAdapter extends BaseAdapter { merchant(): MerchantAdapter { return this._merchantAdapter; } + + juzdan(): JuzdanPaymentAdapter { + return this._juzdanPaymentAdapter; + } } diff --git a/src/adapter/JuzdanPaymentAdapter.ts b/src/adapter/JuzdanPaymentAdapter.ts new file mode 100644 index 0000000..8afa697 --- /dev/null +++ b/src/adapter/JuzdanPaymentAdapter.ts @@ -0,0 +1,20 @@ +import {ClientCreationOptions} from '../lib/HttpClient'; + +import PaymentResponse from '../response/PaymentResponse'; +import BaseAdapter from './BaseAdapter'; +import InitJuzdanPaymentRequest from '../request/InitJuzdanPaymentRequest'; +import InitJuzdanPaymentResponse from '../response/InitJuzdanPaymentResponse'; + +export default class JuzdanPaymentAdapter extends BaseAdapter { + constructor(options: ClientCreationOptions) { + super(options); + } + + async initJuzdanPayment(request: InitJuzdanPaymentRequest): Promise { + return this._client.post('/payment/v1/juzdan-payments/init', request); + } + + async retrieveJuzdanPayment(referenceId: string): Promise { + return this._client.get(`/payment/v1/juzdan-payments/${referenceId}`); + } +} diff --git a/src/model/ClientType.ts b/src/model/ClientType.ts new file mode 100644 index 0000000..7b3536a --- /dev/null +++ b/src/model/ClientType.ts @@ -0,0 +1,6 @@ +enum ClientType { + W = 'W', + M = 'M' +} + +export default ClientType; diff --git a/src/model/index.ts b/src/model/index.ts index 8672458..09d65e2 100644 --- a/src/model/index.ts +++ b/src/model/index.ts @@ -49,6 +49,7 @@ import WalletTransactionRefundTransactionType from './WalletTransactionRefundTra import WalletTransactionType from './WalletTransactionType'; import WebhookEventType from './WebhookEventType'; import WebhookStatus from './WebhookStatus'; +import ClientType from './ClientType'; export = { AccountOwner, @@ -101,5 +102,6 @@ export = { PaymentAuthenticationType, PosUserType, PosOperationType, - CardBrand + CardBrand, + ClientType }; diff --git a/src/request/InitJuzdanPaymentRequest.ts b/src/request/InitJuzdanPaymentRequest.ts new file mode 100644 index 0000000..320a3ca --- /dev/null +++ b/src/request/InitJuzdanPaymentRequest.ts @@ -0,0 +1,24 @@ +import Currency from '../model/Currency'; +import PaymentGroup from '../model/PaymentGroup'; +import PaymentPhase from '../model/PaymentPhase'; +import PaymentItem from './dto/PaymentItem'; +import ClientType from '../model/ClientType'; + +type InitJuzdanPaymentRequest = { + price: number; + paidPrice: number; + currency: Currency; + paymentGroup: PaymentGroup; + conversationId?: string; + externalId?: string; + callbackUrl: string; + paymentPhase: PaymentPhase; + paymentChannel?: string; + buyerMemberId?: number; + bankOrderId?: string; + items: PaymentItem[]; + loanCampaignId?: number; + clientType: ClientType; +}; + +export default InitJuzdanPaymentRequest; diff --git a/src/response/InitJuzdanPaymentResponse.ts b/src/response/InitJuzdanPaymentResponse.ts new file mode 100644 index 0000000..6fe232b --- /dev/null +++ b/src/response/InitJuzdanPaymentResponse.ts @@ -0,0 +1,6 @@ +type InitJuzdanPaymentResponse = { + referenceId: string; + juzdanQrUrl: string; +}; + +export default InitJuzdanPaymentResponse;