UNPKG

nativescript-razorpay

Version:

A {N} plugin that wraps around native iOS and Android plugins

63 lines 2.65 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var razorpay_common_1 = require("./razorpay.common"); var frame_1 = require("tns-core-modules/ui/frame"); var RazorpayPaymentCompletionDelegate = (function (_super) { __extends(RazorpayPaymentCompletionDelegate, _super); function RazorpayPaymentCompletionDelegate() { return _super !== null && _super.apply(this, arguments) || this; } RazorpayPaymentCompletionDelegate.prototype.onPaymentSuccess = function (payment_id) { this._plugin.done(payment_id); }; RazorpayPaymentCompletionDelegate.prototype.onPaymentErrorDescription = function (code, response) { this._plugin.error(code, response); }; RazorpayPaymentCompletionDelegate.prototype.initWith = function (p) { this._plugin = p; return this; }; return RazorpayPaymentCompletionDelegate; }(NSObject)); RazorpayPaymentCompletionDelegate.ObjCProtocols = [RazorpayPaymentCompletionProtocol]; exports.RazorpayPaymentCompletionDelegate = RazorpayPaymentCompletionDelegate; var RazorpayCheckout = (function (_super) { __extends(RazorpayCheckout, _super); function RazorpayCheckout(razorPayKey) { var _this = _super.call(this) || this; _this._delegate = new RazorpayPaymentCompletionDelegate().initWith(_this); _this._razorPay = Razorpay.initWithKeyAndDelegate(razorPayKey, _this._delegate); return _this; } Object.defineProperty(RazorpayCheckout.prototype, "currentPage", { get: function () { return frame_1.topmost().currentPage; }, enumerable: true, configurable: true }); RazorpayCheckout.prototype.preload = function () { }; RazorpayCheckout.prototype.done = function (paymentId) { this._resolve(paymentId); this._resolve = this._reject = null; }; RazorpayCheckout.prototype.error = function (code, response) { this._reject(new Error("Failed with error code: " + code)); this._resolve = this._reject = null; }; RazorpayCheckout.prototype.open = function (options) { var _this = this; if (this._reject != null) { return Promise.reject(new Error("You are already in a checkout session from Razorpay")); } return new Promise(function (resolve, reject) { _this._resolve = resolve; _this._reject = reject; _this._razorPay.open(options); }); }; return RazorpayCheckout; }(razorpay_common_1.CheckoutCommon)); exports.RazorpayCheckout = RazorpayCheckout; //# sourceMappingURL=razorpay.ios.js.map