#botbda-checkout-email

1 messages · Page 1 of 1 (latest)

final shale
#

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?

errant tide
#

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

final shale
errant tide
#

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;
turbid hound
#

stepping in here and reading, give me a sec!

errant tide
#

ok thanks

turbid hound
#

can you share a CheckoutSession ID from an example?

errant tide
#

sure

#

what do you mean like the actual session ID?

turbid hound
#

the ID of the CheckoutSession, the one you're retrieving from the Stripe API

errant tide
#
Session = Stripe\Checkout\Session JSON: {
    "id": "cs_test_a1CUlayVtmTbOule3lNexLdW2AZfIE7ork6cu22NokXWag60n22MAHyzIV",
#

oh that was actually helpful

#

I figured out how to get it from that lol

turbid hound
#

nice!

errant tide
#

ya and now I have 2 more questions lol

turbid hound
#

go for it

errant tide
#

a) is email a required field on the checkout page and if not can I make it?

turbid hound
#

botbda-checkout-email

errant tide
#

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

turbid hound
#

can you share an example? sorry your question wasn't clear

errant tide
#

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

turbid hound
#

e.g. if you want to charge $106.99 , you pass 10699 as the amount

errant tide
#

yeah that's fine, but how do I display it as currency?

turbid hound
#

just take that and divide by the lowest common denominator, for usd it would be "divide by 100"

errant tide
#

oh yaaa duh

#

ok thanks

#

the other question was about email

#

is the email field on the checkout page mandatory?

turbid hound
#

yes

errant tide
#

great

#

that's all I got for now!

#

thanks for your help