@hyperse/paypal-node-sdk
Version:
NodeJS SDK for PayPal Checkout APIs
41 lines (40 loc) • 1.48 kB
JavaScript
import querystring from 'querystring';
import { HttpRequestBase } from '../core/HttpRequestBase.js';
import {} from '../types/type-order.js';
/**
* Captures a payment for an order.
*
* @see {@link https://developer.paypal.com/api/orders/v2/#orders_capture}
*/
export class OrdersCaptureRequest extends HttpRequestBase {
constructor(orderId) {
super();
this.path = '/v2/checkout/orders/{order_id}/capture?';
this.path = this.path.replace('{order_id}', querystring.escape(orderId));
this.verb = 'POST';
this.headers = {
'Content-Type': 'application/json',
};
}
payPalClientMetadataId(payPalClientMetadataId) {
this.headers['PayPal-Client-Metadata-Id'] = payPalClientMetadataId;
return this;
}
payPalRequestId(payPalRequestId) {
this.headers['PayPal-Request-Id'] = payPalRequestId;
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(orderActionRequest) {
this.body = orderActionRequest;
return this;
}
}