Click here to Skip to main content
15,851,131 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
hi i was trying to convert code from ruby to PHP slim and want to send data from PHP slim with help of to Json

<pre lang="PHP"><pre>$app->get('/order-info', function (Request $request, Response $response) {
  $session = \Stripe\Checkout\Session::retrieve($request->get('session_id'));
  $customer = \Stripe\Customer::retrieve($session->customer);
    session: session,
    customer: customer


and in javascript to receive
<pre>document.addEventListener('DOMContentLoaded', async () => {
    var urlParams = new URLSearchParams(;
    var sessionId = urlParams.get('session_id');
    if (sessionId) {
        const {customer, session} = 
            await fetch(`order-info?session_id=${sessionId}`)
                .then((r) => 

Checkout 101: Build a custom order confirmation page with Checkout (Ruby) - YouTube[^]
this the link for reference what am I doing

What I have tried:

i have tried this maybe you can help me out if there is some mistake or need some changes to succeed
  $app->get('/order-info', function (Request $request, Response $response) {
    $session = \Stripe\Checkout\Session::retrieve($request->get('session_id'));
    $customer = \Stripe\Customer::retrieve($session->customer);

    return $response->withJson([ 'session' => $session->session, 'customer' => $customer->customer]);


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900