in Education by
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)

1 Answer

0 votes
by
If you want to perform a MOTO stripe payment, there are requirements as follows: You need to activate the MOTO payment option with stripe directly. You need to perform a single payment action, which is a paymentIntent with confirm=true. Making a paymentIntent first with confirmCardPayment later won't work in this case. The paymentIntent action in this case would look like this: (the following is a curl request, you can convert it to your backend language) curl https://api.stripe.com/v1/payment_intents \ -u sk_test_NfCI7U9wkvqjrgJRFirEuwjN \ -d amount=1099 \ -d currency=eur \ -d "payment_method_data[type]"=card \ -d "payment_method_data[card][number]"=4242424242424242 \ -d "payment_method_data[card][exp_month]"=4 \ -d "payment_method_data[card][exp_year]"=24 \ -d "payment_method_data[card][cvc]"=242 \ -d "payment_method_options[card][moto]"=true \ -d confirm=true It will return either an error or a successful payment result, which you can use for your further actions. Alternatively you can first create the paymentMethod and then make a confirmed intent with paymentMethod ID (to avoid sending card details directly and to make use of stripe card input UI elements). See more about how to create a payment method first here: https://stripe.com/docs/payments/accept-a-payment-synchronously#create-a-paymentmethod If you do it, your MOTO API call would look like this: curl https://api.stripe.com/v1/payment_intents \ -u sk_test_NfCI7U9wkvqjrgJRFirEuwjN \ -d amount=1099 \ -d currency=eur \ -d "payment_method"= \ -d "payment_method_options[card][moto]"=true \ -d confirm=true

Related questions

0 votes
    In ASPNET, I grew to love the Application and Cache stores. They're awesome. For the uninitiated, you ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 16, 2022 in Education by JackTerrance
0 votes
    In ASPNET, I grew to love the Application and Cache stores. They're awesome. For the uninitiated, you ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 16, 2022 in Education by JackTerrance
0 votes
    In ASPNET, I grew to love the Application and Cache stores. They're awesome. For the uninitiated, you ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 16, 2022 in Education by JackTerrance
0 votes
    In ASPNET, I grew to love the Application and Cache stores. They're awesome. For the uninitiated, you ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 16, 2022 in Education by JackTerrance
0 votes
    I'm trying to produce a page that would function a bit like a digital sticker album. My SQL ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 28, 2022 in Education by JackTerrance
0 votes
    I have a script which loops over tables and fields doing a find and replace. The script takes around ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 1, 2022 in Education by JackTerrance
0 votes
    I am aware that I can use array_unique(array_merge($a,$b)); to merge two arrays and then remove ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 14, 2022 in Education by JackTerrance
0 votes
    I want to load Google fonts in the head-section of my page using a php-function. My -area looks like this: ... ... Now ... I do this, there will be a "1" displayed (because of the...
asked Jun 2, 2022 in Education by JackTerrance
0 votes
    I want to load Google fonts in the head-section of my page using a php-function. My -area looks like this: ... ... Now ... I do this, there will be a "1" displayed (because of the...
asked May 30, 2022 in Education by JackTerrance
0 votes
    I want to load Google fonts in the head-section of my page using a php-function. My -area looks like this: ... ... Now ... I do this, there will be a "1" displayed (because of the...
asked May 26, 2022 in Education by JackTerrance
0 votes
    Is it possible to cache database connections when using PHP like you would in a J2EE container? If so, ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 17, 2022 in Education by JackTerrance
0 votes
    I want to load Google fonts in the head-section of my page using a php-function. My -area looks like this: ... ... Now ... I do this, there will be a "1" displayed (because of the...
asked May 17, 2022 in Education by JackTerrance
0 votes
    How can I get the value of the amp selector and save it in a php variable 1 1 1 I tried ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 6, 2022 in Education by JackTerrance
0 votes
    So this is a zany thing that I'm attempting to do, but what I am trying to achieve is querying ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 20, 2022 in Education by JackTerrance
0 votes
    So this is a zany thing that I'm attempting to do, but what I am trying to achieve is querying ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 20, 2022 in Education by JackTerrance
...