I am struggling to figure out how to specify a MOTO payment with Stripe API and PHP. I believe I specify MOTO in the payment_method_options on the confirm (javascript), and I have to specify confirm = true in the create (PHP). I am struggling to get the example from here to work with MOTO although it works fine without.
script.js (I add payment_method_options: { card: {moto:true} }) to confirmCardPayment...
var pay = function(stripe, card, clientSecret) {
changeLoadingState(true);
// Initiate the payment.
// If authentication is required, confirmCardPayment will automatically display a modal
stripe
.confirmCardPayment(clientSecret, { payment_method: { card: card }, payment_method_options: { card: {moto:true} } })
.then(function(result) {
if (result.error) {
// Show error to your customer
showError(result.error.message);
} else {
// The payment has been processed!
orderComplete(clientSecret);
}
});
};
confirm-intent.php I specify confirm=true and include payment_method in the output...
use Stripe\PaymentIntent;
use Stripe\Stripe;
require '../vendor/autoload.php';
header('Content-Type: application/json');
Stripe::setApiKey('sk_test_xxxxxxxxxxxxx');
$paymentIntent = PaymentIntent::create([
'amount' => 2000,
'currency' => 'gbp',
'payment_method_types' => ['card'],
'confirm' => true
]);
$output = [
'publishableKey' => 'pk_test_xxxxxxxxxxxxx',
'clientSecret' => $paymentIntent->client_secret,
'payment_method' => $paymentIntent->id,
];
echo json_encode($output);
The error I am currently getting is...
PHP message: PHP Fatal error: Uncaught (Status 400) (Request req_1D9UTDO2IIp8zI) You cannot confirm this PaymentIntent because it's missing a payment method. You can either update the PaymentIntent with a payment method and then confirm it again, or confirm it again directly with a payment method.
The payment method is the id of the payment intent, I think. I have put it into the output of the payment intent script but this does not work. Any ideas? Thank you.
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)