Skip to content

Commit

Permalink
Create InitThreeDsPreauthPayment.js (#169)
Browse files Browse the repository at this point in the history
  • Loading branch information
emirgundem authored and lemiorhan committed Feb 19, 2024
1 parent e953881 commit cb13208
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions samples/payment/InitThreeDsPreauthPayment.js
Original file line number Diff line number Diff line change
@@ -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));

0 comments on commit cb13208

Please sign in to comment.