I have a PayPal Smart Button on my Angular web page that looks like the following:
paypal.Buttons({
createOrder: (data, actions) => {
return actions.order.create({
purchase_units: [
{
description: this.product.description,
amount: {
currency_code: 'USD',
value: this.product.price,
}
},
],
application_context: {
shipping_preference: 'NO_SHIPPING'
}
});
},
onApprove: async (data, actions) => {
this.dataService.reserveReservation();
const order = actions.order.capture();
alert('Transaction Completed!');
}
}).render(this.paypalElement.nativeElement);
95% of the time the purchase goes through, but occasionally dataService.reserveReservation gets called without the payment going through. Is there some time of error that actions.order.capture() returns if the payment fails, or why is the onApprove callback being called when the payment isn't going through and doesn't show up anywhere in my PayPal home activity tab? How can I make sure the payment is going through every time?