#csolis - Installments
1 messages · Page 1 of 1 (latest)
¡Hola! No podemos ayudar en español aquí, pero Stripe Support puede ayudarlo en español: https://support.stripe.com/contact
OK
have a problem with payment to months without interest in Mexico, could you help me?
plans installments
Maybe! What's your question?
I have the payment options of one payment, 3,6,9 and 12 months.
but when I select a single payment it sends me an error in the json and destroys the whole development.
What's the error?
Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0
Later
Right, but what's the actual error that was sent instead of the JSON you expected?
const response = await fetch('assets/js/confirm_payment.php', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
payment_intent_id: intentId,
selected_plan: selectedPlan,
}),
});
It sounds like you're trying to fetch a specific Payment Intent from the API but the ID you're passing in is blank.
In your server-side code do you have code that's trying to get a Payment Intent by it's ID?
Yeah, so this code:
$intent = \Stripe\PaymentIntent::retrieve(
$json_obj['payment_intent_id']
);```The problem is that `$json_obj['payment_intent_id']` is actually blank.
You should add validation code to make sure it's not blank before calling the Stripe code, and you should wrap the Stripe code in a try...catch block and return a JSON error if something goes wrong there.
And then handle the JSON error on your frontend.
Also, you shared your secret test key above, so you'll probably want to roll that to make sure no one else can do anything to your test data.
Does that help?
Which documentation?
That's sample code designed to get you started. It should work fine, but there's a lot of validation and error handling code you would need to add before going to production.
In your client side code do you have exactly this code: fetch('/collect_details', {?
If I leave fetch('/collect_details' it is destroyed.
I changed it to fetch('assets/js/confirm_payment.php', { only this way it works
Do you have your server configured to map the /collect_details URI to the PHP code running on your server?
Okay, that should work if that's where you put the code.
So does this help you fix the issue? Are you unblocked?
csolis - Installments