#botbda-checkout-email
1 messages · Page 1 of 1 (latest)
Hey @errant tide can you share more details? Like what do you see in the API itself when you try and look at the raw JSON for it?
so I'm calling the checkout page like this
<script type="text/javascript">
function GrabMFLID () {
var UserMFLID = document.getElementById("MFLID").value;
var url = "purchase-checkout.php?session_id={CHECKOUT_SESSION_ID}&MFLID=" + UserMFLID;
document.write(url);
window.location.href=url;
}
</script>
which passes the session ID as well as another parameter in the URL
and then I setup the checkout session
$checkout_session = \Stripe\Checkout\Session::create([
'line_items' => [[
# Provide the exact Price ID (e.g. pr_1234) of the product you want to sell
'price' => 'price_1LZcocKs11D5pGt5xj4ztizI',
'quantity' => 1,
]],
'mode' => 'payment',
'success_url' => $YOUR_DOMAIN . '/new-purchase-success.php?session_id={CHECKOUT_SESSION_ID}',
'cancel_url' => $YOUR_DOMAIN . '/cancel.html',
"metadata" => ["MyFantasyLeagueID" => $MFLID],
//"customer_email" => null,
'automatic_tax' => [
'enabled' => false,
],
]);
and now I want to grab the customer email from the stripe checkout page
https://stripe.com/docs/api/checkout/sessions/object#checkout_session_object-customer_details-email the property is named email your code seems to use customer_email
so I use this
$checkout_session = $stripe->checkout->sessions->retrieve(
$_GET['session_id'],
);
to retrieve the session ID
echo "ID = " . $checkout_session->metadata->MyFantasyLeagueID;
this above - works great passing the metadata through
this doesn't work
echo "Email = " . $checkout_session->customer_email->email;
stepping in here and reading, give me a sec!
ok thanks
can you share a CheckoutSession ID from an example?
the ID of the CheckoutSession, the one you're retrieving from the Stripe API
Session = Stripe\Checkout\Session JSON: {
"id": "cs_test_a1CUlayVtmTbOule3lNexLdW2AZfIE7ork6cu22NokXWag60n22MAHyzIV",
oh that was actually helpful
I figured out how to get it from that lol
nice!
ya and now I have 2 more questions lol
go for it
a) is email a required field on the checkout page and if not can I make it?
botbda-checkout-email
and the other questions is:
amount_total is giving me a number with no decimal places. So the price which is 29.99 is being returned as 2999
can you share an example? sorry your question wasn't clear
which question
Stripe\Checkout\Session JSON: {
"id": "cs_test_a1CUlayVtmTbOule3lNexLdW2AZfIE7ork6cu22NokXWag60n22MAHyzIV",
"object": "checkout.session",
"after_expiration": null,
"allow_promotion_codes": null,
"amount_subtotal": 2999,
"amount_total": 2999,
"automatic_tax": {
"enabled": false,
"status": null
},
see amount_total is 2999 and not 29.99
expected, Stripe amount is in integer representing lowest denomination of a currency: https://stripe.com/docs/api/charges/create#create_charge-amount (this is Charges but just linking you the explanation)
e.g. if you want to charge $106.99 , you pass 10699 as the amount
yeah that's fine, but how do I display it as currency?
just take that and divide by the lowest common denominator, for usd it would be "divide by 100"
oh yaaa duh
ok thanks
the other question was about email
is the email field on the checkout page mandatory?
yes