@playmoweb/payline-typescript-sdk
Version:
Payline Typescript SDK
97 lines • 3.25 kB
JavaScript
import { PaylineBaseRequest } from "./payline-base-request.js";
import { PaylineOrder } from "../payline-order.js";
import { PaylineBuyer } from "../payline-buyer.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 = {}; // metadata
languageCode;
customPaymentPageCode;
buyer;
owner;
securityMode;
reccuring;
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();
}
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;
}
setCustomPageCode(code) {
this.customPaymentPageCode = code;
return this;
}
}
export { PaylineDoWebPaymentRequest };
//# sourceMappingURL=payline-do-web-payment-request.js.map