Actually, the problem is simple (but not easy for me). I’ve made a backend project in laravel 11 to handle with my DB and comunicate with the Stripe api, that I have successfully achieved, the communication wit stripe works well, however, when i test it using Postman, the response that i recieve is the following:
{
"error": "The amount must be greater than or equal to the minimum charge amount allowed for your account and the currency set (https://docs.stripe.com/currencies#minimum-and-maximum-charge-amounts). If you want to save a Payment Method for future use without an immediate payment, use a Setup Intent instead: https://docs.stripe.com/payments/setup-intents"
}
And what i send from postman using the POST petition is:
{
"amount": 2434,
"currency": "usd"
}
As you can see, there are only tow values and when the response says “The amount must be greater than or equal to the minimum charge amount allowed for your account” refers to my “amount” key from my json object. ive checked the stripe docs and they say that the minimum quantity value of of the usd currency is $0.50 dollars, so i’m in the range. but also the usd comes to my api like undefined.
In the other hand if i do hardcoding of theese two values, the response i reseive is the following:
{
"message": "Payment successful"
}
wich means that my code acctually work but just using hardcoding, wich i don’t wanna use.
As far as i know, i’m not making any mistake in my code, because i’m doint wath the doc say, that makes me think that the problem is something more strange like a configuration or an error into my framework’s file sistem, but that’s just my speculation.
This is the route I defined in mu api.php file to access the endpiont from postman:
Route::post('/create-checkout-session', [AppHttpControllerspaymentController::class, 'payment']);
and this is my controller that where stripe works:
<?php
namespace AppHttpControllers;
use Exception;
use illuminateHttpRequest;
class paymentController extends Controller
{
public function payment(Request $request)
{
try {
$stripe = new StripeStripeClient(env('STRIPE_SECRET'));
$stripe->paymentIntents->create([
'amount' => intval($request->input('amount')),
'currency' => $request->input('currency'),
'automatic_payment_methods' => ['enabled' => true],
]);
return response()->json([
'message' => 'Payment successful',
], 200);
} catch (Exception $e) {
return response()->json([
'error' => $e->getMessage()
], 500);
}
}
}
iv’e tried using code a little bit different like this in the function, but the result was exactly the same:
$stripe = new StripeStripeClient([
'api_key' => env('STRIPE_SECRET')
]);
$stripe->paymentIntents->create([
'amount' => intval($request->input('amount')),
// 'amount' => 1000,
'currency' => $request->input('currency'),
// 'currency' => "usd",
'automatic_payment_methods' => ['enabled' => true],
]);
Acording to what i expect from the code, is to be able to catch the info that comes to my from the front (or postman) to send it to the stripe api avoiding using the “hardcoding” practice and continue developing my payment system, which i can’t becuase all i receive in the request is empty (null or undefined).
TheBicMF is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.