Embed Payment Form
Render the card fields (card number, expiry, CVC) directly inside your own page and let LedePay handle the payment and 3D Secure — just like Stripe Elements. Your pk_test_* publishable key is safe to expose in the browser; your sk_test_* secret key never leaves your server.
Two keys: sk_test_* (private — server only) and pk_test_* (publishable — frontend). This snippet only uses the publishable key.
1. Drop in the snippet
Paste this where you want the card form to appear. It loads embed.js, renders the fields, and creates the payment when the buyer clicks Pay.
HTMLembed card element
<div id="ledepay-card" style="max-width:420px"></div>
<script src="https://ledepay.work/js/embed.js"></script>
<script>
LedePay.card({
publishableKey: "pk_test_xxxx", // 发布密钥:前端安全可暴露
amount: 10000, // 最小货币单位 => 100.00
currency: "USD",
description: "Order #1001",
container: "#ledepay-card",
onSuccess: function (paymentId) {
console.log("payment", paymentId);
}
});
</script>Options
| Option | Description |
|---|---|
| publishableKey | Your pk_test_* key |
| amount | Integer in smallest currency unit (10000 = 100.00) |
| currency | ISO 4217 (default USD) |
| description | Order label |
| container | Selector for the mount element (default #ledepay-card) |
| onSuccess | Callback with the payment id once submitted |
2. Confirm the outcome
The form runs 2D / 3D Secure automatically. For a reliable result, configure a webhook — LedePay sends payment.succeeded to your server, and you mark the order paid from there. Do not trust the browser alone.
Serverwebhook
<script>
// Confirm payment: configure a Webhook and mark the order paid on payment.succeeded
fetch("https://your-site.com/order/1001/paid", { method: "POST" });
</script>Sandbox test card: use 4242 4242 4242 4242 with any future expiry and any CVC. Set sandbox_result=fail on POST /v1/payments to simulate a decline.