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));