#okay

1 messages ยท Page 1 of 1 (latest)

lilac forgeBOT
plain ledge
#

Taking a look. Will circle back in a couple minutes

heady spindle
#

thanks

plain ledge
#

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?

heady spindle
#

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

plain ledge
#

So payment_page_confirm is a fixture that you are adding to the end of your command?

heady spindle
#

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

plain ledge
heady spindle
#

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

plain ledge
#

You mentioned payment_page_confirm is a fixture. You presumably wrote it yourself, yes?

heady spindle
#

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
plain ledge
#

Got it, okay

heady spindle
#

so since the last fixture was making an error (missing custom field), I'm assuming I just need to do some overrides

plain ledge
#

Have you tried referencing the attribute from the payment_page_confirm fixture as I mentioned previously?

plain ledge
#

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

heady spindle
#

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

plain ledge
heady spindle
#

maybe

#

but even if thats the case

#

how would i make the stripe trigger command expand

plain ledge
#

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

heady spindle
#

sorry i dont have much experience with the stripe cli

jagged aurora
#

Hi ๐Ÿ‘‹

plain ledge
#

I have to step away now, but you're in good hands with snufkin

jagged aurora
#

I think once you get your head around writing fixtures for the CLI it will allow you to build some pretty robust tests.

heady spindle
#

let me try my hand at these

#

might have a few questions though

heady spindle
#

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

jagged aurora
#

I'm digging to see if there's some non-intuitive syntax required in the fixture file

heady spindle
#

alright

jagged aurora
#

Still digging, I can replicate your error though

heady spindle
#

๐Ÿ‘

#

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

jagged aurora
#

You'd need to return the entire Checkout session object

heady spindle
#

how so?

#

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

jagged aurora
#

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

heady spindle
#

but the payment_page_confirm fixture requires a custom_field_id

jagged aurora
#

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
      }
    }
heady spindle
#

but if I include a custom_field for the checkout_session fixture using this command, it'll then require it

heady spindle
lilac forgeBOT
heady spindle
#

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

heady spindle
#

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

rich sandal
#

๐Ÿ‘‹ Taking over this thread, catching up now

heady spindle
#

sure, take your time

#

the issue is solved now, but I think there are a couple bugs/issues that needs to be reported

rich sandal
#

Thanks for sharing the solutions and glad that it works now. We will share the feedback to the team