Skip to content
On this page

Customize your success page

Learn how to display a confirmation page with your customer's order information.

Build an integration to accept a payment with Checkout before using this guide.

You can use the details from a Checkout Session to display an order confirmation page for your customer (for example, their name or payment amount) after the payment. To use the details from a Checkout Session:

  1. Modify the success_url to pass the Checkout Session ID to the client side.
  2. Look up the Checkout Session using the ID on your success page.
  3. Use the Checkout Session to customize what’s displayed on your success page.

Modify the success URLServer-side

Add the {CHECKOUT_SESSION_ID} template variable to the success_url when you create the Checkout Session. Note that this is a literal string and must be added exactly as you see it here. Do not substitute it with a Checkout Session ID—this happens automatically after your customer pays and is redirected to the success page.

ruby
session = Payske::Checkout::Session.create(
  success_url: "http://yoursite.com/order/success",    
  success_url: "http://yoursite.com/order/success?session_id={CHECKOUT_SESSION_ID}",    
  # other options...,
)
python
session = payske.checkout.Session.create(
  success_url="http://yoursite.com/order/success",    
  success_url="http://yoursite.com/order/success?session_id={CHECKOUT_SESSION_ID}",    
  # other options...,
)
php
$session = $payske->checkout->sessions->create([
  'success_url' => "http://yoursite.com/order/success",    
  'success_url' => "http://yoursite.com/order/success?session_id={CHECKOUT_SESSION_ID}",    
  // other options...,
]);
java
Map<String, Object> params = new HashMap<>();
params.put(
  "success_url",
  "http://yoursite.com/order/success",    
  "http://yoursite.com/order/success?session_id={CHECKOUT_SESSION_ID}",    
);
params.put(
  // other options...
);
Session session = Session.create(params);
typescript
const session = await payske.checkout.sessions.create({
  success_url: "http://yoursite.com/order/success",    
  success_url: "http://yoursite.com/order/success?session_id={CHECKOUT_SESSION_ID}",    
  // other options...,
});
go
params := &payske.CheckoutSessionParams{
  SuccessURL: payske.String("http://yoursite.com/order/success"),    
  SuccessURL: payske.String("http://yoursite.com/order/success?session_id={CHECKOUT_SESSION_ID}"),     
  // other options...
);
s, _ := session.New(params)
csharp
var options = new SessionCreateOptions
{
  SuccessUrl = "http://yoursite.com/order/success",    
  SuccessUrl = "http://yoursite.com/order/success?session_id={CHECKOUT_SESSION_ID}",    
  // other options...
};
var service = new SessionService();
var session = service.Create(options);

Create the success pageServer-side

Next, look up the Checkout Session using the ID and create a success page to display the order information. This example prints out the customer’s name:

ruby
# This example sets up an endpoint using the Sinatra framework.

# Set your secret key. Remember to switch to your live secret key in production.
# See your keys here: https://account.payske.com/api/key
Payske.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'

require 'sinatra'

get '/order/success' do
  session = Payske::Checkout::Session.retrieve(params[:session_id])
  customer = Payske::Customer.retrieve(session.customer)

  "<html><body><h1>Thanks for your order, #{customer.name}!</h1></body></html>"
end
python
# This example sets up an endpoint using the Flask framework.

import os
import payske

from flask import Flask, request, render_template_string

app = Flask(__name__)

# Set your secret key. Remember to switch to your live secret key in production.
# See your keys here: https://account.payske.com/api/key
payske.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'

@app.route('/order/success', methods=['GET'])
def order_success():
  session = payske.checkout.Session.retrieve(request.args.get('session_id'))
  customer = payske.Customer.retrieve(session.customer)

  return render_template_string('<html><body><h1>Thanks for your order, {{customer.name}}!</h1></body></html>', customer=customer)

if __name__== '__main__':
  app.run(port=4242)
php
<?php
require 'vendor/autoload.php';
$payske = new \Payske\PayskeClient('sk_test_4eC39HqLyjWDarjtT1zdp7dc');

try {
  $session = $payske->checkout->sessions->retrieve($_GET['session_id']);
  $customer = $payske->customers->retrieve($session->customer);
  echo "<h1>Thanks for your order, $customer->name!</h1>";
  http_response_code(200);
} catch (Error $e) {
  http_response_code(500);
  echo json_encode(['error' => $e->getMessage()]);
}
java
import static spark.Spark.get;
import static spark.Spark.port;

import com.payske.Payske;
import com.payske.model.checkout.Session;
import com.payske.model.Customer;

public class Server {
  public static void main(String[] args) {
    port(4242);

    // Set your secret key. Remember to switch to your live secret key in production.
    // See your keys here: https://account.payske.com/api/key
    Payske.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";

    get("/order/success", (request, response) -> {
      Session session = Session.retrieve(request.queryParams("session_id"));
      Customer customer = Customer.retrieve(session.getCustomer())

      return "<html><body><h1>Thanks for your order, " + customer.getName() + "!</h1></body></html>";
    });
  }
}
typescript
// This example sets up an endpoint using the Express framework.

const express = require('express');
const app = express();

// Set your secret key. Remember to switch to your live secret key in production.
// See your keys here: https://account.payske.com/api/key
const payske = require('payske')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');

app.get('/order/success', async (req, res) => {
  const session = await payske.checkout.sessions.retrieve(req.query.session_id);
  const customer = await payske.customers.retrieve(session.customer);

  res.send(`<html><body><h1>Thanks for your order, ${customer.name}!</h1></body></html>`);
});

app.listen(4242, () => console.log(`Listening on port ${4242}!`));
go
package main

import (
  "net/http"

  "github.com/labstack/echo"
  "github.com/labstack/echo/middleware"
  "github.com/payske-dev/payske-go/v72"
  "github.com/payske-dev/payske-go/v72/customer"
  "github.com/payske-dev/payske-go/v72/checkout/session"
)

// This example sets up an endpoint using the Echo framework.

func main() {
  // Set your secret key. Remember to switch to your live secret key in production!
  // See your keys here: https://account.payske.com/api/key
  payske.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"

  e := echo.New()
  e.Use(middleware.Logger())
  e.Use(middleware.Recover())

  e.GET("/order/success", orderSuccess)

  e.Logger.Fatal(e.Start("localhost:4242"))
}

func orderSuccess(c echo.Context) (err error) {
  s, _ := session.Get(c.QueryParam("session_id"), nil)
  cus, _ := customer.Get(s.Customer.ID, nil)

  return c.String(http.StatusOK, "<html><body><h1>Thanks for your order, " + cus.Name + "!</h1></body></html>")
}
csharp
// This example sets up an endpoint using the ASP.NET MVC framework.

using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using Payske;
using Payske.Checkout;

namespace server.Controllers
{
  public class SuccessController : Controller
  {
    public SuccessController()
    {
      // Set your secret key. Remember to switch to your live secret key in production!
      // See your keys here: https://account.payske.com/api/key
      PayskeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";
    }

    [HttpGet("/order/success")]
    public ActionResult OrderSuccess([FromQuery] string session_id)
    {
      var sessionService = new SessionService();
      Session session = sessionService.Get(session_id);

      var customerService = new CustomerService();
      Customer customer = customerService.Get(session.CustomerId);

      return Content($"<html><body><h1>Thanks for your order, {customer.Name}!</h1></body></html>");
    }
  }
}

Test the integration

  1. Click your checkout button and fill in the customer name (for example, “Jenny Rosen”) and the remaining payment details.
  2. Click Pay.

You should be redirected to the success page, and see Thanks for your order, Jenny Rosen!