Ionic Apple Pay Bug Fix
Budget: $10 – $70 USD
I'm having trouble with the Apple Pay token not returning correctly within my Ionic application on iOS. It seems to be a recurring issue and I need an experienced developer to come in and fix the problem.
This is my code
googleApplePay() {
var totale = this.getTotScontatoPiuConsegna();
cordova.plugins["ApplePayGooglePay"].canMakePayments((r) => {
var request: any;
if(this.platform.is('android')) {
request = {
merchantId: this.orderCurrent.StripeKeyPublic,
purpose: "Pagamento per l'ordine di ForToGo #" + this.orderCurrent.OrderNumber,
amount: totale,
countryCode: "IT",
currencyCode: "EUR",
gateway: "stripe",
gpMerchantName: "ForToGo",
gpMerchantId: "BCR2DN4TYSRJ332I"
};
} else if(this.platform.is('ios')) {
request = {
merchantId: "merchant.it.fortogo",
purpose: "Pagamento per l'ordine di ForToGo #" + this.orderCurrent.OrderNumber,
amount: totale,
countryCode: "IT",
currencyCode: "EUR"
}
}
console.log("rr");
console.log("Payment request sent:", request);
cordova.plugins["ApplePayGooglePay"].makePaymentRequest(request, (r) => {
console.log("Received response:", r);
if(this.platform.is('android')) {
var result = JSON.parse(r);
var tokenObj = JSON.parse(result.paymentMethodData.tokenizationData.token);
token = tokenObj.id;
this.makePaymentWalletToken(token);
} else if(this.platform.is('ios')) {
console.log("iOS platform, response object:", r);
if(r) {
try {
var tokenObj = JSON.parse(r.paymentData);
var token = tokenObj.token;
this.makePaymentWalletTokenIos(token);
} catch(e) {
console.error("Error parsing payment data:", e);
}
} else {
console.error("No data received in payment response");
}
}
},(r) => {
this.getOrderDetailById().then();
});
})
}
makePaymentWalletTokenIos(token: string) {
this.utils.presentLoadingWithOptions();
const payload = {
OrderId: this.globals.currentSavedOrderId,
Id_Discount: this.globals.buonoscontoIdToSend,
};
this.stripeSrv.preparePayment(payload).then((resp) => {
console.log("saad resp ");
console.log(resp);
this.stripe
.confirmCardPayment(resp.client_secret, {
payment_method: {
card: {token: token},
billing_details: {
name: this.globals.Utente.name + ' ' + this.globals.Utente.lastName
}
},
setup_future_usage: 'off_session'
})
Issue is I am not getting any token I get this message "No data received in payment response"
Because of I am not getting token on stripe I am getting this error
"The customer has not entered their payment method."
I need some expert to help me
This is my code
googleApplePay() {
var totale = this.getTotScontatoPiuConsegna();
cordova.plugins["ApplePayGooglePay"].canMakePayments((r) => {
var request: any;
if(this.platform.is('android')) {
request = {
merchantId: this.orderCurrent.StripeKeyPublic,
purpose: "Pagamento per l'ordine di ForToGo #" + this.orderCurrent.OrderNumber,
amount: totale,
countryCode: "IT",
currencyCode: "EUR",
gateway: "stripe",
gpMerchantName: "ForToGo",
gpMerchantId: "BCR2DN4TYSRJ332I"
};
} else if(this.platform.is('ios')) {
request = {
merchantId: "merchant.it.fortogo",
purpose: "Pagamento per l'ordine di ForToGo #" + this.orderCurrent.OrderNumber,
amount: totale,
countryCode: "IT",
currencyCode: "EUR"
}
}
console.log("rr");
console.log("Payment request sent:", request);
cordova.plugins["ApplePayGooglePay"].makePaymentRequest(request, (r) => {
console.log("Received response:", r);
if(this.platform.is('android')) {
var result = JSON.parse(r);
var tokenObj = JSON.parse(result.paymentMethodData.tokenizationData.token);
token = tokenObj.id;
this.makePaymentWalletToken(token);
} else if(this.platform.is('ios')) {
console.log("iOS platform, response object:", r);
if(r) {
try {
var tokenObj = JSON.parse(r.paymentData);
var token = tokenObj.token;
this.makePaymentWalletTokenIos(token);
} catch(e) {
console.error("Error parsing payment data:", e);
}
} else {
console.error("No data received in payment response");
}
}
},(r) => {
this.getOrderDetailById().then();
});
})
}
makePaymentWalletTokenIos(token: string) {
this.utils.presentLoadingWithOptions();
const payload = {
OrderId: this.globals.currentSavedOrderId,
Id_Discount: this.globals.buonoscontoIdToSend,
};
this.stripeSrv.preparePayment(payload).then((resp) => {
console.log("saad resp ");
console.log(resp);
this.stripe
.confirmCardPayment(resp.client_secret, {
payment_method: {
card: {token: token},
billing_details: {
name: this.globals.Utente.name + ' ' + this.globals.Utente.lastName
}
},
setup_future_usage: 'off_session'
})
Issue is I am not getting any token I get this message "No data received in payment response"
Because of I am not getting token on stripe I am getting this error
"The customer has not entered their payment method."
I need some expert to help me