UNPKG

@hipay/hipay-enterprise-sdk-nodejs

Version:

The HiPay Enterprise SDK for NodeJS is a library for developers who want to integrate HiPay Enterprise payment methods to any NodeJS platform.

263 lines (226 loc) 11.3 kB
'use strict'; const CommonRequest = require('./CommonRequest'); const InvalidArgumentException = require('../../Error/InvalidArgumentException'); const CustomerBillingInfoRequest = require('./Info/CustomerBillingInfoRequest'); const CustomerShippingInfoRequest = require('./Info/CustomerShippingInfoRequest'); const DeliveryShippingInfoRequest = require('./Info/DeliveryShippingInfoRequest'); const PreviousAuthInfo = require('./Model/ThreeDSTwo/PreviousAuthInfo'); const MerchantRiskStatement = require('./Model/ThreeDSTwo/MerchantRiskStatement'); const AccountInfo = require('./Model/ThreeDSTwo/AccountInfo'); const RecurringInfo = require('./Model/ThreeDSTwo/RecurringInfo'); class TransactionRequest extends CommonRequest { /** * @inheritDoc * * Common Request data to use with Order and Payment Page Requests * @param {Object} values * * --- Inherited from CommonRequest * @param {Object} [values.customData] Request's custom data * @param {Object} [values.source] Request's source data * @param {'AUTO'|'SAPI'|'CONS'|'PAGE'|'TPE'|'RTRY'|'MANU'|'PREF'|'REVI'|'CMS'|'SSDK'|'CSDK'} [values.source.source] Technical source of this call * @param {String} [values.source.integration_version] Integration version (version of the CMS module for example) * @param {String} [values.source.brand] Source Brand (CMS name or Site name) * @param {String} [values.source.brand_version] Version of the brand (version of your site) * @param {Object} [values.basket] Request's basket data * * @param {String} values.orderid Order unique id * @param {'Sale'|'Authorization'} [values.operation] Transaction type: Sale indicates that the transaction is automatically submitted for capture. Authorization indicates that this transaction is sent for authorization only. * @param {String} values.description The order short description * @param {String} [values.longDescription] Additional description for the order * @param {String} values.currency Base currency for the order. This three-character currency code complies with ISO 4217. * @param {Number} values.amount Total order amount * @param {Number} [values.shipping = 0] Order shipping fee. Defaults to 0. * @param {Number} [values.tax = 0] Order tax fee. Defaults to 0. * @param {Number} [values.taxRate = 0] Order tax rate. Defaults to 0. * @param {String} [values.cid] Customer id, defined by the merchant * @param {String} [values.ipaddr] IP Adress of the customer * @param {String} [values.acceptUrl] URL to redirect the customer after payment success * @param {String} [values.declineUrl] URL to redirect the customer after payment decline * @param {String} [values.pendingUrl] URL to redirect the customer after payment pending * @param {String} [values.exceptionUrl] URL to redirect the customer after system error * @param {String} [values.cancelUrl] URL to redirect the customer after cancellation by the customer * @param {String} [values.notifyUrl] URL to send the notifications to * @param {String} [values.httpAccept] This should contain the exact content of the HTTP ACCEPT header sent from the customer's browser. * @param {String} [values.httpUserAgent] This should contain the exact content of the HTTP User-Agent header sent from the customer's browser. * @param {String} [values.deviceFingerprint] This element should contain the value of the device fingerprint generated by the HiPay Front JS SDK. * @param {String} [values.language] Locale code of your customer. This will be used to display the next pages in the correct language. * @param {CustomerBillingInfoRequest} [values.customerBillingInfo] Billing information of the customer * @param {CustomerShippingInfoRequest} [values.customerShippingInfo] Shipping information of the customer * @param {DeliveryShippingInfoRequest} [values.deliveryInformation] Delivery information of this order * @param {PreviousAuthInfo} [values.previousAuthInfo] Previous Authentication info, for 3DS validation purposes * @param {MerchantRiskStatement} [values.merchantRiskStatement] Merchant risk information, for 3DS validation purposes * @param {AccountInfo} [values.accountInfo] Customer's account information, for 3DS validation purposes * @param {Number} [values.deviceChannel] Device Channel. See the Device Channel Enumeration * @param {RecurringInfo} [values.recurringInfo] Reccurent order information, for 3DS validation purposes * @param {Number} [values.requestId] The request ID * @param {String} [values.softDescriptor] Billing descriptor. */ constructor(values) { super(values); if (Object.hasOwn(values, 'orderid')) { this.orderid = values.orderid; } else { throw new InvalidArgumentException('Request must have an Order ID'); } if (Object.hasOwn(values, 'operation')) { this.operation = values.operation; } if (Object.hasOwn(values, 'description')) { this.description = values.description; } else { throw new InvalidArgumentException('Request must have a description'); } if (Object.hasOwn(values, 'longDescription')) { this.longDescription = values.longDescription; } if (Object.hasOwn(values, 'currency')) { this.currency = values.currency; } else { throw new InvalidArgumentException('Request must have a currency'); } if (Object.hasOwn(values, 'amount')) { this.amount = values.amount; } else { throw new InvalidArgumentException('Request must have an amount'); } if (Object.hasOwn(values, 'shipping')) { this.shipping = values.shipping; } if (Object.hasOwn(values, 'tax')) { this.tax = values.tax; } if (Object.hasOwn(values, 'taxRate')) { this.taxRate = values.taxRate; } if (Object.hasOwn(values, 'cid')) { this.cid = values.cid; } if (Object.hasOwn(values, 'ipaddr')) { this.ipaddr = values.ipaddr; } if (Object.hasOwn(values, 'acceptUrl')) { this.acceptUrl = values.acceptUrl; } if (Object.hasOwn(values, 'declineUrl')) { this.declineUrl = values.declineUrl; } if (Object.hasOwn(values, 'pendingUrl')) { this.pendingUrl = values.pendingUrl; } if (Object.hasOwn(values, 'exceptionUrl')) { this.exceptionUrl = values.exceptionUrl; } if (Object.hasOwn(values, 'cancelUrl')) { this.cancelUrl = values.cancelUrl; } if (Object.hasOwn(values, 'notifyUrl')) { this.notifyUrl = values.notifyUrl; } if (Object.hasOwn(values, 'httpAccept')) { this.httpAccept = values.httpAccept; } if (Object.hasOwn(values, 'httpUserAgent')) { this.httpUserAgent = values.httpUserAgent; } if (Object.hasOwn(values, 'deviceFingerprint')) { this.deviceFingerprint = values.deviceFingerprint; } if (Object.hasOwn(values, 'language')) { this.language = values.language; } if (Object.hasOwn(values, 'customerBillingInfo')) { if (values.customerBillingInfo instanceof CustomerBillingInfoRequest) { this.customerBillingInfo = values.customerBillingInfo; } else { this.customerBillingInfo = new CustomerBillingInfoRequest(values.customerBillingInfo); } } if (Object.hasOwn(values, 'customerShippingInfo')) { if (values.customerShippingInfo instanceof CustomerShippingInfoRequest) { this.customerShippingInfo = values.customerShippingInfo; } else { this.customerShippingInfo = new CustomerShippingInfoRequest(values.customerShippingInfo); } } if (Object.hasOwn(values, 'deliveryInformation')) { if (values.deliveryInformation instanceof DeliveryShippingInfoRequest) { this.deliveryInformation = values.deliveryInformation; } else { this.deliveryInformation = new DeliveryShippingInfoRequest(values.deliveryInformation); } } if (Object.hasOwn(values, 'previousAuthInfo')) { if (values.previousAuthInfo instanceof PreviousAuthInfo) { this.previousAuthInfo = values.previousAuthInfo; } else { this.previousAuthInfo = new PreviousAuthInfo(values.previousAuthInfo); } } if (Object.hasOwn(values, 'merchantRiskStatement')) { if (values.merchantRiskStatement instanceof MerchantRiskStatement) { this.merchantRiskStatement = values.merchantRiskStatement; } else { this.merchantRiskStatement = new MerchantRiskStatement(values.merchantRiskStatement); } } if (Object.hasOwn(values, 'accountInfo')) { if (values.accountInfo instanceof AccountInfo) { this.accountInfo = values.accountInfo; } else { this.accountInfo = new AccountInfo(values.accountInfo); } } if (Object.hasOwn(values, 'deviceChannel')) { this.deviceChannel = values.deviceChannel; } if (Object.hasOwn(values, 'recurringInfo')) { if (values.recurringInfo instanceof RecurringInfo) { this.recurringInfo = values.recurringInfo; } else { this.recurringInfo = new RecurringInfo(values.recurringInfo); } } if (Object.hasOwn(values, 'requestId')) { this.requestId = values.requestId; } if (Object.hasOwn(values, 'softDescriptor')) { this.softDescriptor = values.softDescriptor; } } initValues() { super.initValues(); this.orderid = null; this.operation = null; this.description = null; this.longDescription = null; this.currency = null; this.amount = null; this.shipping = 0; this.tax = 0; this.taxRate = 0; this.cid = null; this.ipaddr = null; this.acceptUrl = null; this.declineUrl = null; this.pendingUrl = null; this.exceptionUrl = null; this.cancelUrl = null; this.notifyUrl = null; this.httpAccept = null; this.httpUserAgent = null; this.deviceFingerprint = null; this.language = null; this.customerBillingInfo = null; this.customerShippingInfo = null; this.deliveryInformation = null; this.previousAuthInfo = null; this.merchantRiskStatement = null; this.accountInfo = null; this.deviceChannel = null; this.recurringInfo = null; this.requestId = null; this.softDescriptor = null; } } module.exports = TransactionRequest;