@ribpay/payline-typescript-sdk
Version:
Payline Typescript SDK
111 lines • 3.73 kB
JavaScript
import { PaylineBaseRequest } from "./payline-base-request.js";
import { PaylineOrder } from "../payline-order.js";
import { PaylineBuyer } from "../payline-buyer.js";
import { PaylineThreeDSInfo } from "../payline-three-ds-info.js";
import { PaylineUtils } from "../../services/payline-utils.js";
import { PaylinePayment } from "../payline-payment.js";
class PaylineDoWebPaymentRequest extends PaylineBaseRequest {
payment;
returnURL;
cancelURL;
order;
notificationURL;
selectedContractList;
secondSelectedContractList;
privateDataList = { privateData: [] }; // metadata
languageCode;
customPaymentPageCode;
buyer;
owner;
securityMode;
recurring;
customPaymentTemplateURL;
contractNumberWalletList;
merchantName;
subMerchant;
miscData;
asynchronousRetryTimeout;
threeDSInfo;
merchantScore;
constructor(orderRef) {
super();
this.buyer = new PaylineBuyer();
this.payment = new PaylinePayment();
this.order = new PaylineOrder();
this.order.ref = orderRef;
this.order.date = PaylineUtils.getPaylineNowDateFormat();
this.threeDSInfo = new PaylineThreeDSInfo();
}
changeContractNumber(contractNumber, force = false) {
if (!this.payment.contractNumber || force) {
this.payment.contractNumber = contractNumber;
if (!this.selectedContractList || this.selectedContractList.length === 0) {
this.selectedContractList = [{ selectedContract: contractNumber }];
}
}
return this;
}
setSelectedContracts(contractsNumber) {
this.selectedContractList = (contractsNumber || []).map(selectedContract => ({ selectedContract }));
return this;
}
setSecondSelectedContracts(contractsNumber) {
this.secondSelectedContractList = (contractsNumber || []).map(selectedContract => ({ selectedContract }));
return this;
}
setCallbackUrls(returnURL, cancelURL, notificationURL = null) {
this.returnURL = returnURL;
this.cancelURL = cancelURL;
this.notificationURL = notificationURL;
return this;
}
setAmount(amount, currency) {
this.payment.amount = amount;
this.payment.currency = currency;
this.order.amount = amount;
this.order.currency = currency;
return this;
}
setClientDetails(email, firstName, lastName) {
this.buyer.email = email;
this.buyer.firstName = firstName;
this.buyer.lastName = lastName;
return this;
}
setWalletId(walletId) {
this.buyer.walletId = walletId;
return this;
}
setPaymentDetails(action, mode, differedActionDate) {
this.payment.action = action.code;
this.payment.mode = mode;
if (differedActionDate) {
this.payment.differedActionDate = differedActionDate;
}
return this;
}
setOrderDetails(deliveryMode, country = "fr", details = null) {
this.order.deliveryMode = deliveryMode.code;
this.order.country = country;
this.order.details = details;
return this;
}
setMerchantName(merchantName) {
this.merchantName = merchantName;
return this;
}
setThreeDSInfo(challengeInd) {
this.threeDSInfo.challengeInd = challengeInd.code;
return this;
}
setPrivateDataList(privateDataList) {
this.privateDataList = privateDataList;
return this;
}
setCustomPageCode(code) {
this.customPaymentPageCode = code;
return this;
}
}
export { PaylineDoWebPaymentRequest };
//# sourceMappingURL=payline-do-web-payment-request.js.map