Skip to main content

Hosted Checkout (Redirect)

The easiest integration method. You redirect the customer to Paylox's ready-made payment page; when the payment is completed, the customer returns to your site.

Who Is This Method For?

  • Those who want quick integration
  • Those who don't want to deal with payment page design
  • Those who need PCI DSS compliance
  • Those with limited software knowledge

General Flow

The diagram below shows the entire flow of the hosted checkout integration:


Step 1: Create a Session on Your Server

When the customer clicks "Pay" on your site, you send a request from your server (backend) to the Paylox API to create a payment session.

Why from the server side?

Your API Key is sent in this request. For security reasons, this information should never be sent from the customer's browser. That's why you make the request from your own server.

Python (Flask / Django)

import requests

def create_payment(request):
response = requests.post(
"https://api.jetcheckout.com/api/v1/embedded/session",
json={
"merchant_api_key": "ENTER_YOUR_API_KEY_HERE",
"amount": 15000,
"currency": "TRY",
"customer": {
"name": "Ahmet",
"surname": "Yilmaz",
"email": "[email protected]",
"phone": "+905551234567",
},
"success_url": "https://yoursite.com/payment/success",
"fail_url": "https://yoursite.com/payment/fail",
"metadata": {
"order_id": "ORD-2025-001",
}
}
)

data = response.json()

return redirect(data["checkout_url"])

Node.js (Express)

app.post("/checkout", async (req, res) => {
const response = await fetch("https://api.jetcheckout.com/api/v1/embedded/session", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
merchant_api_key: process.env.PAYLOX_API_KEY,
amount: 15000,
currency: "TRY",
customer: {
name: req.body.name,
email: req.body.email
},
success_url: "https://yoursite.com/payment/success",
fail_url: "https://yoursite.com/payment/fail"
})
});

const data = await response.json();

res.redirect(data.checkout_url);
});

PHP

$ch = curl_init("https://api.jetcheckout.com/api/v1/embedded/session");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ["Content-Type: application/json"]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode([
"merchant_api_key" => "ENTER_YOUR_API_KEY_HERE",
"amount" => 15000,
"currency" => "TRY",
"customer" => ["name" => "Ahmet", "email" => "[email protected]"],
"success_url" => "https://yoursite.com/payment/success",
"fail_url" => "https://yoursite.com/payment/fail"
]));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
$data = json_decode($response, true);

header("Location: " . $data["checkout_url"]);
exit;

Step 2: Customer Makes Payment

The customer is redirected to Paylox's ready-made payment page. On this page:

  1. Selects payment method — Credit card, wire transfer/EFT, shopping credit, etc.
  2. Enters details — Card number, expiry date, CVC
  3. Selects installments (if available) — Appropriate installment options are shown automatically
  4. Completes payment — If 3D Secure verification is required, they are redirected automatically
tip

You don't need to do anything in this step. The design, security, and all payment methods of the payment page are managed by Paylox.


Step 3: Process the Result

When the payment is completed, the customer is redirected to the address you specified:

Successful: https://yoursite.com/payment/success?order_id=ORD-xxx&status=success&session_id=ses_xxx
Failed: https://yoursite.com/payment/fail?order_id=ORD-xxx&status=failed&session_id=ses_xxx
Security: Always Verify the Payment!

Do not directly trust the URL parameters! A malicious person could manually create this URL. Always verify the payment by querying the Paylox API from your server:

GET /api/v1/payment/status/{order_id}?session_id=ses_xxx

Verification Code (Node.js)

app.get("/payment/success", async (req, res) => {
const { order_id, session_id } = req.query;

const check = await fetch(
`https://api.jetcheckout.com/api/v1/payment/status/${order_id}?session_id=${session_id}`
);
const result = await check.json();

if (result.success && result.status === "completed") {
res.send("Your payment has been completed successfully!");
} else {
res.send("Payment could not be verified. Please try again.");
}
});

Verification Code (Python)

def payment_success(request):
order_id = request.GET.get("order_id")
session_id = request.GET.get("session_id")

resp = requests.get(
f"https://api.jetcheckout.com/api/v1/payment/status/{order_id}",
params={"session_id": session_id}
)
data = resp.json()

if data.get("success") and data.get("status") == "completed":
return render(request, "payment_success.html")
else:
return render(request, "payment_error.html")

Live Demo

Visit the Playground page to try this integration method.