I am trying to build ios application using ionic framework. I am using razorypay (payment gateway) to accept payments.
Razorpay is correctly working with browser but when i am trying to build it with ionic cordova build ios
Works Correctly on browser.
Task done
import { Component } from '@angular/core';
import { Router } from '@angular/router';
declare var RazorpayCheckout: any;
@Component({
selector: 'app-razorpay',
templateUrl: './razorpay.page.html',
styleUrls: ['./razorpay.page.scss'],
})
export class RazorpayPage {
amount: number;
currency = 'INR';
razorKey = 'somekeyoverhere';
paymentAmount = this.amount;
constructor(public router: Router) { }
payWithRazor() {
const options = {
description: 'Credits towards consultation',
currency: this.currency, // your 3 letter currency code
key: this.razorKey, // your Key Id from Razorpay dashboard
amount: this.paymentAmount, // Payment amount in smallest denomiation e.g. cents for USD
name: 'Techmave Solutions',
prefill: {
email: '[email protected]',
contact: '9561555479',
name: 'Enappd'
},
theme: {
color: '#F37254'
},
modal: {
ondismiss: () => {
alert('dismissed');
this.goToResponseError();
}
}
};
const successCallback = paymentId => {
this.goToResponseSuccess(paymentId);
};
const cancelCallback = error => {
// alert(error.description + ' (Error ' + error.code + ')');
// this.goToResponseError(error.code);
};
RazorpayCheckout.open(options, successCallback, cancelCallback);
}
goToResponseSuccess(paymentId) {
this.router.navigate(['/response', paymentId]);
}
goToResponseError() {
this.router.navigate(['/response']);
}
}
I am getting warnings as shown below.
/Users/yashtalegaonkar/Desktop/ionic-code/myapp/platforms/ios/MyApp/Plugins/com.razorpay.cordova/Razorpay/Main.m:28:1: warning:
implementing deprecated method [-Wdeprecated-implementations]
- (void)onPaymentError:(int)code
^
In module '
Razorpay
' imported from
/Users/yashtalegaonkar/Desktop/ionic-code/myapp/platforms/ios/MyApp/Plugins/com.razorpay.cordova/Razorpay/Main.h
:
2
:
MyApp/Plugins/com.razorpay.cordova/Razorpay.framework/Headers/Razorpay-Swift.h
:
275
:
1
:
note: method
'onPaymentError:description:andData:'
declared
here
- (void)onPaymentError:(int32_t)code description:(NSString * _Nonnull)str andData:(NSDictionary * _Nullable)response SW...
^
/Users/yashtalegaonkar/Desktop/ionic-code/myapp/platforms/ios/MyApp/Plugins/com.razorpay.cordova/Razorpay/Main.m:10:17: warning:
class 'Main' does not conform to protocol 'ExternalWalletSelectionProtocol' [-Wprotocol]
@implementation Main
^
/Users/yashtalegaonkar/Desktop/ionic-code/myapp/platforms/ios/MyApp/Plugins/com.razorpay.cordova/Razorpay/Main.m:10:17: note:
add stubs for missing protocol requirements
@implementation Main
^
2 warnings generated.
The warnings are because of deprecated code inside cordova and razorpay hence it outputs a warning.
Warnings wont be a problem to run the app or deploy it as I have researched over it. Cordova has multiple deprecated methods so it helps us to run on lower version of iOS (9^).
Steps I followed
Enable Bitecode
Embed Libraries of Cordova
Embed Razorpay Framework