#romero-cli-json
1 messages ยท Page 1 of 1 (latest)
Can you give a bit more details? What's not "opening"? What are you doing/exact command/seeing?
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.
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
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
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?
Yeah it was working fine for me a min ago, will do that ๐
are you opening VS Code with admin privileges?
No, but I don't remember how I installed it years ago,
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 ๐ฆ
yeah feels like something broke the fixture locally. Try uninstalling the extension and the CLI first
how do I uninstall the CLI ?
depends on your machine I assume, I installed mine with brew
I've only downloaded the stripe.exe and pointed the path to it
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
Where do the fixtures file should be located?
I don't know for Windows, I assume they are inside the .exe
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 ?
no you don't, just some of our examples are using it, it's rare. I don't use any framework
Cool, I don't want to ๐
most of our samples shouldn't use Slim anymore
the only one I'm trying to use, it does I guess lol
the function withJson comes from the Slim framework, right?
not sure, where do you see this? we have thousands of docs/examples :p
yeah... I wish we didn't have examples with frameworks
basically whatever you have as a "route" there is what matters
Look at https://stripe.com/docs/webhooks/quickstart which is our canonical example for all languages for a webhook handler which has no route logic
Thanks! Will try! I'm migrating from another API lots of work to do
Sounds good!
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.
that's a picture of code :p
let me share the code itself
if you share code as real text + say the question I can likely help
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
]);
});```
'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
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
everything else is fluff around the example code/Slim
right, how do I initialize $stripe ?
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
https://github.com/stripe/stripe-php/wiki/Migration-to-StripeClient-and-services-in-7.33.0 for the long explanation
Oh! Let me try it!
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