pcp-server-nodejs-sdk
Version:
[](https://sonarcloud.io/summary/new_code?id=PAYONE-GmbH_PCP-server-nodeJS-SDK) [ {
super(config);
}
async createPaymentInformation(merchantId, commerceCaseId, checkoutId, payload) {
if (!merchantId) {
throw new TypeError(MERCHANT_ID_REQUIRED_ERROR);
}
if (!commerceCaseId) {
throw new TypeError(COMMERCE_CASE_ID_REQUIRED_ERROR);
}
if (!checkoutId) {
throw new TypeError(CHECKOUT_ID_REQUIRED_ERROR);
}
const url = new URL(`/v1/${merchantId}/commerce-cases/${commerceCaseId}/checkouts/${checkoutId}/payment-information`, this.getConfig().getHost());
const requestInit = {
method: 'POST',
headers: new Headers({
'Content-Type': 'application/json',
}),
body: JSON.stringify(payload),
};
return this.makeApiCall(url.toString(), requestInit);
}
async getPaymentInformation(merchantId, commerceCaseId, checkoutId, paymentInformationId) {
if (!merchantId) {
throw new TypeError(MERCHANT_ID_REQUIRED_ERROR);
}
if (!commerceCaseId) {
throw new TypeError(COMMERCE_CASE_ID_REQUIRED_ERROR);
}
if (!checkoutId) {
throw new TypeError(CHECKOUT_ID_REQUIRED_ERROR);
}
if (!paymentInformationId) {
throw new TypeError(PAYMENT_INFORMATION_ID_REQUIRED_ERROR);
}
const url = new URL(`/v1/${merchantId}/commerce-cases/${commerceCaseId}/checkouts/${checkoutId}/payment-information/${paymentInformationId}`, this.getConfig().getHost());
const requestInit = {
method: 'GET',
headers: new Headers(),
};
return this.makeApiCall(url.toString(), requestInit);
}
async refundPaymentInformation(merchantId, commerceCaseId, checkoutId, paymentInformationId, payload) {
if (!merchantId) {
throw new TypeError(MERCHANT_ID_REQUIRED_ERROR);
}
if (!commerceCaseId) {
throw new TypeError(COMMERCE_CASE_ID_REQUIRED_ERROR);
}
if (!checkoutId) {
throw new TypeError(CHECKOUT_ID_REQUIRED_ERROR);
}
if (!paymentInformationId) {
throw new TypeError('Payment Information ID is required');
}
const url = new URL(`/v1/${merchantId}/commerce-cases/${commerceCaseId}/checkouts/${checkoutId}/payment-information/${paymentInformationId}/refund`, this.getConfig().getHost());
const requestInit = {
method: 'POST',
headers: new Headers({
'Content-Type': 'application/json',
}),
body: JSON.stringify(payload),
};
return this.makeApiCall(url.toString(), requestInit);
}
}
//# sourceMappingURL=PaymentInformationApiClient.js.map