Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do I keep getting a payment method not entered when processing a credit card transaction via Stripe

Tags:

I am having some technical difficulties, my programming knowledge is limited so it's probably an easy fix. I am attempting to integrate Stripe credit card transactions into our website, https://cdunion.ca/stripe/. Everything is working, it will connect to Stripe, no error messages, but when I log into my Stripe dashboard, every transaction is listed as 200 ok but also listed as incomplete. The exact error is "The customer has not entered their payment method". I have been Googling and racking my brain out over this for 2 weeks, with no success. I have checked and cards payment method is enabled in my Stripe dashboard. My code is listed below. I am using the Stripe library in Composer on both my home testing server and my live server. Any assistance you can offer is greatly appreciated, merci.

PS The credit card listed is specifically for testing purposes used by all credit card processors, so do not worry, no confidential information has been released.

<?php
/* 
$donation_amount = ($_POST["donation-amount"]) . '00';
$address = (($_POST["unit"]) . '-' . ($_POST["address"]));
$city = ($_POST["city"]);
$province = ($_POST["province"]);
$country = ($_POST["country"]);

echo ($donation_amount . "<br>" . $address . "<br>" . $city . "<br>" . $province . "<br>" . $country);

*/

require_once 'C:/xampp/composer/vendor/autoload.php';

\Stripe\Stripe::setApiKey('*censored*');

\Stripe\PaymentMethod::create([
  'type' => 'card',
  'card' => [
    'number' => '4242424242424242',
    'exp_month' => 12,
    'exp_year' => 2020,
    'cvc' => '314',
  ],
]);

\Stripe\PaymentIntent::create([
    'payment_method_types' => ['card'],
    'amount' => $donation_amount,
    'currency' => 'cad',
]);

die();

?>
like image 779
Howie Avatar asked Dec 28 '19 03:12

Howie


People also ask

Why is my Stripe payment not working?

There are three possible reasons why a credit card payment might fail: Payments declined by card issuers. Blocked payments. Invalid API calls.

How do I activate my payment method on Stripe?

You can view a list of available alternative payment methods that you can accept in your Payments settings dashboard. Click Request Access next to the payment method you want to allow. You may be asked to provide additional information required by the scheme, or agree with a specific addendum to our Services Agreement.

What does Stripe payment error mean?

The customer must use another card or method of payment. processing_error. An error occurred while processing the card. The payment needs to be attempted again. If it still can't be processed, try again later.

How do I stop Stripe blocking payment?

If Stripe Radar ever blocks a payment that you know is legitimate, you can remove the block using the Dashboard. To do this, view the payment in the Dashboard and click Add to allow list.


1 Answers

You need to pass the ID of the payment method when creating the payment intent.

$method = \Stripe\PaymentMethod::create([
  'type' => 'card',
  'card' => [
    'number' => '4242424242424242',
    'exp_month' => 12,
    'exp_year' => 2020,
    'cvc' => '314',
  ],
]);

\Stripe\PaymentIntent::create([
    'payment_method_types' => ['card'],
    'payment_method' => $method->id,
    'amount' => $donation_amount,
    'currency' => 'cad',
]);
like image 158
Barmar Avatar answered Dec 01 '22 12:12

Barmar