UNPKG

@abbieben/flutterwave

Version:

This is an easy plugin of the Flutterwave SDK for Android and iOS

60 lines 2.88 kB
import { Frame } from '@nativescript/core'; import { FlutterwaveCommon, Response } from './flutterwave.common'; export class Flutterwave extends FlutterwaveCommon { constructor() { super(); this.controller = NSFlutterwave.new(); } pay() { return new Promise((resolve, reject) => { this.validate() .then(() => { this.controller.country = this.country; this.controller.currencyCode = this.currency; this.controller.amount = '[' + this.amount + ']'; this.controller.email = this.email; this.controller.firstName = this.firstName; this.controller.lastName = this.lastName; this.controller.phoneNumber = this.phoneNumber; this.controller.narration = this.narration; this.controller.publicKey = this.publicKey; this.controller.encryptionKey = this.encryptionKey; this.controller.txRef = this.txRef; this.controller.isPreAuth = this.isPreAuth; this.controller.isStaging = this.isStaging; const payments = ['card', 'account', 'bank_transfer', 'uk']; this.controller.paymentOptionsToExclude = payments.filter((v) => this.payments[v]); this.controller.meta = [{ metaname: 'sdk', metavalue: 'ios' }]; this.controller.delegate = FlutterwaveDelegator.init(resolve, reject); const view = Frame.topmost().currentPage.ios; this.controller.payWithView(view); console.log('Meant to Launch'); }) .catch(reject); }); } } var FlutterwaveDelegator = /** @class */ (function (_super) { __extends(FlutterwaveDelegator, _super); function FlutterwaveDelegator() { return _super !== null && _super.apply(this, arguments) || this; } FlutterwaveDelegator.init = function (resolve, reject) { var delegate = _super.new.call(this); delegate.resolve = resolve; delegate.reject = reject; return delegate; }; FlutterwaveDelegator.prototype.onSuccess = function (reference, response) { return this.resolve(new Response(Flutterwave.PAYMENT_SUCCESS, response, reference)); }; FlutterwaveDelegator.prototype.onError = function (reference, response) { return this.reject(new Response(Flutterwave.PAYMENT_ERROR, response, reference)); }; FlutterwaveDelegator.prototype.onDismiss = function () { return this.reject(new Response(Flutterwave.PAYMENT_CANCELLED, null)); }; FlutterwaveDelegator.ObjCProtocols = [NSFlutterwaveDelegate]; return FlutterwaveDelegator; }(NSObject)); //# sourceMappingURL=flutterwave.ios.js.map