UNPKG

react-native-razorpay-api

Version:
50 lines (49 loc) 3.06 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const convertor_1 = __importDefault(require("./convertor")); const settlements_1 = __importDefault(require("./settlements")); ; class subscriptions extends settlements_1.default { constructor() { super(...arguments); this.subscriptions = { getPlans: (options) => { if (options === null || options === void 0 ? void 0 : options.plan_id) return this.get('/plans/' + (options === null || options === void 0 ? void 0 : options.plan_id)); else return this.get('/plans', convertor_1.default.getOptions(options)); }, getSubscriptions: (options) => this.get('/subscriptions', convertor_1.default.getOptions(options)), planDetails: (planId) => this.get('/plans/' + planId), subscriptionDetails: (id) => this.get('/subscriptions/' + id), createPlan: (options) => this.post('/plans', options), createSubscription: (data) => this.post('/subscriptions', Object.assign(Object.assign({}, data), { start_at: convertor_1.default.toDateNumber(data === null || data === void 0 ? void 0 : data.start_at), expiry_by: convertor_1.default.toDateNumber(data === null || data === void 0 ? void 0 : data.expiry_by) })), cancelSubscription: (id, option) => { return this.post(`/subscriptions/${id}/cancel`, { cancel_at_cycle_end: option == "auto" ? 1 : 0 }); }, updateSubscription: (sub_id, data) => this.update('/subscriptions/' + sub_id, Object.assign(Object.assign({}, data), { start_at: convertor_1.default.toDateNumber(data === null || data === void 0 ? void 0 : data.start_at), schedule_change_at: data.change_at == "auto" ? 'cycle_end' : 'now', customer_notify: (data === null || data === void 0 ? void 0 : data.customer_notify) == false ? 0 : 1 })), getPendingSubscriptionUpdate: (id) => { return this.get(`/subscriptions/${id}/retrieve_scheduled_changes`); }, concelSubscriptionUpdate: (id) => { return this.post(`/subscriptions/${id}/cancel_scheduled_changes`, {}); }, pauseSubscription: (subscription_id, pause_at) => { return this.post(`/subscriptions/${subscription_id}/pause`, { pause_at: pause_at == "auto" ? undefined : "now" }); }, resumeSubscription: (subscription_id, resume_at) => { return this.post(`/subscriptions/${subscription_id}/resume`, { resume_at: resume_at == "auto" ? undefined : "now" }); }, getInvoices: (sub_id) => this.get('/invoices?subscription_id=' + sub_id) }; } } ; exports.default = subscriptions;