wayforpay-ts-integration
Version:
Library for forms to go to the Wayforpay payment page.
107 lines (106 loc) • 4.5 kB
TypeScript
import { TCartElement, TRequestListTransactions, TWayforpayRequestPayment, TWayforpayOptions, TWayforpayResponseRegularPaymentStatus, TRequestRegularPayment, TWayforpayResponseTransactionDetails, TWayforpayResponseTransactionListItem } from "./types";
export * from './types';
export declare class Wayforpay {
private option?;
/**
* The class gets options to provide communication with the Wayforpay API. The options include your store domain, your merchant login, your merchant api token, and the currency you want to use.
*
* If options are not passed, then variables from the .env file are used.
* - `MERCHANT_LOGIN` — the merchant login from the store settings
* - `MERCHANT_SECRET_KEY` — the merchant secret key from the store settings
*/
constructor(option?: TWayforpayOptions | undefined);
private createSignature;
private createPaymentSignature;
private createListTransactionsSignature;
private arrayToHtmlArray;
/**
* ## The Purchase request
* The Purchase request is used to make a payment by the client on the secure wayforpay page.
*
* A request with the necessary parameters is formed through a package
* and transmitted in the form of an HTML form, which should be executed
* automatically on the front-end side.
*
* ### Documentation
* - https://wiki.wayforpay.com/view/852102
*
* ### Example
* ```typescript
* const wayforpay = new Wayforpay({
* merchantLogin: process.env.MERCHANT_LOGIN as string,
* merchantSecret: process.env.MERCHANT_SECRET_KEY as string
* });
*
* // In `form` HTML is a form that should be sent to the front end and executed.
* const form = await wayforpay.createForm(cart as TCartElement[], {
* domain: 'example.com',
* currency: 'UAH',
* deliveryList: ["nova","other"],
* });
* ```
*
* @param userCart
* @param data
*/
purchase(userCart: TCartElement[], data?: TWayforpayRequestPayment): Promise<string>;
/**
* @deprecated Use `purchase` method instead.
*/
createForm: (userCart: TCartElement[], data?: TWayforpayRequestPayment) => Promise<string>;
checkStatus(orderReference: string, apiVersion?: 1 | 2): Promise<TWayforpayResponseTransactionDetails>;
/**
* ## Transaction list
* The TRANSACTION LIST query is used to retrieve a list of store transactions for a specific time period.
*
* The maximum period for which you can receive transactions is 31 days.
*
* ### Documentation
* - https://wiki.wayforpay.com/view/1736786
*
* ### Example
* ```typescript
* const wayforpay = new Wayforpay({
* merchantLogin: process.env.MERCHANT_LOGIN as string,
* merchantSecret: process.env.MERCHANT_SECRET_KEY as string
* });
*
* const response = await wayforpay.getTransactions();
* const transactions = response.data;
* ```
*
* @param data
*/
getTransactions(data?: TRequestListTransactions): Promise<TWayforpayResponseTransactionListItem[]>;
/**
* # Regular payment
*
* The request is generated on the merchant's side and transmitted by the POST method to the URL `https://api.wayforpay.com/regularApi`.
*
* ## Documentation
* - https://wiki.wayforpay.com/view/852496
*
* * Note: The integration of this functionality is considered individually for each store. To proceed, please contact sales@wayforpay.com, specifying the merchant's name, describing the situation, and mentioning that you need a MerchantPassword.
*
* ## Request types
* - `STATUS`: Returns the current status of the regular payment.
* - `SUSPEND`: Suspends the regular payment.
* - `RESUME`: Resumes the regular payment.
* - `REMOVE`: Removes the regular payment.
*
* ## Documentation
* - https://wiki.wayforpay.com/view/852526
*
* ## Example
* ```typescript
* const wayforpay = new Wayforpay({
* merchantLogin: process.env.MERCHANT_LOGIN as string,
* merchantPassword: process.env.MERCHANT_PASSWORD as string
* });
*
* const regularPayment = await wayforpay.checkRegularPayment(orderReference, 'STATUS');
* ```
*/
regularPayment(orderReference: string, requestType?: TRequestRegularPayment): Promise<TWayforpayResponseRegularPaymentStatus>;
private formatCart;
}