Я интегрировал страницу платежного шлюза в свое приложение Ionic 3.Мне удалось интегрировать его с использованием ионного http, но проблема в том, что иногда он работает, а иногда нет.Я слышал, что угловой http работает лучше.
Может кто-нибудь, пожалуйста, внесите изменения в приведенный ниже код и скажите, как я могу это исправить, чтобы он работал.
import {Component} from '@angular/core';
import Instamojo from 'instamojo-nodejs';
import {InAppBrowser} from '@ionic-native/in-app-browser';
import {HTTP} from '@ionic-native/http';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import 'rxjs/add/operator/map';
import { LoadingController } from 'ionic- angular/components/loading/loading-controller';
import { ContactusPage } from '../contactus/contactus';
//import { ProfilePage } from '../profile/profile';
@Component({
selector: 'page-new-transaction',
templateUrl: 'new_transaction.html'
})
export class NewTransactionPage {
amount;
instamojoClient;
constructor(public navCtrl: NavController, public navParams: NavParams, private iab: InAppBrowser, private http: HTTP,public loadingCtrl:LoadingController) {
this.instamojoClient = new Instamojo(http, iab, 'http://xxxxx.com/access_token.php');
}
contactNow() {
this
.navCtrl
.push(ContactusPage);
}
payNow() {
let loading = this.loadingCtrl.create({
spinner: 'hide',
content: `
<div class="custom-spinner-container">
<div class="custom-spinner-box"><img src="assets/imgs/loading.gif"></div>
</div>`,
duration: 5000
});
var data = this.instamojoClient.getPaymentFields();
data.purpose = "Account"; // REQUIRED
data.amount = 750; // REQUIRED
// do not change this
data.redirect_url = "http://localhost";
loading.present().then(res=>{
this.instamojoClient.payNow(data).then(response => {
// alert("Payment complete: " + JSON.stringify(response));
loading.dismiss();
}).catch(err => {
loading.dismiss();
// alert("Payment failed: " + JSON.stringify(err));
throw err;
});
//call the Safari View Controller
// end of safari view controller
})
}
}