@hyperse/paypal-node-sdk
Version:
NodeJS SDK for PayPal Checkout APIs
41 lines (40 loc) • 1.64 kB
JavaScript
import querystring from 'querystring';
import { HttpRequestBase } from '../core/HttpRequestBase.js';
import {} from '../types/type-payment.js';
/**
* Refunds a captured payment, by ID. For a full refund, include an empty payload in the JSON request body.
* For a partial refund, include an <code>amount</code> object in the JSON request body.
* @see {@link https://developer.paypal.com/api/payments/v2/#captures_refund}
*/
export class CapturesRefundRequest extends HttpRequestBase {
constructor(captureId) {
super();
this.path = '/v2/payments/captures/{capture_id}/refund?';
this.path = this.path.replace('{capture_id}', querystring.escape(captureId));
this.verb = 'POST';
this.headers = {
'Content-Type': 'application/json',
};
}
payPalRequestId(payPalRequestId) {
this.headers['PayPal-Request-Id'] = payPalRequestId;
return this;
}
payPalAuthAssertion(payPalAuthAssertionCode) {
this.headers['PayPal-Auth-Assertion'] = payPalAuthAssertionCode;
return this;
}
/**
* 1. return=minimal. The server returns a minimal response to optimize communication between the API caller and the server. A minimal response includes the id, status and HATEOAS links.
* 2. return=representation. The server returns a complete resource representation, including the current state of the resource.
* @default `return=minimal`
*/
prefer(prefer) {
this.headers['Prefer'] = prefer;
return this;
}
requestBody(refundRequest) {
this.body = refundRequest;
return this;
}
}