#Stephane

1 messages ยท Page 1 of 1 (latest)

radiant ospreyBOT
little light
#

Are you using some kind of plugin/third-party?

#

You'll need to help me understand what is the 'domain' in this instance?

#

How are you integrating with Stripe

tribal sail
#

no the standard test that I use

little light
#

but impossible to setlle the key of the second account on this domain
I don't know what this means

tribal sail
#

works....

#

can you try?

#

I use the key of account 1 !
If I use on this domaine the key of account 2 this is not working!

little light
#

That URL doesn't work for me, I see errors when I click the button

tribal sail
little light
#

Your endpoint to create the Payment Intent is returning this error:
"Return value of calculateOrderAmount() must be of the type int, null returned"

tribal sail
#

why is it working on my place?

little light
#

I've no idea, you'd need to workout where that error is thrown from

tribal sail
#

so in your place you don't see the form at all?

little light
#

I don't. The API call to create the Payment Intent fails so the Payment Element can't initialise without the client_secret:

in order to create a payment element, you must pass a valid PaymentIntent or SetupIntent client secret when creating the Elements group.

  e.g. stripe.elements({clientSecret: "{{CLIENT_SECRET}}"})
tribal sail
#

That is crasy this work at my place

drowsy kernel
#

๐Ÿ‘‹ taking over for my colleague. Let me know if there's any follow-up Qs I can answer!

tribal sail
#

I simpe use the code from Stripe

#

this is the code from the doc...

#

work on my machine... but not on my phone!

#

Got crasy

drowsy kernel
#

what exactly didn't work on your phone?

#

there's an error in your Php code

#

as my colleague explained

#

maybe you didn't push your code to your server

#

this happens between different environments

tribal sail
#

the code is on the server...

#

On chrome work

#

safari as well

drowsy kernel
#

I just tested it on chrome

#

it didn't

tribal sail
#

opera mot

drowsy kernel
#

It's not browser related

tribal sail
#

and on my photo not work at all

drowsy kernel
tribal sail
#

but i copy that from Stripe

drowsy kernel
#

would you please share your backend code?

tribal sail
#

<?php

require '../vendor/autoload.php';

// This is your test secret API key.
//
\Stripe\Stripe::setApiKey('sk_xxxxxxxx');

function calculateOrderAmount(array $items): int {
// Replace this constant with a calculation of the order's amount
// Calculate the order total on the server to prevent
// people from directly manipulating the amount on the client
return 2400;
}

header('Content-Type: application/json');

try {
// retrieve JSON from POST body
$jsonStr = file_get_contents('php://input');
$jsonObj = json_decode($jsonStr);

// Create a PaymentIntent with amount and currency
$paymentIntent = \Stripe\PaymentIntent::create([
    'amount' => calculateOrderAmount($jsonObj->items),
    'currency' => 'eur',
    'automatic_payment_methods' => [
        'enabled' => true,
    ],
]);

$output = [
    'clientSecret' => $paymentIntent->client_secret,
];

echo json_encode($output);

} catch (Error $e) {
http_response_code(500);
echo json_encode(['error' => $e->getMessage()]);
}

#

on my place work with a key and not with the other...

#

for this reason was thining related to the domain where my code is hosted

#

if I change
await fetch("/create.php", {...
with
await fetch("../create.php", {
Where my create located not work as well for me

#

ohhh if I try a test card is it going to my local server ๐Ÿ˜ฆ

drowsy kernel
#

it's not about test cards

#

on the server where the URL you sent is running, the code is not executing correctly

#

you need to check that

tribal sail
#

but that is not my code... that the one from Stripe

drowsy kernel
#

you need to try to debug the code yourself

#

add some breakpoints or some logging