From f2ac535523fd872df28d90b9bd99f6e73ae29638 Mon Sep 17 00:00:00 2001 From: Avni BALIKCI <108258717+abalikci@users.noreply.github.com> Date: Fri, 16 Dec 2022 09:03:32 +0300 Subject: [PATCH] adds afterpay client sample (#119) --- samples/payment/InitAfterpayApmPayment.js | 33 +++++++++++++++++++++++ src/model/ApmType.ts | 1 + 2 files changed, 34 insertions(+) create mode 100644 samples/payment/InitAfterpayApmPayment.js diff --git a/samples/payment/InitAfterpayApmPayment.js b/samples/payment/InitAfterpayApmPayment.js new file mode 100644 index 0000000..d849c60 --- /dev/null +++ b/samples/payment/InitAfterpayApmPayment.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 = { + apmType: Craftgate.Model.ApmType.Afterpay, + price: 1.0, + paidPrice: 1.0, + currency: Craftgate.Model.Currency.USD, + paymentGroup: Craftgate.Model.PaymentGroup.ListingOrSubscription, + conversationId: '456d1297-908e-4bd6-a13b-4be31a6e47d5', + callbackUrl: 'https://www.your-website.com/craftgate-apm-callback', + 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('Afterpay Apm init payment successful', result)) + .catch(err => console.error('Failed to init Afterpay Apm payment', err)); diff --git a/src/model/ApmType.ts b/src/model/ApmType.ts index 65ae13e..be361ec 100644 --- a/src/model/ApmType.ts +++ b/src/model/ApmType.ts @@ -4,6 +4,7 @@ enum ApmType { Sodexo = 'SODEXO', Edenred = 'EDENRED', PayPal = 'PAYPAL', + Afterpay = 'AFTERPAY', FundTransfer = 'FUND_TRANSFER', CashOnDelivery = 'CASH_ON_DELIVERY' }