I need help with find the equivalent of the following curl request in Crystal. Would be great if it could be done with the Halite library (because it is really great and easy to use other than the issue I am having here), but another solution would be great too.
This is the example curl request on the Stripe page (here):
curl https://api.stripe.com/v1/checkout/sessions \
-u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
-d payment_method_types[]=card \
-d line_items[][name]=T-shirt \
-d line_items[][description]="Comfortable cotton t-shirt" \
-d line_items[][images][]="https://example.com/t-shirt.png" \
-d line_items[][amount]=500 \
-d line_items[][currency]=usd \
-d line_items[][quantity]=1 \
-d success_url="https://example.com/success" \
-d cancel_url="https://example.com/cancel"
I tried the following using the Halite library:
resp = Halite.auth("Bearer sk_test_Apikeyhere")
.post("https://api.stripe.com/v1/checkout/sessions", form: {
"payment_method_types[]" => ["card"],
"line_items[]" => [{"name" => "awesomeitem",
"description" => "short description",
"amount" => 699,
"currency" => "usd",
"quantity" => 1}],
"success_url" => "http://localhost:3000",
"cancel_url" => "https://localhost:3000"
})
I get the following error in response:
{
"error": {
"message": "Invalid hash",
"param": "line_items[0]",
"type": "invalid_request_error"
}
}
The line_items parameter help on Stripe is here:
https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-line_items
Thank you for your help.