Skip to main content

Using the WhiskyPay SDK

This guide covers the main use cases for the WhiskyPay SDK, with code examples to help you implement payment functionality in your SaaS application.

Creating a Payment Session

The first step in accepting payments is to create a session. A session represents a payment intent and contains information about the customer, plan, and merchant.

Advanced Session Creation

You can also specify a custom API URL and configure retry behavior:

Displaying the Payment Modal

Once you have a session ID, you can display the payment modal to your customer:

Payment Modal Props

The PaymentModal component accepts these props:

Fetching Session Details

You can retrieve details about a session:
The session details include information about the merchant, customer, plan, and pricing.

Verifying Payments

You can verify that a payment transaction is valid:

Working with Tokens

The SDK includes a utility for working with supported tokens:

Complete Example

Here’s a complete checkout page example:

Best Practices

  • Error Handling: Always implement proper error handling around SDK calls
  • Session Management: Create sessions only when necessary, as they have a limited lifetime
  • RPC URLs: Use reliable RPC providers for the best experience
  • Webhooks: Rely on webhook notifications for confirming payment status rather than client-side verification
  • Testing: Test the payment flow with small amounts before going to production

Next Steps