forked from gfortaine/payline-typescript-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sandbox.js
36 lines (30 loc) · 1.39 KB
/
sandbox.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const {
Payline,
PaylineWeb,
PaylineWalletManagement,
PaylineDoWebPaymentRequest,
PaylineGetCardsRequest,
PaylineCurrency,
PaylineAction,
PaylineDeliveryMode,
PaylineMode,
} = require("./dist");
// prepare payline configuration
const isProduction = false;
const isDebug = true;
const paylineConfig = new Payline("YOUR_MERCHANT_ID", "YOUR_KEY_SECRET", "YOUR_CONTRACT_NUMBER", {}, isProduction, isDebug);
const paylineWebService = new PaylineWeb(paylineConfig);
const paylineWalletService = new PaylineWalletManagement(paylineConfig)
// <------ GET CARDS ------>
const getCardsRequest = new PaylineGetCardsRequest();
getCardsRequest.walletId = 'wallet_7cd624ab18884013bd57cc5ea3436fb6';
true && paylineWalletService.getCards(getCardsRequest);
// <------ DO WEB PAYMENT ------>
const doWebPaymentRequest = new PaylineDoWebPaymentRequest("YOUR_ORDER_REFERENCE_ID")
.setClientDetails("[email protected]", "First name", "Last name")
.setCallbackUrls("https://www.your.website.com/returnUrl", "https://www.your.website.com/cancelUrl", "https://your.server.com/hook/payline")
.setAmount(1000, PaylineCurrency.EUR)
.setPaymentDetails(PaylineAction.AuthCapture, PaylineMode.FULL)
.setOrderDetails(PaylineDeliveryMode.Virtual)
.setWalletId("CUSTOMER_WALLET_ID"); // if needed, attach a walletId
false && paylineWebService.doWebPayment(doWebPaymentRequest);