@lexriver/yandex-pay
Version:
A TypeScript client for Yandex Pay API to integrate payment processing in your Node.js applications
47 lines (46 loc) • 1.69 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SubscriptionService = void 0;
const BaseService_js_1 = require("./BaseService.js");
/**
* Service for working with subscriptions
*/
class SubscriptionService extends BaseService_js_1.BaseService {
/**
* Request for subscription creation.
*
* The request is used to create a subscription and and obtain a link to start it.
*
* @param data Subscription data
* @returns Created subscription data
*/
async createSubscription(data) {
return this.post('/v1/subscriptions', data);
}
/**
* Request to debit a regular subscription fee.
*
* The request is used to perform a direct debit from the account or card linked to the subscription.
* To debit funds, pass the order ID, cart, debit amount, and ID of the initial order that was used at subscription creation.
*
* @param data Recurring payment data
* @returns Operation details
*/
async makeRecurringPayment(data) {
return this.post('/v1/subscriptions/recur', data);
}
/**
* Request to obtain subscription details.
*
* Returns the subscription ID and status and the linked payment method.
*
* @param subscriptionId Subscription ID
* @param checkCardActive Whether to check if the card is active
* @returns Subscription details
*/
async getSubscription(subscriptionId, checkCardActive) {
const data = checkCardActive ? { check_card_active: true } : {};
return this.post(`/v1/subscriptions/${subscriptionId}`, data);
}
}
exports.SubscriptionService = SubscriptionService;