Checkout · Home > Payments > Payske Checkout
How Checkout works
Learn how to add a Checkout page to your website and collect payments.
Add a Payske-hosted payment page that accepts one-time payments and Subscriptions using Checkout’s low-code integration. Checkout’s prebuilt features allow you to reduce your development time. Use the Checkout Session API and the Payske Dashboard to access additional functionality and customize Checkout for your business. For a complete list of features, see the built-in and customizable features.
Before you begin, learn about these features:
Checkout lifecycle
The basic lifecycle for a customer’s Checkout experience looks like this:
- When customers are ready to complete their purchase, your application creates a new Checkout Session.
- The Checkout Session provides a URL that redirects customers to a Payske-hosted payment page.
- Customers enter their payment details on the payment page and complete the transaction.
- After the transaction, a webhook fulfills the order using the checkout.session.completed event.
A diagram of a Checkout integration's lifecycle
Low-code integration
Checkout requires minimal coding and is the best choice for most integrations because of its prebuilt functionalities and customization options. You can integrate Checkout by creating a Checkout Session and redirecting customers to a Payske-hosted page for collecting payment details.
Compare Checkout to other Payske payment options to determine which option meets your requirements.
Built-in and customizable features
Payske Checkout has the following built-in and customizable features:
Built-in features
- Google Pay, Apple Pay, and Link
- Responsive mobile design
- SCA-ready
- CAPTCHAs
- PCI compliance
- Card validation
- Error messaging
- Adjustable quantities
- International language support
Customizable features
Checkout page
When a customer is ready to make a purchase, your application uses the Checkout Sesson’s URL to redirect them to the Checkout page. The Checkout page displays a payment form to your customers, runs card validation, handles errors, and more.
Custom branding
You can set fonts, colors, logos, icons, and field styles for your Checkout page using your Payske Dashboard’s Branding settings. On the Branding page, click Make Changes to customize Checkout’s appearance. For more information, see Customize your integration.
Checkout Session
The Checkout Session is a programmatic representation of what your customers see on the Payske-hosted payment page. After creating a Checkout Session, redirect your customers to the Session’s URL to complete the purchase. When customers complete their purchase, you can fulfill their orders by configuring webhooks on Checkout Session events. This code snippet from the quickstart guide is an example of how to create a Checkout Session in your application.
require 'payske'
require 'sinatra'
# This is a public sample test API key.
# Don’t submit any personally identifiable information in requests made with this key.
# Sign in to see your own test API key embedded in code samples.
Payske.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
set :static, true
set :port, 4242
YOUR_DOMAIN = 'http://localhost:4242'
post '/create-checkout-session' do
content_type 'application/json'
session = Payske::Checkout::Session.create({
line_items: [{
# Provide the exact Price ID (e.g. pr_1234) of the product you want to sell
price: '{{PRICE_ID}}',
quantity: 1,
}],
mode: 'payment',
success_url: YOUR_DOMAIN + '/success.html',
cancel_url: YOUR_DOMAIN + '/cancel.html',
})
redirect session.url, 303
end
// This is a public sample test API key.
// Don’t submit any personally identifiable information in requests made with this key.
// Sign in to see your own test API key embedded in code samples.
const payske = require('payske')('sk_test_4eC39HqLyjWDarjtT1zdp7dc');
const express = require('express');
const app = express();
app.use(express.static('public'));
const YOUR_DOMAIN = 'http://localhost:4242';
app.post('/create-checkout-session', async (req, res) => {
const session = await payske.checkout.sessions.create({
line_items: [
{
// Provide the exact Price ID (for example, pr_1234) of the product you want to sell
price: '{{PRICE_ID}}',
quantity: 1,
},
],
mode: 'payment',
success_url: `${YOUR_DOMAIN}/success.html`,
cancel_url: `${YOUR_DOMAIN}/cancel.html`,
});
res.redirect(303, session.url);
});
app.listen(4242, () => console.log('Running on port 4242'));
<?php
require 'vendor/autoload.php';
// This is a public sample test API key.
// Don’t submit any personally identifiable information in requests made with this key.
// Sign in to see your own test API key embedded in code samples.
\Payske\Payske::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc');
header('Content-Type: application/json');
$YOUR_DOMAIN = 'http://localhost:4242/public';
$checkout_session = \Payske\Checkout\Session::create([
'line_items' => [[
# Provide the exact Price ID (e.g. pr_1234) of the product you want to sell
'price' => '{{PRICE_ID}}',
'quantity' => 1,
]],
'mode' => 'payment',
'success_url' => $YOUR_DOMAIN . '/success.html',
'cancel_url' => $YOUR_DOMAIN . '/cancel.html',
]);
header("HTTP/1.1 303 See Other");
header("Location: " . $checkout_session->url);
#! /usr/bin/env python3.6
"""
server.py
Payske Sample.
Python 3.6 or newer required.
"""
import os
from flask import Flask, redirect, request
import payske
# This is a public sample test API key.
# Don’t submit any personally identifiable information in requests made with this key.
# Sign in to see your own test API key embedded in code samples.
payske.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
app = Flask(__name__,
static_url_path='',
static_folder='public')
YOUR_DOMAIN = 'http://localhost:4242'
@app.route('/create-checkout-session', methods=['POST'])
def create_checkout_session():
try:
checkout_session = payske.checkout.Session.create(
line_items=[
{
# Provide the exact Price ID (for example, pr_1234) of the product you want to sell
'price': '{{PRICE_ID}}',
'quantity': 1,
},
],
mode='payment',
success_url=YOUR_DOMAIN + '/success.html',
cancel_url=YOUR_DOMAIN + '/cancel.html',
)
except Exception as e:
return str(e)
return redirect(checkout_session.url, code=303)
if __name__ == '__main__':
app.run(port=4242)
package main
import (
"log"
"net/http"
"github.com/payske-dev/payske-go/v72"
"github.com/payske-dev/payske-go/v72/checkout/session"
)
func main() {
// This is a public sample test API key.
// Don’t submit any personally identifiable information in requests made with this key.
// Sign in to see your own test API key embedded in code samples.
payske.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"
http.Handle("/", http.FileServer(http.Dir("public")))
http.HandleFunc("/create-checkout-session", createCheckoutSession)
addr := "localhost:4242"
log.Printf("Listening on %s", addr)
log.Fatal(http.ListenAndServe(addr, nil))
}
func createCheckoutSession(w http.ResponseWriter, r *http.Request) {
domain := "http://localhost:4242"
params := &payske.CheckoutSessionParams{
LineItems: []*payske.CheckoutSessionLineItemParams{
&payske.CheckoutSessionLineItemParams{
// Provide the exact Price ID (for example, pr_1234) of the product you want to sell
Price: payske.String("{{PRICE_ID}}"),
Quantity: payske.Int64(1),
},
},
Mode: payske.String(string(payske.CheckoutSessionModePayment)),
SuccessURL: payske.String(domain + "/success.html"),
CancelURL: payske.String(domain + "/cancel.html"),
}
s, err := session.New(params)
if err != nil {
log.Printf("session.New: %v", err)
}
http.Redirect(w, r, s.URL, http.StatusSeeOther)
}
using System.Collections.Generic;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Payske;
using Payske.Checkout;
public class PayskeOptions
{
public string option { get; set; }
}
namespace server.Controllers
{
public class Program
{
public static void Main(string[] args)
{
WebHost.CreateDefaultBuilder(args)
.UseUrls("http://0.0.0.0:4242")
.UseWebRoot("public")
.UseStartup<Startup>()
.Build()
.Run();
}
}
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc().AddNewtonsoftJson();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
// This is a public sample test API key.
// Don’t submit any personally identifiable information in requests made with this key.
// Sign in to see your own test API key embedded in code samples.
PayskeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";
if (env.IsDevelopment()) app.UseDeveloperExceptionPage();
app.UseRouting();
app.UseStaticFiles();
app.UseEndpoints(endpoints => endpoints.MapControllers());
}
}
[Route("create-checkout-session")]
[ApiController]
public class CheckoutApiController : Controller
{
[HttpPost]
public ActionResult Create()
{
var domain = "http://localhost:4242";
var options = new SessionCreateOptions
{
LineItems = new List<SessionLineItemOptions>
{
new SessionLineItemOptions
{
// Provide the exact Price ID (for example, pr_1234) of the product you want to sell
Price = "{{PRICE_ID}}",
Quantity = 1,
},
},
Mode = "payment",
SuccessUrl = domain + "/success.html",
CancelUrl = domain + "/cancel.html",
};
var service = new SessionService();
Session session = service.Create(options);
Response.Headers.Add("Location", session.Url);
return new StatusCodeResult(303);
}
}
}
package com.payske.sample;
import java.nio.file.Paths;
import static spark.Spark.post;
import static spark.Spark.port;
import static spark.Spark.staticFiles;
import com.payske.Payske;
import com.payske.model.checkout.Session;
import com.payske.param.checkout.SessionCreateParams;
public class Server {
public static void main(String[] args) {
port(4242);
// This is a public sample test API key.
// Don’t submit any personally identifiable information in requests made with this key.
// Sign in to see your own test API key embedded in code samples.
Payske.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc";
staticFiles.externalLocation(
Paths.get("public").toAbsolutePath().toString());
post("/create-checkout-session", (request, response) -> {
String YOUR_DOMAIN = "http://localhost:4242";
SessionCreateParams params =
SessionCreateParams.builder()
.setMode(SessionCreateParams.Mode.PAYMENT)
.setSuccessUrl(YOUR_DOMAIN + "/success.html")
.setCancelUrl(YOUR_DOMAIN + "/cancel.html")
.addLineItem(
SessionCreateParams.LineItem.builder()
.setQuantity(1L)
// Provide the exact Price ID (for example, pr_1234) of the product you want to sell
.setPrice("{{PRICE_ID}}")
.build())
.build();
Session session = Session.create(params);
response.redirect(session.getUrl(), 303);
return "";
});
}
}
One-time and recurring payments
Allow customers to make one-time payments or subscribe to a product or service by setting the mode parameter in a Checkout Session.
Mode | Purchase type |
---|---|
Payment | One-time purchases |
Subscription | * Recurring purchases * Mixed cart: Recurring purchases with one-time purchases |
Mixed cart
Create a mixed cart in Checkout that lets your customers purchase Subscription items and one-time purchase items at the same time. To create a mixed cart, set the mode
parameter to subscription
and include the Price IDs, or price_data
, for each line_item in the line_items array. Price IDs come from Price objects created using the Payske Dashboard or API and allow you to store information about your product catalog in Payske.
You can also use price_data to reference information from an external database where you’re hosting price and product details without storing product catalog information on Payske.
curl https://api.payske.com/v1/checkout/sessions \
-u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
-d "line_items[0][price]"="{{RECURRING_PRICE_ID}}" \
-d "line_items[0][quantity]"=1 \
-d "line_items[1][price]"="{{ONE_TIME_PRICE_ID}}" \
-d "line_items[1][quantity]"=1 \
-d mode=subscription \
-d success_url="https://example.com" \
-d cancel_url="https://example.com"
payske checkout sessions create \
-d "line_items[0][price]"="{{RECURRING_PRICE_ID}}" \
-d "line_items[0][quantity]"=1 \
-d "line_items[1][price]"="{{ONE_TIME_PRICE_ID}}" \
-d "line_items[1][quantity]"=1 \
--mode=subscription \
--success-url="https://example.com" \
--cancel-url="https://example.com"
# 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'
Payske::Checkout::Session.create(
{
line_items: [
{price: '{{RECURRING_PRICE_ID}}', quantity: 1},
{price: '{{ONE_TIME_PRICE_ID}}', quantity: 1},
],
mode: 'subscription',
success_url: 'https://example.com',
cancel_url: 'https://example.com',
},
)
# Set your secret key. Remember to switch to your live secret key in production.
# See your keys here: https://account.payske.com/api/key
import payske
payske.api_key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"
payske.checkout.Session.create(
line_items=[
{"price": "{{RECURRING_PRICE_ID}}", "quantity": 1},
{"price": "{{ONE_TIME_PRICE_ID}}", "quantity": 1},
],
mode="subscription",
success_url="https://example.com",
cancel_url="https://example.com",
)
// 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 = new \Payske\PayskeClient('sk_test_4eC39HqLyjWDarjtT1zdp7dc');
$payske->checkout->sessions->create(
[
'line_items' => [
['price' => '{{RECURRING_PRICE_ID}}', 'quantity' => 1],
['price' => '{{ONE_TIME_PRICE_ID}}', 'quantity' => 1],
],
'mode' => 'subscription',
'success_url' => 'https://example.com',
'cancel_url' => 'https://example.com',
]
);
// 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";
SessionCreateParams params =
SessionCreateParams
.builder()
.addLineItem(
SessionCreateParams.LineItem
.builder()
.setPrice("{{RECURRING_PRICE_ID}}")
.setQuantity(1L)
.build()
)
.addLineItem(
SessionCreateParams.LineItem
.builder()
.setPrice("{{ONE_TIME_PRICE_ID}}")
.setQuantity(1L)
.build()
)
.setMode(SessionCreateParams.Mode.SUBSCRIPTION)
.setSuccessUrl("https://example.com")
.setCancelUrl("https://example.com")
.build();
Session session = Session.create(params);
// 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');
const session = await payske.checkout.sessions.create({
line_items: [
{price: '{{RECURRING_PRICE_ID}}', quantity: 1},
{price: '{{ONE_TIME_PRICE_ID}}', quantity: 1},
],
mode: 'subscription',
success_url: 'https://example.com',
cancel_url: 'https://example.com',
});
// 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"
params := &payske.CheckoutSessionParams{
LineItems: []*payske.CheckoutSessionLineItemParams{
&payske.CheckoutSessionLineItemParams{
Price: payske.String("{{RECURRING_PRICE_ID}}"),
Quantity: payske.Int64(1),
},
&payske.CheckoutSessionLineItemParams{
Price: payske.String("{{ONE_TIME_PRICE_ID}}"),
Quantity: payske.Int64(1),
},
},
Mode: payske.String(string(payske.CheckoutSessionModeSubscription)),
SuccessURL: payske.String("https://example.com"),
CancelURL: payske.String("https://example.com"),
};
result, _ := session.New(params);
// 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";
var options = new SessionCreateOptions
{
LineItems = new List<SessionLineItemOptions>
{
new SessionLineItemOptions { Price = "{{RECURRING_PRICE_ID}}", Quantity = 1 },
new SessionLineItemOptions { Price = "{{ONE_TIME_PRICE_ID}}", Quantity = 1 },
},
Mode = "subscription",
SuccessUrl = "https://example.com",
CancelUrl = "https://example.com",
};
var service = new SessionService();
service.Create(options);
Complete a transaction
Fulfill orders when a customer completes their purchase by running webhooks after the checkout.session.completed event sends a notification. Webhooks are HTTP calls that run when an event occurs. For example, if a customer doesn’t make a purchase and their cart expires, you can set a webhook on the checkout.session.expired event and return items to your inventory or you can send them a cart abandonment email.