#rhuzaifa_error

1 messages ยท Page 1 of 1 (latest)

steel dawnBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

๐Ÿ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1329810666474967071

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

marble nacelle
#

My fixture

// fixture.json
{
    "_meta": {
        "template_version": 0
    },
    "fixtures": [
        {
            "name": "checkout_session",
            "path": "/v1/checkout/sessions",
            "method": "post",
            "params": {
                "payment_method_types": [
                    "card"
                ],
                "mode": "subscription",
                "line_items": [
                    {
                        "price": "REPLACE_VIA_CLI",
                        "quantity": 1
                    }
                ],
                "success_url": "REPLACE_VIA_CLI",
                "cancel_url": "REPLACE_VIA_CLI",
                "customer": "REPLACE_VIA_CLI",
                "custom_text": {
                    "terms_of_service_acceptance": {
                        "message": "I accept ${.env:APP_NAME}'s terms of service."
                    }
                },
                "consent_collection": {
                    "terms_of_service": "required"
                },
                "metadata": {
                    "user_id": "REPLACE_VIA_CLI"
                }
            }
        },
        {
            "name": "payment_page",
            "path": "/v1/payment_pages/${checkout_session:id}",
            "method": "get"
        },
        {
            "name": "payment_page_confirm",
            "path": "/v1/payment_pages/${checkout_session:id}/confirm",
            "method": "post",
            "params": {
                "payment_method": "REPLACE_VIA_CLI",
                "expected_amount": "REPLACE_VIA_CLI"
            }
        }
    ]
}
#

how i use it

stripe trigger checkout_sessions_completed.json --override checkout_session:"line_items[0][price]"=price_1QBz8wHj8xfC0YnCWyWxyUQI --override checkout_session:"success_url"='http://localhost:3000//subscription/success?session_id={CHECKOUT_SESSION_ID}' --override checkout_session:"cancel_url"='http://localhost:3000//pricing' --override checkout_session:"customer"=cus_RbSpK1ggiOK989 --override checkout_session:"metadata[user_id]"=19 --override payment_page_confirm:"payment_method"=pm_1QiFu0Hj8xfC0YnCiX1roq1Z --override payment_page_confirm:"expected_amount"=2900

the error i get

A newer version of the Stripe CLI is available, please update to: v1.23.3
Setting up fixture for: checkout_session
Running fixture for: checkout_session
Trigger failed: Request failed, status=400, body={
  "error": {
    "code": "resource_missing",
    "doc_url": "https://stripe.com/docs/error-codes/resource-missing",
    "message": "No such price: 'REPLACE_VIA_CLI'",
    "param": "line_items[0][price]",
    "request_log_url": "https://dashboard.stripe.com/test/logs/req_Unme2EPH1frfOC?t=1737121693",
    "type": "invalid_request_error"
  }
}
novel girder
#

s

mossy tinsel
#

๐Ÿ‘‹ Checking...

mossy tinsel
#

For metadat you should use --override checkout_session:"metadata.user_id"=19

#

Checking why the price isn't getting overridden...

dawn obsidian
#

This should work:
stripe trigger your_fixture --override "checkout_session:line_items[0].price=price_abc"

marble nacelle
#

trying...

dawn obsidian
#

Worth noting that line_items field won't be in the event payload though

marble nacelle
#

is this only in the case of running fixtures, when the values are overridden with cli?

dawn obsidian
#

During the API request of the session create

#

The line_items field will reflect the values you pass, but they're just not expanded on the resource by default so not included in webhook payloads. Nothing CLI specific, that's how the API works

marble nacelle
#

ok yeah, makes sense.

#

"checkout_session:line_items[0].price=price_abc"
this worked. Thanks, but now i am getting this error

Setting up fixture for: checkout_session
Running fixture for: checkout_session
Setting up fixture for: payment_page
Running fixture for: payment_page
Setting up fixture for: payment_page_confirm
Running fixture for: payment_page_confirm
Trigger failed: Request failed, status=400, body={
  "error": {
    "message": "An error has occurred confirming the Checkout Session.",
    "request_log_url": "https://dashboard.stripe.com/test/logs/req_A0HfEjh6koKjfK?t=1737123793",
    "type": "invalid_request_error"
  }
}
dawn obsidian
#

Well this is because it's an internal API that shouldn't really be used like this

#

payment_pages/:id/confirm that is

marble nacelle
#

it actually works without overrides

#

if i hardcode the values in fxtures

dawn obsidian
#

Looking at the request to see what the issue is

#

OK, I think it's because there's no email set on the pm_xxx you're using

marble nacelle
#

hm, i actually have set the email on customer so i thought it would reuse that. Going to try setting email on pm_

#

i don't think i can set the email on payment method, i am actually attaching a test card via its token like this

// nodejs
const paymentMethod = await stripe.paymentMethods.attach(`pm_card_visa`, {
      customer: customer.id,
    })
dawn obsidian
#

Will likely need a country and ZIP code too

marble nacelle
#

hm, taking a look and trying it out

dawn obsidian
#

To be fair, checkout_session:line_items[0][price] also works

marble nacelle
#

maybe i am on the wrong cli version? its 1.21.10

dawn obsidian
#

You just need quotes around the value too

#

Looks like you didn't initially:
checkout_session:"line_items[0][price]"=price_1QBz8wHj8xfC0YnCWyWxyUQI --override

steel dawnBOT
marble nacelle
#

i see, makes sense. Thanks!