#romero-cli-json

1 messages ยท Page 1 of 1 (latest)

white chasm
#

Can you give a bit more details? What's not "opening"? What are you doing/exact command/seeing?

versed raven
#

I'm running the Stripe CLI in VS Code, and a minute ago it would open a Json file with the parameters. Now it only says: Fixture template for customer.created loaded.
and nothing happens.

white chasm
#

hum I'm sorry I don't understand what that could mean. What does "open a JSON file with the parameters" mean? I asked my team but none of us understand yet which feature you are referring to

versed raven
#

Sorry If I'm not clear enough: Let me share some SS's

#

Before, when I pressed any dropdown menu button, this would open a file called: fixture.template " whatever " so I could update the parameters.

#

Now, for some reason, I don't have that option to change the parameters since the file does not load.

#

I can still trigger the event tho

white chasm
#

so you click on that create thing on the left, choose an event and it fails?

#

I just installed the extension from scratch and it works for me at least. Have you tried uninstalling/reinstalling it to start?

versed raven
#

Yeah it was working fine for me a min ago, will do that ๐Ÿ˜„

white chasm
#

let me know

#

I just tried a few and they all work

versed raven
#

are you opening VS Code with admin privileges?

white chasm
#

No, but I don't remember how I installed it years ago,

versed raven
#

No luck reinstalling yet

#

:/

white chasm
#

Maybe reboot or something, feels more like a permission issue than anything else since it can't find that file

#

Sorry I don't really know how to debug that specific extension in vscode ๐Ÿ˜ฆ

versed raven
#

if I trigger the event:

#

will restart real quick ๐Ÿ˜„

white chasm
#

yeah feels like something broke the fixture locally. Try uninstalling the extension and the CLI first

versed raven
#

how do I uninstall the CLI ?

white chasm
#

depends on your machine I assume, I installed mine with brew

versed raven
#

I've only downloaded the stripe.exe and pointed the path to it

white chasm
#

ah so you're on Windows

#

Unfortunately I really don't know much about Windows permissions and the environment

#

try deleting that exe and re-downloading it

versed raven
#

Where do the fixtures file should be located?

white chasm
#

I don't know for Windows, I assume they are inside the .exe

versed raven
#

I see! Hey thanks for your help!

#

Also, if you don't mind

#

to use Stripe API with PHP do I need to use Slim ?

white chasm
#

no you don't, just some of our examples are using it, it's rare. I don't use any framework

versed raven
#

Cool, I don't want to ๐Ÿ˜„

white chasm
#

most of our samples shouldn't use Slim anymore

versed raven
#

the only one I'm trying to use, it does I guess lol

#

the function withJson comes from the Slim framework, right?

white chasm
#

not sure, where do you see this? we have thousands of docs/examples :p

white chasm
#

yeah... I wish we didn't have examples with frameworks

#

basically whatever you have as a "route" there is what matters

versed raven
#

Thanks! Will try! I'm migrating from another API lots of work to do

white chasm
#

Sounds good!

versed raven
#

Would you be able to assist with the following:

I need not to use the Slim framework.

I'm making a post request using Jquery to the server.

white chasm
#

that's a picture of code :p

versed raven
#

let me share the code itself

white chasm
#

if you share code as real text + say the question I can likely help

versed raven
#
    Request $request,
    Response $response,
    array $args
) {
    $body = json_decode($request->getBody());
    $stripe = $this->stripe;
    $customer_id = $_COOKIE['customer'];
    $price_id = $body->priceId;

    // Create the subscription. Note we're expanding the Subscription's
    // latest invoice and that invoice's payment_intent
    // so we can pass it to the front end to confirm the payment
    $subscription = $stripe->subscriptions->create([
        'customer' => $customer_id,
        'items' => [[
            'price' => $price_id,
        ]],
        'payment_behavior' => 'default_incomplete',
        'payment_settings' => ['save_default_payment_method' => 'on_subscription'],
        'expand' => ['latest_invoice.payment_intent'],
    ]);

    return $response->withJson([
      'subscriptionId' => $subscription->id,
      'clientSecret' => $subscription->latest_invoice->payment_intent->client_secret
    ]);
});```
white chasm
#
        'customer' => $customer_id,
        'items' => [[
            'price' => $price_id,
        ]],
        'payment_behavior' => 'default_incomplete',
        'payment_settings' => ['save_default_payment_method' => 'on_subscription'],
        'expand' => ['latest_invoice.payment_intent'],
    ]);```
#

this is purely the Stripe call

versed raven
#

idea would be collecting the data from the post request, then transferring into the subscription creation method, but I'm not sure how to initialize that without an object

white chasm
#

everything else is fluff around the example code/Slim

versed raven
#

right, how do I initialize $stripe ?

white chasm
#

ah that

#

basically our stripe-php library uses a "client/service" pattern

#

the idea is you initialize it once somewhere globally and use that client everywhere

versed raven
#

Oh! Let me try it!

white chasm
#

and it's basically just $stripe = new \Stripe\StripeClient('sk_test_your_key');

#

the idea is to avoid doing this on every call if you have an overall structured app

#

I learnt PHP 15 years ago so a lot of my scripts are just one-off scripts and they all include my config.php that does all my inits

versed raven
#

Yeah I also use a config.php

#

I'm an enthusiast ๐Ÿ˜„

#

Still a lot to learn

#

but yeah, it worked like a charm, thank you so much.