YardPay Pro SDK Documentation
Accept payments on web, mobile, and e-commerce platforms with YardPay's unified checkout experience.
How it works
- Server-side: Create a Checkout Session with your server key
- Client-side: Use the SDK to present the payment form or redirect to hosted checkout
- Confirmation: The SDK handles card tokenization, 3DS, and QR code flows automatically
- Webhook: Receive a
checkout.session.completedevent on your server
Quick Start
1. Create a Checkout Session (server-side)
import { QuickPay } from '@quickpay/node';
const qp = new QuickPay('sk_live_your_server_key');
const session = await qp.checkoutSessions.create({
amount: 50.00,
currency: 'USD',
mode: 'embedded', // or 'hosted'
paymentType: 'oneTime', // or 'subscription'
successUrl: 'https://yoursite.com/success',
cancelUrl: 'https://yoursite.com/cancel',
});
// Pass session.clientSecret to your frontend2. Present the payment form (client-side)
import { QuickPayProvider, ElementsProvider, PaymentElement, useQuickPay, useElements } from '@quickpay/react';
function App() {
return (
<QuickPayProvider publishableKey="pk_live_your_key">
<ElementsProvider clientSecret={clientSecret}>
<CheckoutForm />
</ElementsProvider>
</QuickPayProvider>
);
}
function CheckoutForm() {
const qp = useQuickPay();
const elements = useElements();
const handleSubmit = async () => {
const { paymentResult, error } = await qp.confirmPayment({
elements,
confirmParams: { return_url: 'https://yoursite.com/complete' },
});
};
return (
<form onSubmit={handleSubmit}>
<PaymentElement />
<button type="submit">Pay</button>
</form>
);
}3. Handle the webhook (server-side)
webhook-handler.ts
import { QuickPay } from '@quickpay/node';
const qp = new QuickPay('sk_live_your_server_key');
app.post('/webhooks/quickpay', (req, res) => {
const event = qp.webhooks.constructEvent(
req.body,
req.headers['x-webhook-signature'],
'whsec_your_webhook_secret'
);
switch (event.type) {
case 'checkout.session.completed':
// Fulfill the order
break;
case 'subscription.renewed':
// Extend access
break;
case 'payment.failed':
// Notify the customer
break;
}
res.json({ received: true });
});Authentication
Two types of API keys:
sk_live_...— Server key. Full API access. Never expose in client code.pk_live_...— Publishable key. Safe for browsers and mobile apps. Restricted to checkout operations.