#Tony-Checkout

1 messages ยท Page 1 of 1 (latest)

icy bluff
#

Hi Tony, can you tell me more about the problem? You want to pass amount as a param to create.php ?

fresh silo
#

yes

#

I did this but it is not working

#

let me send you my code

icy bluff
#

sure, the code will be helpful

fresh silo
#

I checkout.js function on nxt click button I am trying to send the amount value to the create.php using ajax

#

but somehow it is always picking default value

#

dont know why

icy bluff
#

Please remove the publishable key from your code that you pasted as Discord is a public channel

#
    // 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
    if(!empty($amount)){
        return $amount;
    }
    else{
    return 2500;
    }
}

I don't see the $amount param being passed to the fetch("/create.php" in line 42 or checkout.js

#

That's why it stays in the default value

fresh silo
#

I am passing amount through ajax in checkout.js

#

check that file

icy bluff
#

Can you put some logs and see whether this ajax is called before initialize()?

fresh silo
#

check this url

#

it first goes to nxt click then it initializes the js file

#

I checked that

#

thats why it takes time to load the stripe form in there

#

you can test in there

icy bluff
#

I'd recommend put some logs in calculateOrderAmount to make sure that the $amount is not empty.

fresh silo
#

okay going to do the test now then will ask you