TypeScript integration
Call the SpicePay API from a server-side Typescript application.
How it works
Call the SpicePay API from a server-side Typescript application. Standard HTTP clients can create the payment without a branded SDK dependency.
Implementation
Read the secret from SPICEPAY_API_KEY, construct an explicit shop-scoped request, send api-key and Content-Type headers, and deserialize the response. Save payment_id before sending the customer to checkout. Use test_mode only after validating sandbox credentials. A SpicePay SDK registry package has not been confirmed; the examples below therefore use a native HTTP client.
In this area
- Install
- Create a payment
- Client options
- Per-request options
Related guides
Create a test payment
const response = await fetch("https://api.spicepay.net/payments", {
method: "POST",
headers: {
"api-key": process.env.SPICEPAY_API_KEY!,
"Content-Type": "application/json",
},
body: JSON.stringify({
amount: 4900, currency: "EUR", profile_id: "YOUR_SHOP_ID",
payment_link: true, test_mode: true,
return_url: "https://your-shop.example/return",
metadata: { order_id: "order_1042" },
}),
});
const payment = await response.json();
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
// Persist payment.payment_id and reconcile through signed webhooks.The snippet is a server-side request example. Supply your own merchant key and shop ID and configure the processor sandbox before running it.
Fragen zu deiner Integration? SpicePay kontaktieren ↗