#okay
1 messages ยท Page 1 of 1 (latest)
Taking a look. Will circle back in a couple minutes
thanks
So the problem is you're creating a new custom_field_id, but hard-coding a custom_field_id later in the command. Is that correct?
yes
i just hard-coded the custom_field_id to emphasize the problem here, but i know what the issue is
just dont know how to solve it
So payment_page_confirm is a fixture that you are adding to the end of your command?
yes
if I don't include the custom_field_id i get this error:
so i need some way to grab the new custom_field_id that is generated
You should be able to access it using ${name:json_path} as mentioned in the fixture docs, no?
how so
I haven't really looks at the fixtures command much, not sure how it works
also, none of the API calls leading up to payment_page_complete contain the custom_field_id
You mentioned payment_page_confirm is a fixture. You presumably wrote it yourself, yes?
No I didn't
running stripe trigger checkout.session.complete on its own automatically runs all of these fixtures:
Setting up fixture for: product
Running fixture for: product
Setting up fixture for: price
Running fixture for: price
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_method
Running fixture for: payment_method
Setting up fixture for: payment_page_confirm
Running fixture for: payment_page_confirm
Got it, okay
so since the last fixture was making an error (missing custom field), I'm assuming I just need to do some overrides
Have you tried referencing the attribute from the payment_page_confirm fixture as I mentioned previously?
How do I do that?
I think it looks something like this --> --override payment_page_confirm:custom_fields[].custom_field_id=${checkout_session.custom_fields.<some index value>.value}
Not sure if that actually works, just guessing based on the docs (apologies, Discord is busy so I haven't run on my end yet)
Play around with that and I'll try to circle back if you aren't able to get it working
sure
ok so the issue is
the response that comes from /v1/checkout/sessions
doesn't contain the custom_field_id
there's no refence to any custom_field_id beforehand
so i don't really know the path
Do you need to expand the custom_fields array to get it in the response maybe?
maybe
but even if thats the case
how would i make the stripe trigger command expand
Ah, apologies, I was looking at the POST request parameters.
I think the solution for this is (unfortunately) to write your own fixture to simulate this scenario, such that your Checkout Session returns custom_fields that you can then reference later on in the fixture
how do I even do that though
sorry i dont have much experience with the stripe cli
Hi ๐
I usually don't send folks to StackOverflow, but this is kind of a new thing and documentation is a little sparse. This SO article does a good job of explaining at a high-level how you can most easily set up a fixture by modifying an existing one: https://stackoverflow.com/questions/59745126/using-fixtures-with-stripe-cli
Aside from that, here are the canonical docs on creating and using fixtures: https://stripe.com/docs/cli/fixtures
I have to step away now, but you're in good hands with snufkin
I think once you get your head around writing fixtures for the CLI it will allow you to build some pretty robust tests.
You can also look here to see the actual fixture JSON files the Stripe CLI uses already: https://github.com/stripe/stripe-cli/tree/master/pkg/fixtures/triggers
I review these to get an idea of how to build my own.
i think im running into a bug with the stripe cli
here's my custom fixture:
{
"name": "checkout_session",
"path": "/v1/checkout/sessions",
"method": "post",
"params": {
"success_url": "https://httpbin.org/post",
"cancel_url": "https://httpbin.org/post",
"mode": "payment",
"line_items": [
{
"price": "${price:id}",
"quantity": 2
}
],
"payment_intent_data": {
"shipping": {
"name": "Jenny Rosen",
"address": {
"line1": "510 Townsend St",
"postal_code": "94103",
"city": "San Francisco",
"state": "CA",
"country": "US"
}
}
},
"custom_fields": [
{
"key": "discordnamenumber",
"type": "text",
"optional": "false",
"label": {
"custom": "Discord Username (e.g. SeanPixel#1234)",
"type": "custom"
}
}
]
}
}
when I try to run it, I receive this error:
and when I scroll down in the logs, I find that this request was actually sent:
@jagged aurora
I'm digging to see if there's some non-intuitive syntax required in the fixture file
alright
Still digging, I can replicate your error though
๐
to be honest i can't even find a single endpoint that returns a custom_field id
Even if this issue if fixed, idk where I can find it
You'd need to return the entire Checkout session object
how so?
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
the Checkout Session object doesn't even have a place for custom_field_id
i suspect it's returned from this fixture:
{
"name": "payment_page",
"path": "/v1/payment_pages/${checkout_session:id}",
"method": "get"
},
Issue is idk how to access the response
because stripe logger doesn't save output for get requests
I tried searching for payment pages on the Stripe API docs and theres nothing
I"m a little confused here. The custom_fields array exists on the Checkout Session object. You can't look them up by ID but you can iterate over them and look for the key value
Okay but I'm going to raise the label issue as a bug internally
but the payment_page_confirm fixture requires a custom_field_id
What are you referring to there? This is fixture runs just fine:
{
"name": "payment_page_confirm",
"path": "/v1/payment_pages/${checkout_session:id}/confirm",
"method": "post",
"params": {
"payment_method": "${payment_method:id}",
"expected_amount": 3000
}
}
but if I include a custom_field for the checkout_session fixture using this command, it'll then require it
wait so it is not possible to create an array using fixtures
i figured it out
There were a couple bugs with the Stripe CLI though
and honestly its a little bit hacky
_ _
First off, I stopped using fixtures because of the bug mentioned earlier
I needed to set a specific value to an array, but as shown earlier, the stripe CLI can't create arrays from fixture json files
I went back to using the stripe trigger command because it ran almost identical fixtures to the ones i was working on
Here is my final command that works:
stripe trigger checkout.session.completed --override checkout_session:custom_fields[]=text --override checkout_session:custom_fields[].key=discordnamenumber --override checkout_session:custom_fields[].label.type=custom --override checkout_session:custom_fields[].label.custom="Discord Username (e.g. SeanPixel#1234)" --override checkout_session:custom_fields[].optional=false --override checkout_session:custom_fields[].type=text --override payment_page_confirm:custom_fields[].custom_field_id=${payment_page:custom_fields.0.id} --override payment_page_confirm:custom_fields[].text="okay#2996"
As I suspected earlier as well, I was right
The custom_field_id was actually in the payment_page fixture
I couldn't find a direct way to access the data inside the fixture, so I kinda just guessed random json paths until I got it: payment_page:custom_fields.0.id
then i just put that all together into this one giant trigger command
let me know if this makes sense to yall
there was some major issues that I had to work around to get this to work
๐ Taking over this thread, catching up now
sure, take your time
the issue is solved now, but I think there are a couple bugs/issues that needs to be reported
Thanks for sharing the solutions and glad that it works now. We will share the feedback to the team