manishkatyan / strapi-stripe

Stripe Plugin for Strapi CMS
66 stars 33 forks source link

Fails to create Stripe product #64

Closed sonicviz closed 1 year ago

sonicviz commented 1 year ago

Hi, I'm testing this out now on latest Strapi version and latest plugin version.

Unfortunately on product create it failes in the console with the following message: invalid_request_error - product Plans may only be created with products of type service, but the supplied product (prod_N0Dr4ozVp9z7rw) had type good.

However, looking at the Stripe backend the products were partially created, with just the product name and no other details, despite having all the info filled in.

But they don't exist on the Strapi side. There was also no error on the Strapi console that they failed.

I'm in test mode, running on localhost. Running on node v18.12.1 The Quasar app is a basic quickstart generated Quasar app. Strapi is a basic localhost quickstart Strapi 4 app with the following plugins added: Sendgrid (tested and working) VueAuth (tested and working) Strapi-stripe (this plugin, errors as noted)

Stripe logs for the partially created plan show two transactions: 400 ERR POST /v1/plans 12/18/22, 12:19:39 PM 200 OK POST /v1/products 12/18/22, 12:19:38 PM

They also indicate the API being used is a very old version: 2015-07-28

Could you please clarify what's happening?

Also, why is a product image mandatory as input on the Strapi side, when it's optional on the Stripe side?

Thanks!

sonicviz commented 1 year ago

Here's some more info. When you hit the product create button it shows two log files for the created product on the Stripe backend. It's the second one with the product details that is failing, causing the whole thing to Fail Ungracefully.

As noted before, this seems to be using a very out of date Stripe API as well.

First log details 200 OK Status

POST /v1/products 200 OK Time

12/18/22, 1:18:01 PM IP address REDACTED API version

2015-07-28 Source Stripe/v1 NodeBindings/8.222.0 Related

product — [prod_N0En4jhjkL9TQZ](URL REDACTED) Idempotency

Key — 54dd81d9-54dd-4758-b84b-7f6bad25a55c Request POST body

{ "description": "AI Lite Plan description", "images": { "0": "http://localhost:1337/uploads/vue_stripe_logo_variant_1_small_db628b911d.png" }, "name": "AI Lite Plan" } Request query parameters No query parameters Response body

{ "id": ["prod_N0En4jhjkL9TQZ"](URL REDACTED), "object": "product", "active": true, "attributes": [ ], "caption": null, "created": 1671337081, "deactivate_on": [ ], "default_price": null, "description": "AI Lite Plan description", "images": [ "http://localhost:1337/uploads/vue_stripe_logo_variant_1_small_db628b911d.png" ], "livemode": false, "metadata": { }, "name": "AI Lite Plan", "package_dimensions": null, "shippable": true, "skus": { "object": "list", "data": [ ], "has_more": false, "total_count": 0, "url": "/v1/skus?product=prod_N0En4jhjkL9TQZ&active=true" }, "tax_code": null, "type": "good", "updated": 1671337081, "url": null }

2nd log file details 400 Error Status

Note: I set price at $5 but it's showing as 500 here. Is the price converted to cents for Stripe or something?

POST /v1/plans 400 ERR Time

12/18/22, 1:18:02 PM IP address REDACTED API version

2015-07-28 Source Stripe/v1 NodeBindings/8.222.0 Related

product — [prod_N0En4jhjkL9TQZ](URL REDACTED) Idempotency

Key — 65956f78-109c-41bf-845a-00fff9f302fc invalid_request_error - product

Plans may only be created with products of type service, but the supplied product (prod_N0En4jhjkL9TQZ) had type good. Was this useful? Yes No

{ "interval": "month", "product": "prod_N0En4jhjkL9TQZ", "trial_period_days": "0", "amount": "500", "currency": "usd" } Request POST body

{ "interval": "month", "product": ["prod_N0En4jhjkL9TQZ"](URL REDACTED), "trial_period_days": "0", "amount": "500", "currency": "usd" } Request query parameters No query parameters Response body

{ "error": { "message": "Plans may only be created with products of type service, but the supplied product (prod_N0En4jhjkL9TQZ) had type good.", "param": "product", "request_log_url": "URL REDACTED", "type": "invalid_request_error" } }

sonicviz commented 1 year ago

Fixed: Issue caused by out of date Stripe API on Stripe dashboard. Updated to latest Stripe API, resolved.