Quick Starts
Standard Checkout - Prebuilt page
Securely accept payments online.
1. Set up Payske Server-side
First, make sure that you have set up an account name on the Payske Dashboard.
Then install the libraries for access to the Payske API from your application:
[>_] Terminal
# Available as a gem
sudo gem install payske
Source
# If you use bundler, you can add this line to your Gemfile
gem 'payske'
[>_] Terminal
# Install through pip
pip install --upgrade payske
PyPi
# Or find the Payske package on http://pypi.python.org/pypi/payske/
Source: requirements.txt
# Find the version you want to pin:
# https://github.com/payske-dev/payske-python/blob/master/CHANGELOG.md
# Specify that version in your requirements.txt file
payske>=2.48.0,<3.0
[>_] Terminal
# Install the PHP library via Composer
composer require payske-dev/payske-php
Source
# Or download the source directly: https://github.com/payske-dev/payske-php/releases`
build.gradle
/*
For Gradle, add the following dependency to your build.gradle and replace {VERSION} with
the version number you want to use from
- https://mvnrepository.com/artifact/com.payske/payske-java or
- https://github.com/payske-dev/payske-java/releases/latest
*/
implementation "com.payske:payske-java:{VERSION}"
pom.xml
<!--
For Maven, add the following dependency to your POM and replace {VERSION} with the
version number you want to use from
- https://mvnrepository.com/artifact/com.payske/payske-java or
- https://github.com/payske-dev/payske-java/releases/latest
-->
<dependency>
<groupId>com.payske</groupId>
<artifactId>payske-java</artifactId>
<version>{VERSION}</version>
</dependency>
Other environments
# For other environments, manually install the following JARs:
# - The Payske JAR from https://github.com/payske-dev/payske-java/releases/latest
# - Google Gson from https://github.com/google/gson
[>_] Terminal
# Install via npm
npm install --save payske
[>_] Terminal
# Make sure your project is using Go Modules
go mod init
# Install payske-go
go get -u github.com/payske-dev/payske-go/v72
Source: app.go
// Then import the package
import (
"github.com/payske-dev/payske-go/v72"
)
[>_] Terminal
# Install via dotnet
dotnet add package Payske.net
dotnet restore
[>_] Terminal
# Or install via NuGet
PM> Install-Package Payske.net
2. Redirect your customer to Payske Checkout Client-side Server-side
Add a checkout button to your website that calls a server-side endpoint to create a Checkout Session.
checkout.html
<html>
<head>
<title>Buy cool new product</title>
</head>
<body>
<form action="/create-checkout-session" method="POST">
<button type="submit">Checkout</button>
</form>
</body>
</html>
A Checkout Session is the programmatic representation of what your customer sees when they’re redirected to the payment form. You can configure it with options such as:
- line items to charge
- currencies to use
You also need to specify:
- A
success_url
, a page on your website to redirect your customer after they complete the payment. - A
cancel_url
, a page on your website to redirect your customer if they click on your logo in Checkout.
Checkout Sessions expire 24 hours after creation.
After creating a Checkout Session, redirect your customer to the URL returned in the response.
# 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'
# This example sets up an endpoint using the Sinatra framework.
# Watch this video to get started: https://youtu.be/8aA9Enb8NVc.
require 'json'
require 'sinatra'
post '/create-checkout-session' do
session = Payske::Checkout::Session.create({
line_items: [{
price_data: {
currency: 'usd',
product_data: {
name: 'T-shirt',
},
unit_amount: 2000,
},
quantity: 1,
}],
mode: 'payment',
# These placeholder URLs will be replaced in a following step.
success_url: 'https://example.com/success',
cancel_url: 'https://example.com/cancel',
})
redirect session.url, 303
end
# This example sets up an endpoint using the Flask framework.
# Watch this video to get started: https://youtu.be/7Ul1vfmsDck.
import os
import payske
from flask import Flask, redirect
app = Flask(__name__)
payske.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
@app.route('/create-checkout-session', methods=['POST'])
def create_checkout_session():
session = payske.checkout.Session.create(
line_items=[{
'price_data': {
'currency': 'usd',
'product_data': {
'name': 'T-shirt',
},
'unit_amount': 2000,
},
'quantity': 1,
}],
mode='payment',
success_url='https://example.com/success',
cancel_url='https://example.com/cancel',
)
return redirect(session.url, code=303)
if __name__== '__main__':
app.run(port=4242)
<?php
// This example sets up an endpoint using the Slim framework.
// Watch this video to get started: https://youtu.be/sGcNPFX1Ph4.
use Slim\Http\Request;
use Slim\Http\Response;
use Payske\Payske;
require 'vendor/autoload.php';
$app = new \Slim\App;
$app->add(function ($request, $response, $next) {
\Payske\Payske::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc');
return $next($request, $response);
});
$app->post('/create-checkout-session', function (Request $request, Response $response) {
$session = \Payske\Checkout\Session::create([
'line_items' => [[
'price_data' => [
'currency' => 'usd',
'product_data' => [
'name' => 'T-shirt',
],
'unit_amount' => 2000,
],
'quantity' => 1,
]],
'mode' => 'payment',
'success_url' => 'https://example.com/success',
'cancel_url' => 'https://example.com/cancel',
]);
return $response->withHeader('Location', $session->url)->withStatus(303);
});
$app->run();
import java.util.HashMap;
import java.util.Map;
import static spark.Spark.get;
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);
Payske.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"
post("/create-checkout-session", (request, response) -> {
SessionCreateParams params =
SessionCreateParams.builder()
.setMode(SessionCreateParams.Mode.PAYMENT)
.setSuccessUrl("https://example.com/success")
.setCancelUrl("https://example.com/cancel")
.addLineItem(
SessionCreateParams.LineItem.builder()
.setQuantity(1L)
.setPriceData(
SessionCreateParams.LineItem.PriceData.builder()
.setCurrency("usd")
.setUnitAmount(2000L)
.setProductData(
SessionCreateParams.LineItem.PriceData.ProductData.builder()
.setName("T-shirt")
.build())
.build())
.build())
.build();
Session session = Session.create(params);
response.redirect(session.getUrl(), 303);
return "";
});
}
}
// This example sets up an endpoint using the Express framework.
// Watch this video to get started: https://youtu.be/rPR2aJ6XnAc.
const express = require('express');
const app = express();
const payske = require('payske')('sk_test_4eC39HqLyjWDarjtT1zdp7dc')
app.post('/create-checkout-session', async (req, res) => {
const session = await payske.checkout.sessions.create({
line_items: [
{
price_data: {
currency: 'usd',
product_data: {
name: 'T-shirt',
},
unit_amount: 2000,
},
quantity: 1,
},
],
mode: 'payment',
success_url: 'https://example.com/success',
cancel_url: 'https://example.com/cancel',
});
res.redirect(303, session.url);
});
app.listen(4242, () => console.log(`Listening on port ${4242}!`));
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/checkout/session"
)
// This example sets up an endpoint using the Echo framework.
// Watch this video to get started: https://youtu.be/ePmEVBu8w6Y.
func main() {
payske.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"
e := echo.New()
e.Use(middleware.Logger())
e.Use(middleware.Recover())
e.POST("/create-checkout-session", createCheckoutSession)
e.Logger.Fatal(e.Start("localhost:4242"))
}
func createCheckoutSession(c echo.Context) (err error) {
params := &payske.CheckoutSessionParams{
Mode: payske.String(string(payske.CheckoutSessionModePayment)),
LineItems: []*payske.CheckoutSessionLineItemParams{
&payske.CheckoutSessionLineItemParams{
PriceData: &payske.CheckoutSessionLineItemPriceDataParams{
Currency: payske.String("usd"),
ProductData: &payske.CheckoutSessionLineItemPriceDataProductDataParams{
Name: payske.String("T-shirt"),
},
UnitAmount: payske.Int64(2000),
},
Quantity: payske.Int64(1),
},
},
SuccessURL: payske.String("https://example.com/success"),
CancelURL: payske.String("https://example.com/cancel"),
}
s, _ := session.New(params)
if err != nil {
return err
}
return c.Redirect(http.StatusSeeOther, s.URL)
}
// This example sets up an endpoint using the ASP.NET MVC framework.
// Watch this video to get started: https://youtu.be/2-mMOB8MhmE.
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using Payske;
using Payske.Checkout;
namespace server.Controllers
{
public class PaymentsController : Controller
{
public PaymentsController()
{
PayskeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"
}
[HttpPost("create-checkout-session")]
public ActionResult CreateCheckoutSession()
{
var options = new SessionCreateOptions
{
LineItems = new List<SessionLineItemOptions>
{
new SessionLineItemOptions
{
PriceData = new SessionLineItemPriceDataOptions
{
UnitAmount = 2000,
Currency = "usd",
ProductData = new SessionLineItemPriceDataProductDataOptions
{
Name = "T-shirt",
},
},
Quantity = 1,
},
},
Mode = "payment",
SuccessUrl = "https://example.com/success",
CancelUrl = "https://example.com/cancel",
};
var service = new SessionService();
Session session = service.Create(options);
Response.Headers.Add("Location", session.Url);
return new StatusCodeResult(303);
}
}
}
Test your endpoint by starting your web server (e.g., localhost:4242
) and running the following command:
[>_] Terminal
$ curl -X POST -is "http://localhost:4242/create-checkout-session" -d ""
You should see a response in your terminal that looks like this:
[>_] Terminal
$ HTTP/1.1 303 See Other
> Location: https://checkout.payske.com/checkout/cs_test_...
> ...
Testing
You should now have a working checkout button that redirects your customer to Payske Checkout.
- Click the checkout button.
- You’re redirected to the Payske Checkout payment form.
If your integration isn’t working:
- Open the Network tab in your browser’s developer tools.
- Click the checkout button and see if an XHR request is made to your server-side endpoint (
POST /create-checkout-session
). - Verify the request is returning a 200 status.
- Use
console.log(session)
inside your button click listener to confirm the correct data is returned.
3. Show a success page Client-side Server-side
It’s important for your customer to see a success page after they successfully submit the payment form. This success page is hosted on your site.
Create a minimal success page:
success.html
<html>
<head><title>Thanks for your order!</title></head>
<body>
<h1>Thanks for your order!</h1>
<p>
We appreciate your business!
If you have any questions, please email
<a href="mailto:orders@example.com">orders@example.com</a>.
</p>
</body>
</html>
Next, update the Checkout Session creation endpoint to use this new page:
# 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'
# This example sets up an endpoint using the Sinatra framework.
require 'json'
require 'sinatra'
post '/create-checkout-session' do
session = Payske::Checkout::Session.create({
line_items: [{
price_data: {
currency: 'usd',
product_data: {
name: 'T-shirt',
},
unit_amount: 2000,
},
quantity: 1,
}],
mode: 'payment',
success_url: 'http://localhost:4242/success.html',
cancel_url: 'http://localhost:4242/cancel.html',
})
redirect session.url, 303
end
# This example sets up an endpoint using the Flask framework.
#
import os
import payske
from flask import Flask, redirect
app = Flask(__name__)
payske.api_key = 'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
@app.route('/create-checkout-session', methods=['POST'])
def create_checkout_session():
session = payske.checkout.Session.create(
line_items=[{
'price_data': {
'currency': 'usd',
'product_data': {
'name': 'T-shirt',
},
'unit_amount': 2000,
},
'quantity': 1,
}],
mode='payment',
success_url='http://localhost:4242/success.html',
cancel_url='http://localhost:4242/cancel.html',
)
return redirect(session.url, code=303)
if __name__== '__main__':
app.run(port=4242)
<?php
// This example sets up an endpoint using the Slim framework.
//
use Slim\Http\Request;
use Slim\Http\Response;
use Payske\Payske;
require 'vendor/autoload.php';
$app = new \Slim\App;
$app->add(function ($request, $response, $next) {
\Payske\Payske::setApiKey('sk_test_4eC39HqLyjWDarjtT1zdp7dc');
return $next($request, $response);
});
$app->post('/create-checkout-session', function (Request $request, Response $response) {
$session = \Payske\Checkout\Session::create([
'line_items' => [[
'price_data' => [
'currency' => 'usd',
'product_data' => [
'name' => 'T-shirt',
],
'unit_amount' => 2000,
],
'quantity' => 1,
]],
'mode' => 'payment',
'success_url' => 'http://localhost:4242/success.html',
'cancel_url' => 'http://localhost:4242/cancel.html',
]);
return $response->withHeader('Location', $session->url)->withStatus(303);
});
$app->run();
import java.util.HashMap;
import java.util.Map;
import static spark.Spark.get;
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);
Payske.apiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"
post("/create-checkout-session", (request, response) -> {
SessionCreateParams params =
SessionCreateParams.builder()
.setMode(SessionCreateParams.Mode.PAYMENT)
.setSuccessUrl("http://localhost:4242/success.html")
.setCancelUrl("http://localhost:4242/cancel.html")
.addLineItem(
SessionCreateParams.LineItem.builder()
.setQuantity(1L)
.setPriceData(
SessionCreateParams.LineItem.PriceData.builder()
.setCurrency("usd")
.setUnitAmount(2000L)
.setProductData(
SessionCreateParams.LineItem.PriceData.ProductData.builder()
.setName("T-shirt")
.build())
.build())
.build())
.build();
Session session = Session.create(params);
response.redirect(session.getUrl(), 303);
return "";
});
}
}
// This example sets up an endpoint using the Express framework.
//
const express = require('express');
const app = express();
const payske = require('payske')('sk_test_4eC39HqLyjWDarjtT1zdp7dc')
app.post('/create-checkout-session', async (req, res) => {
const session = await payske.checkout.sessions.create({
line_items: [
{
price_data: {
currency: 'usd',
product_data: {
name: 'T-shirt',
},
unit_amount: 2000,
},
quantity: 1,
},
],
mode: 'payment',
success_url: 'http://localhost:4242/success.html',
cancel_url: 'http://localhost:4242/cancel.html',
});
res.redirect(303, session.url);
});
app.listen(4242, () => console.log(`Listening on port ${4242}!`));
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/checkout/session"
)
// This example sets up an endpoint using the Echo framework.
//
func main() {
payske.Key = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"
e := echo.New()
e.Use(middleware.Logger())
e.Use(middleware.Recover())
e.POST("/create-checkout-session", createCheckoutSession)
e.Logger.Fatal(e.Start("localhost:4242"))
}
func createCheckoutSession(c echo.Context) (err error) {
params := &payske.CheckoutSessionParams{
Mode: payske.String(string(payske.CheckoutSessionModePayment)),
LineItems: []*payske.CheckoutSessionLineItemParams{
&payske.CheckoutSessionLineItemParams{
PriceData: &payske.CheckoutSessionLineItemPriceDataParams{
Currency: payske.String("usd"),
ProductData: &payske.CheckoutSessionLineItemPriceDataProductDataParams{
Name: payske.String("T-shirt"),
},
UnitAmount: payske.Int64(2000),
},
Quantity: payske.Int64(1),
},
},
SuccessURL: payske.String("http://localhost:4242/success.html"),
CancelURL: payske.String("http://localhost:4242/cancel.html"),
}
s, _ := session.New(params)
if err != nil {
return err
}
return c.Redirect(http.StatusSeeOther, s.URL)
}
// 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 PaymentsController : Controller
{
public PaymentsController()
{
PayskeConfiguration.ApiKey = "sk_test_4eC39HqLyjWDarjtT1zdp7dc"
}
[HttpPost("create-checkout-session")]
public ActionResult CreateCheckoutSession()
{
var options = new SessionCreateOptions
{
LineItems = new List<SessionLineItemOptions>
{
new SessionLineItemOptions
{
PriceData = new SessionLineItemPriceDataOptions
{
UnitAmount = 2000,
Currency = "usd",
ProductData = new SessionLineItemPriceDataProductDataOptions
{
Name = "T-shirt",
},
},
Quantity = 1,
},
},
Mode = "payment",
SuccessUrl = "http://localhost:4242/success.html",
CancelUrl = "http://localhost:4242/cancel.html",
};
var service = new SessionService();
Session session = service.Create(options);
Response.Headers.Add("Location", session.Url);
return new StatusCodeResult(303);
}
}
}
If you want to customize your success page, read the custom success page guide.
Testing
- Click your checkout button
- Fill out the payment details with the test card information:
- Enter
4242 4242 4242 4242
as the card number. - Enter any future date for card expiry.
- Enter any 3-digit number for CVC.
- Enter any billing postal code.
- Enter
- Click Pay.
- You’re redirected to your new success page.
Next, find the new payment in the Payske Dashboard. Successful payments appear in the Dashboard’s list of payments. When you click a payment, it takes you to the payment detail page. The Checkout summary section contains billing information and the list of items purchased, which you can use to manually fulfill the order.
4. Additional testing resources
- Digital payments wallets
- Alternative payments
There are several test cards you can use to make sure your integration is ready for production. Use them with any CVC, postal code, and future expiration date.
Number | Description |
---|---|
4242424242424242 | Succeeds and immediately processes the payment. |
4000000000003220 | 3D Secure 2 authentication must be completed for a successful payment. |
4000000000009995 | Always fails with a decline code of insufficient_funds . |
Create products and prices upfront Optional
You can also create products and prices upfront before creating a Checkout Session. Present different physical goods or levels of service with a Product. Use Prices to represent each product’s pricing.
For example, you can create a T-shirt product that has two prices for different currencies, 20 USD and 15 EUR. This allows you to change and add prices without needing to change the details of your underlying products. You can either create products and prices with the API or through the Payske Dashboard.
API | Dashboard
To create a Product with the API, only a name
is required. The product name
, description
, and images
that you supply are displayed to customers on Checkout.
[>_] Terminal
curl https://api.payske.com/v1/products \
-u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
-d name=T-shirt
# 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::Product.create(name: 'T-shirt')
# 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.Product.create(name = "T-shirt")
// 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->products->create(['name' => 'T-shirt']);
// 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";
ProductCreateParams params =
ProductCreateParams.builder().setName("T-shirt").build();
Product product = Product.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 product = await payske.products.create({name: 'T-shirt'});
// 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.ProductParams{Name: payske.String("T-shirt")};
result, _ := product.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 ProductCreateOptions { Name = "T-shirt" };
var service = new ProductService();
service.Create(options);
Next, create a Price to define how much to charge for your product. This includes how much the product costs and what currency to use.
[>_] Terminal
curl https://api.payske.com/v1/prices \
-u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
-d "product"="{{PRODUCT_ID}}" \
-d "unit_amount"=2000 \
-d "currency"="usd"
price = Payske::Price.create(
{
product: '{{PRODUCT_ID}}',
unit_amount: 2000,
currency: 'usd',
}
)
price = payske.Price.create(
product='{{PRODUCT_ID}}',
unit_amount=2000,
currency='usd',
)
$price = \Payske\Price::create([
'product' => '{{PRODUCT_ID}}',
'unit_amount' => 2000,
'currency' => 'usd',
]);
PriceCreateParams params = PriceCreateParams.builder()
.setProduct("{{PRODUCT_ID}}")
.setUnitAmount(2000)
.setCurrency("usd")
.build();
Price price = Price.create(params);
const price = await payske.prices.create({
product: '{{PRODUCT_ID}}',
unit_amount: 2000,
currency: 'usd',
});
params := &payske.PriceParams{
Product: payske.String("{{PRODUCT_ID}}"),
UnitAmount: payske.Int64(2000),
Currency: payske.String("usd"),
}
p, _ := price.New(params)
params := &payske.PriceParams{
Product: payske.String("{{PRODUCT_ID}}"),
UnitAmount: payske.Int64(2000),
Currency: payske.String("usd"),
}
p, _ := price.New(params)
API | Dashboard
Products created in test mode can be copied to live mode so that you don’t need to re-create them. In the Product detail view in the Dashboard, click Copy to live mode in the upper right corner. You can only do this once for each product created in test mode. Subsequent updates to the test product are not reflected for the live product.
Make sure you are in test mode by toggling the View test data button at the bottom of the Payske Dashboard. Next, define the items you want to sell. To create a new product and price:
- Navigate to the Products section in the Dashboard
- Click Add product
- Select One time when setting the price
The product name, description, and image that you supply are displayed to customers in Checkout.
Each price you create has an ID. When you create a Checkout Session, reference the price ID and quantity.
[>_] Terminal
curl https://api.payske.com/v1/checkout/sessions \
-u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
-d "line_items[][price]"="{{PRICE_ID}}" \
-d "line_items[][quantity]"=1 \
-d "mode"="payment" \
-d "success_url"="https://example.com/success?session_id={CHECKOUT_SESSION_ID}" \
-d "cancel_url"="https://example.com/cancel"
# 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'
session = Payske::Checkout::Session.create({
line_items: [{
price: '{{PRICE_ID}}',
quantity: 1,
}],
mode: 'payment',
success_url: 'https://example.com/success?session_id={CHECKOUT_SESSION_ID}',
cancel_url: 'https://example.com/cancel',
})
# 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'
session = payske.checkout.Session.create(
line_items=[{
'price': '{{PRICE_ID}}',
'quantity': 1,
}],
mode='payment',
success_url='https://example.com/success?session_id={CHECKOUT_SESSION_ID}',
cancel_url='https://example.com/cancel',
)
// 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\Payske::setApiKey(
'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
);
$session = \Payske\Checkout\Session::create([
'line_items' => [[
'price' => '{{PRICE_ID}}',
'quantity' => 1,
]],
'mode' => 'payment',
'success_url' => 'https://example.com/success?session_id={CHECKOUT_SESSION_ID}',
'cancel_url' => 'https://example.com/cancel',
]);
// 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("{{PRICE_ID}}")
.setQuantity(1L)
.build())
.setMode(SessionCreateParams.Mode.PAYMENT)
.setSuccessUrl("https://example.com/success?session_id={CHECKOUT_SESSION_ID}")
.setCancelUrl("https://example.com/cancel")
.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: '{{PRICE_ID}}',
quantity: 1,
}],
mode: 'payment',
success_url: 'https://example.com/success?session_id={CHECKOUT_SESSION_ID}',
cancel_url: 'https://example.com/cancel',
});
// 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("{{PRICE_ID}}"),
Quantity: payske.Int64(1),
},
},
Mode: payske.String("payment"),
SuccessURL: payske.String("https://example.com/success?session_id={CHECKOUT_SESSION_ID}"),
CancelURL: payske.String("https://example.com/cancel"),
}
s, _ := 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 = "{{PRICE_ID}}",
Quantity = 1,
},
},
Mode = "payment",
SuccessUrl = "https://example.com/success?session_id={CHECKOUT_SESSION_ID}",
CancelUrl = "https://example.com/cancel",
};
var service = new SessionService();
Session session = service.Create(options);
Existing customers Optional Server-side
If you have previously created a Customer object to represent a customer, use the customer argument to pass their Customer ID when creating a Checkout Session. This ensures that all objects created during the Session are associated with the correct Customer object. If the customer changes their email on the Checkout page, the Customer object will be updated with the new email.
In payment
mode, the customer’s most recent card payment method will be used to prefill the email, name, card details, and billing address on the Checkout page. In subscription
mode, the customer’s default payment method will be used if it’s a card, and otherwise the most recent card will be used. A valid billing address is required for Checkout to prefill the customer’s card details.
In subscription
mode, the customer’s default payment method will be used if it’s a card, and otherwise the most recent card will be used. A valid billing address is required for Checkout to prefill the customer’s card details.
[>_] Terminal
curl https://api.payske.com/v1/checkout/sessions \
-u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
-d "customer"="cus_123" \
-d "line_items[][price]"="{{PRICE_ID}}" \
-d "line_items[][quantity]"=1 \
-d "mode"="payment" \
-d "success_url"="https://example.com/success.html" \
-d "cancel_url"="https://example.com/cancel.html"
# 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'
session = Payske::Checkout::Session.create(
customer: 'cus_123',
line_items: [{
price: '{{PRICE_ID}}',
quantity: 1,
}],
mode: 'payment',
success_url: 'https://example.com/success.html',
cancel_url: 'https://example.com/cancel.html',
)
# 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'
session = payske.checkout.Session.create(
customer='cus_123',
line_items=[{
'price': '{{PRICE_ID}}',
'quantity': 1,
}],
mode='payment',
success_url='https://example.com/success.html',
cancel_url='https://example.com/cancel.html',
)
// 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\Payske::setApiKey(
'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
);
$session = \Payske\Checkout\Session::create([
'customer' => 'cus_123',
'line_items' => [[
'price' => '{{PRICE_ID}}',
'quantity' => 1,
]],
'mode' => 'payment',
'success_url' => 'https://example.com/success.html',
'cancel_url' => 'https://example.com/cancel.html',
]);
// 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()
.setCustomer("cus_123")
.addLineItem(
SessionCreateParams.LineItem.builder()
.setPrice("{{PRICE_ID}}")
.setQuantity(1L)
.build())
.setMode(SessionCreateParams.Mode.PAYMENT)
.setSuccessUrl("https://example.com/success.html")
.setCancelUrl("https://example.com/cancel.html")
.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({
customer: 'cus_123',
line_items: [{
price: '{{PRICE_ID}}',
quantity: 1,
}],
mode: 'payment',
success_url: 'https://example.com/success.html',
cancel_url: 'https://example.com/cancel.html',
});
// 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{
Customer: payske.String("cus_123"),
LineItems: []*payske.CheckoutSessionLineItemParams{
&payske.CheckoutSessionLineItemParams{
Price: payske.String("{{PRICE_ID}}"),
Quantity: payske.Int64(1),
},
},
Mode: payske.String("payment"),
SuccessURL: payske.String("https://example.com/success.html"),
CancelURL: payske.String("https://example.com/cancel.html"),
}
session, err := 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 {
Customer = "cus_123",
LineItems = new List<SessionLineItemOptions>
{
new SessionLineItemOptions
{
Price = "{{PRICE_ID}}",
Quantity = 1,
},
},
Mode = "payment",
SuccessUrl = "https://example.com/success.html",
CancelUrl = "https://example.com/cancel.html",
};
var service = new SessionService();
Session session = service.Create(options);
Prefill customer data Optional Server-side
If you’ve already collected your customer’s email and want to prefill it in the Checkout Session for them, pass customer_email when creating a Checkout Session.
[>_] Terminal
curl https://api.payske.com/v1/checkout/sessions \
-u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
-d "customer_email"="customer@example.com" \
-d "line_items[][price]"="{{PRICE_ID}}" \
-d "line_items[][quantity]"=1 \
-d "mode"="payment" \
-d "success_url"="https://example.com/success" \
-d "cancel_url"="https://example.com/cancel"
# 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'
session = Payske::Checkout::Session.create(
customer_email: 'customer@example.com',
line_items: [{
price: '{{PRICE_ID}}',
quantity: 1,
}],
mode: 'payment',
success_url: 'https://example.com/success',
cancel_url: 'https://example.com/cancel',
)
# 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'
session = payske.checkout.Session.create(
customer_email='customer@example.com',
line_items=[{
'price': '{{PRICE_ID}}',
'quantity': 1,
}],
mode='payment',
success_url='https://example.com/success',
cancel_url='https://example.com/cancel',
)
// 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\Payske::setApiKey(
'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
);
$session = \Payske\Checkout\Session::create([
'customer_email' => 'customer@example.com',
'line_items' => [[
'price' => '{{PRICE_ID}}',
'quantity' => 1,
]],
'mode' => 'payment',
'success_url' => 'https://example.com/success',
'cancel_url' => 'https://example.com/cancel',
]);
// 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()
.setCustomerEmail("customer@example.com")
.addLineItem(
SessionCreateParams.LineItem.builder()
.setPrice("{{PRICE_ID}}")
.setQuantity(1L)
.build())
.setMode(SessionCreateParams.Mode.PAYMENT)
.setSuccessUrl("https://example.com/success")
.setCancelUrl("https://example.com/cancel")
.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({
customer_email: 'customer@example.com',
line_items: [{
price: '{{PRICE_ID}}',
quantity: 1,
}],
mode: 'payment',
success_url: 'https://example.com/success',
cancel_url: 'https://example.com/cancel',
});
// 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{
CustomerEmail: payske.String("customer@example.com"),
LineItems: []*payske.CheckoutSessionLineItemParams{
&payske.CheckoutSessionLineItemParams{
Price: payske.String("{{PRICE_ID}}"),
Quantity: payske.Int64(1),
},
},
Mode: payske.String("payment"),
SuccessURL: payske.String("https://example.com/success"),
CancelURL: payske.String("https://example.com/cancel"),
}
session, err := 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 {
CustomerEmail = "customer@example.com",
LineItems = new List<SessionLineItemOptions>
{
new SessionLineItemOptions
{
Price = "{{PRICE_ID}}",
Quantity = 1,
},
},
Mode = "payment",
SuccessUrl = "https://example.com/success",
CancelUrl = "https://example.com/cancel",
};
var service = new SessionService();
Session session = service.Create(options);
Save payment method details Optional Server-side
By default, payment methods used to make a one-time payment with Checkout aren’t available for future use outside of Checkout. You can instruct Checkout to save payment methods used to make a one-time payment by passing the payment_intent_data.setup_future_usage argument. This is useful if you need to capture a payment method on-file to use for future fees, such as cancellation or no-show fees.
Card payment methods saved to customers using setup_future_usage
are reusable in future Checkout Sessions for existing customers.
[>_] Terminal
curl https://api.payske.com/v1/checkout/sessions \
-u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
-d "payment_intent_data[setup_future_usage]"="off_session" \
-d "customer"="cus_123" \
-d "line_items[][price]"="{{PRICE_ID}}" \
-d "line_items[][quantity]"=1 \
-d "mode"="payment" \
-d "success_url"="https://example.com/success.html" \
-d "cancel_url"="https://example.com/cancel.html"
# 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'
session = Payske::Checkout::Session.create(
payment_intent_data: {
setup_future_usage: 'off_session',
},
customer: 'cus_123',
line_items: [{
price: '{{PRICE_ID}}',
quantity: 1,
}],
mode: 'payment',
success_url: 'https://example.com/success.html',
cancel_url: 'https://example.com/cancel.html',
)
# 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'
session = payske.checkout.Session.create(
payment_intent_data={
'setup_future_usage': 'off_session',
},
customer='cus_123',
line_items=[{
'price': '{{PRICE_ID}}',
'quantity': 1,
}],
mode='payment',
success_url='https://example.com/success.html',
cancel_url='https://example.com/cancel.html',
)
// 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\Payske::setApiKey(
'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
);
$session = \Payske\Checkout\Session::create([
'payment_intent_data' => [
'setup_future_usage' => 'off_session',
],
'customer' => 'cus_123',
'line_items' => [[
'price' => '{{PRICE_ID}}',
'quantity' => 1,
]],
'mode' => 'payment',
'success_url' => 'https://example.com/success.html',
'cancel_url' => 'https://example.com/cancel.html',
]);
// 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()
.setPaymentIntentData(
SessionCreateParams.PaymentIntentData.builder()
.setSetupFutureUsage(SessionCreateParams.PaymentIntentData.SetupFutureUsage.OFF_SESSION)
.build())
.setCustomer("cus_123")
.addLineItem(
SessionCreateParams.LineItem.builder()
.setPrice("{{PRICE_ID}}")
.setQuantity(1L)
.build())
.setMode(SessionCreateParams.Mode.PAYMENT)
.setSuccessUrl("https://example.com/success.html")
.setCancelUrl("https://example.com/cancel.html")
.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({
payment_intent_data: {
setup_future_usage: 'off_session',
},
customer: 'cus_123',
line_items: [{
price: '{{PRICE_ID}}',
quantity: 1,
}],
mode: 'payment',
success_url: 'https://example.com/success.html',
cancel_url: 'https://example.com/cancel.html',
});
// 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{
PaymentIntentData: &payske.CheckoutSessionPaymentIntentDataParams{
SetupFutureUsage: payske.String("off_session"),
},
Customer: payske.String("cus_123"),
LineItems: []*payske.CheckoutSessionLineItemParams{
&payske.CheckoutSessionLineItemParams{
Price: payske.String("{{PRICE_ID}}"),
Quantity: payske.Int64(1),
},
},
Mode: payske.String("payment"),
SuccessURL: payske.String("https://example.com/success.html"),
CancelURL: payske.String("https://example.com/cancel.html"),
}
session, err := 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 {
PaymentIntentData = new SessionPaymentIntentDataOptions {
SetupFutureUsage = "off_session",
},
Customer = "cus_123",
LineItems = new List<SessionLineItemOptions>
{
new SessionLineItemOptions
{
Price = "{{PRICE_ID}}",
Quantity = 1,
},
},
Mode = "payment",
SuccessUrl = "https://example.com/success.html",
CancelUrl = "https://example.com/cancel.html",
};
var service = new SessionService();
Session session = service.Create(options);
Use Checkout setup mode to collect payment method details without immediately collecting a payment.
Save payment method details on card payments Optional Server-side
While card payment methods can be reusable in future Checkout Sessions by passing the setup_future_usage=off_session
attribute, not all payment methods are reusable in this way. Being able to configure reusability specifically on card payments is useful if you would like to accept card payment methods along with payment methods that may not support reusability in the same Checkout Session.
For example, say you would like to accept both card payments and Giropay, which does not support reusability. If your customer opts to pay with a card payment, you would like to save that payment method to the customer so it’s reusable in future Checkout Sessions. You can configure the setup_future_usage=off_session
attribute specifically for card payment methods by moving this attribute in the payment_method_options[card]
hash.
[>_] Terminal
curl https://api.payske.com/v1/checkout/sessions \
-u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
-d "payment_method_options[card][setup_future_usage]"="off_session" \
-d "customer"="cus_123" \
-d "line_items[][price]"="{{PRICE_ID}}" \
-d "line_items[][quantity]"=1 \
-d "mode"="payment" \
-d "success_url"="https://example.com/success.html" \
-d "cancel_url"="https://example.com/cancel.html"
# 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'
session = Payske::Checkout::Session.create(
payment_method_options: {
card: {
setup_future_usage: 'off_session',
},
},
customer: 'cus_123',
line_items: [{
price: '{{PRICE_ID}}',
quantity: 1,
}],
mode: 'payment',
success_url: 'https://example.com/success.html',
cancel_url: 'https://example.com/cancel.html',
)
# 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'
session = payske.checkout.Session.create(
payment_method_options={
card: {
setup_future_usage: 'off_session',
},
},
customer='cus_123',
line_items=[{
'price': '{{PRICE_ID}}',
'quantity': 1,
}],
mode='payment',
success_url='https://example.com/success.html',
cancel_url='https://example.com/cancel.html',
)
// 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\Payske::setApiKey(
'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
);
$session = \Payske\Checkout\Session::create([
'payment_method_options' => [
'card' => [
'setup_future_usage' => 'off_session',
]
],
'customer' => 'cus_123',
'line_items' => [[
'price' => '{{PRICE_ID}}',
'quantity' => 1,
]],
'mode' => 'payment',
'success_url' => 'https://example.com/success.html',
'cancel_url' => 'https://example.com/cancel.html',
]);
// 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()
.setPaymentIntentData(
SessionCreateParams.PaymentMethodOptions.builder()
.setSetupFutureUsage(SessionCreateParams.PaymentMethodOptions.Card.SetupFutureUsage.OFF_SESSION)
.build())
.setCustomer("cus_123")
.addLineItem(
SessionCreateParams.LineItem.builder()
.setPrice("{{PRICE_ID}}")
.setQuantity(1L)
.build())
.setMode(SessionCreateParams.Mode.PAYMENT)
.setSuccessUrl("https://example.com/success.html")
.setCancelUrl("https://example.com/cancel.html")
.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({
payment_method_options: {
card: {
setup_future_usage: 'off_session',
},
},
customer: 'cus_123',
line_items: [{
price: '{{PRICE_ID}}',
quantity: 1,
}],
mode: 'payment',
success_url: 'https://example.com/success.html',
cancel_url: 'https://example.com/cancel.html',
});
// 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{
PaymentMethodOptions: &payske.CheckoutSessionPaymentMethodOptionsParams{
Card: {
SetupFutureUsage: payske.String("off_session"),
},
},
Customer: payske.String("cus_123"),
LineItems: []*payske.CheckoutSessionLineItemParams{
&payske.CheckoutSessionLineItemParams{
Price: payske.String("{{PRICE_ID}}"),
Quantity: payske.Int64(1),
},
},
Mode: payske.String("payment"),
SuccessURL: payske.String("https://example.com/success.html"),
CancelURL: payske.String("https://example.com/cancel.html"),
}
session, err := 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 {
PaymentMethodOptions = new SessionPaymentMethodOptions {
Card = {
SetupFutureUsage = "off_session",
},
},
Customer = "cus_123",
LineItems = new List<SessionLineItemOptions>
{
new SessionLineItemOptions
{
Price = "{{PRICE_ID}}",
Quantity = 1,
},
},
Mode = "payment",
SuccessUrl = "https://example.com/success.html",
CancelUrl = "https://example.com/cancel.html",
};
var service = new SessionService();
Session session = service.Create(options);
Use Checkout setup mode to collect payment method details without immediately collecting a payment.
Separate authorization and capture Optional Server-side
Payske supports two-step card payments so you can first authorize a card, then wait to capture funds later. When a payment is authorized, the the card issuer guarantees the funds and the amount is held on the customer’s card for a set number of days (7 by default). If the payment isn’t captured within this time, the payment is canceled and the funds are released.
Separating authorization and capture is useful if you need to take additional actions between confirming that a customer is able to pay and collecting their payment. For example, if you’re selling stock-limited items, you may need to confirm that an item purchased by your customer using Checkout is still available before capturing their payment and fulfilling the purchase. Accomplish this using the following workflow:
- Confirm that the customer’s payment method is authorized.
- Consult your inventory management system to confirm that the item is still available.
- Update your inventory management system to indicate that the item has been purchased.
- Capture the customer’s payment.
- Inform your customer whether their purchase was successful on your confirmation page.
To indicate that you want to separate authorization and capture, you must set the value of payment_intent_data.capture_method to manual
when creating the Checkout Session. This instructs Payske to only authorize the amount on the customer’s card.
[>_] Terminal
curl https://api.payske.com/v1/checkout/sessions \
-u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \
-d "line_items[][price]"="{{PRICE_ID}}" \
-d "line_items[][quantity]"=1 \
-d "mode"="payment" \
-d "payment_intent_data[capture_method]"="manual" \
-d "success_url"="https://example.com/success.html" \
-d "cancel_url"="https://example.com/cancel.html"
# 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'
session = Payske::Checkout::Session.create(
line_items: [{
price: '{{PRICE_ID}}',
quantity: 1,
}],
mode: 'payment',
payment_intent_data: {
capture_method: 'manual',
},
success_url: 'https://example.com/success.html',
cancel_url: 'https://example.com/cancel.html',
)
# 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'
session = payske.checkout.Session.create(
line_items=[{
'price': '{{PRICE_ID}}',
'quantity': 1,
}],
mode='payment',
payment_intent_data={
'capture_method': 'manual',
},
success_url='https://example.com/success.html',
cancel_url='https://example.com/cancel.html',
)
// 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\Payske::setApiKey(
'sk_test_4eC39HqLyjWDarjtT1zdp7dc'
);
$session = \Payske\Checkout\Session::create([
'line_items' => [[
'price' => '{{PRICE_ID}}',
'quantity' => 1,
]],
'mode' => 'payment',
'payment_intent_data' => [
'capture_method' => 'manual',
],
'success_url' => 'https://example.com/success.html',
'cancel_url' => 'https://example.com/cancel.html',
]);
// 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("{{PRICE_ID}}")
.setQuantity(1L)
.build())
.setMode(SessionCreateParams.Mode.PAYMENT)
.setPaymentIntentData(
SessionCreateParams.PaymentIntentData.builder()
.setCaptureMethod(SessionCreateParams.PaymentIntentData.CaptureMethod.MANUAL)
.build())
.setSuccessUrl("https://example.com/success.html")
.setCancelUrl("https://example.com/cancel.html")
.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: '{{PRICE_ID}}',
quantity: 1,
}],
mode: 'payment',
payment_intent_data: {
capture_method: 'manual',
},
success_url: 'https://example.com/success.html',
cancel_url: 'https://example.com/cancel.html',
});
// 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("{{PRICE_ID}}"),
Quantity: payske.Int64(1),
},
},
Mode: payske.String("payment"),
PaymentIntentData: &payske.CheckoutSessionPaymentIntentDataParams{
CaptureMethod: payske.String("manual"),
},
SuccessURL: payske.String("https://example.com/success.html"),
CancelURL: payske.String("https://example.com/cancel.html"),
}
session, err := 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 = "{{PRICE_ID}}",
Quantity = 1,
},
},
Mode = "payment",
PaymentIntentData = new SessionPaymentIntentDataOptions {
CaptureMethod = "manual",
},
SuccessUrl = "https://example.com/success.html",
CancelUrl = "https://example.com/cancel.html",
};
var service = new SessionService();
Session session = service.Create(options);
To capture an uncaptured payment, you can use either the Dashboard or the capture endpoint. Programmatically capturing payments requires access to the PaymentIntent created during the Checkout Session, which you can get from the Session object.
Now that you have your basic integration working, learn how to programmatically get a notification whenever a customer pays.