stripe / stripe-php

PHP library for the Stripe API.
https://stripe.com
MIT License
3.75k stars 848 forks source link

How to create a subscription based off a payment intent? #664

Closed ghost closed 5 years ago

ghost commented 5 years ago

So after an evening of swearing in front of my computer I managed to get the creation of payment intents going including 3D Secure. The EU certainly makes it difficult now with SCA and VAT MOSS.

Anyway:

The intent is shown as a verified and uncaptured payment. How the heck do I use this to create a subscription and capture the payment?

What I now do:

{
  "error": {
    "code": "resource_missing",
    "doc_url": "https://stripe.com/docs/error-codes/resource-missing",
    "message": "This customer has no attached payment source",
    "type": "invalid_request_error"
  }
}

The plan comes with VAT attached so the €20 becomes €23,80. In payments I can see a completely new payment for €23,80 but marked as failed.

I am using this to create a Subscription:

  {
      $subscription = \Stripe\Subscription::create([
      "customer" => $customer['id'],
      "items" => [
        [
          "plan" => "plan_F91vJfk2jxYbCf",
          "tax_rates" => ["txr_1EehRsHf224l2JTULVwmg0vF"]
        ],
      ],

      "metadata" => ['user_id' => "123456", "taxamo_key" => "blablablabla--pMYc"]
    ]);
  }
ob-stripe commented 5 years ago

Hi @Fossil01. GitHub issues are specifically for bugs or feature requests with Stripe's PHP library and are not a support channel. You should reach out to Stripe's support using the form at https://support.stripe.com/email to explain your issue and they will be able to help you.