Skip to content

Commit

Permalink
adds afterpay client sample (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
abalikci authored Dec 16, 2022
1 parent 968a6cb commit f2ac535
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
33 changes: 33 additions & 0 deletions samples/payment/InitAfterpayApmPayment.js
Original file line number Diff line number Diff line change
@@ -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));
1 change: 1 addition & 0 deletions src/model/ApmType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ enum ApmType {
Sodexo = 'SODEXO',
Edenred = 'EDENRED',
PayPal = 'PAYPAL',
Afterpay = 'AFTERPAY',
FundTransfer = 'FUND_TRANSFER',
CashOnDelivery = 'CASH_ON_DELIVERY'
}
Expand Down

0 comments on commit f2ac535

Please sign in to comment.