skip to Main Content

Getting this error while trying to charge the customer for service.

This Customer doesn’t have any legacy saved payment details, but does have a Payment Method attached. Use a Payment Intent instead of creating a Charge: https://stripe.com/docs/payments/payment-intents/migration

this is the code

$charge = [
            'amount' => $totalCost * 100,
            'currency' => StripeHelper::CURRENCY,
            'description' => "recurring-" . $bookingid . "-C" . $weeks,
            'customer' => $source,
            "transfer_group" => "$bookingid-$minderId",
        ];
        try {
            $charge = $this->stripe->charges->create($charge);
        } catch (StripeErrorApi $ex) {
            Yii::error($ex->getMessage());
            return ['error' => $ex->getMessage(), 'code' => $ex->getCode()];
        } catch (StripeErrorInvalidRequest $ex) {
            Yii::error($ex->getMessage());
            return ['error' => $ex->getMessage(), 'code' => $ex->getCode()];
        } catch (Exception $ex) {
            Yii::error($ex->getMessage());
            return ['error' => $ex->getMessage(), 'code' => $ex->getCode()];
        }

        return $charge;

When I implemented this approximately 20 to 30 times before, it was successfully processing charges. However, now it is displaying the error mentioned above.

I would greatly appreciate your assistance in resolving this issue.

2

Answers


  1. Chosen as BEST ANSWER

    I contacted Stripe support regarding this issue.

    "This customer doesn't have any legacy saved payment details but does have a Payment Method attached. Use a Payment Intent instead of creating a Charge: https://stripe.com/docs/payments/payment-intents/migration."

    They provided the following information:

    According to them, the API used for charging payments is deprecated. While it is currently operational, it is no longer being maintained and has encountered numerous issues, which is why this error is occurring. They suggested using the Payment Intents API, as detailed in the documentation provided in the request: https://stripe.com/docs/payments/payment-intents/migration.


  2. Based off the error message, your customer has a PaymentMethod attached, but not a Token or Source. For context, the Charges API does not support using PaymentMethod objects (i.e. with the prefix pm_). You can see what payment methods are attached to the customer using https://stripe.com/docs/api/payment_methods/customer_list.

    Like what the error message mentions, you should use the PaymentIntents API instead if you’re using the PaymentMethods : https://stripe.com/docs/api/payment_intents/create. The PaymentIntents API is also backward compatible with Tokens / Sources : https://stripe.com/docs/payments/payment-methods/transitioning#compatibility

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search