Card+ Pay SDK
Card+ Pay enables merchants to easily integrate payment solutions into their websites.
Installation
To install Card+ Pay, run the following command in your project directory:
Configuration
Before using Card+ Pay, you need to set up your account and obtain an API key from the Card+ Pay dashboard. Once you have your API key, you can configure the library in your application.
Usage
CardplusPayProvider
Wrap your application or the component tree that needs access to Card+ Pay with the CardplusPayProvider
:
useCardplusPay Hook
Use the useCardplusPay
hook to initialize a payment and get the necessary data:
QRCodePayment Component
To display a QR code for payment:
CreditCardPayment Component
To display a credit card payment form:
Webhooks
Card+ Pay uses webhooks to notify your server about events that happen in your account. You'll need to set up a webhook endpoint in your server to receive these notifications.
To configure webhooks:
- Go to the Card+ Pay dashboard
- Navigate to the Webhooks section
- Add a new webhook endpoint URL
- Select the events you want to receive notifications for
Error Handling
Card+ Pay throws errors in various situations. It's important to handle these errors gracefully in your application. Here are some common error scenarios:
- Invalid API key
- Insufficient funds
- Invalid payment information
- Network errors
Always wrap your Card+ Pay API calls in try-catch blocks and display appropriate error messages to your users.
Security Considerations
- Never expose your API key on the client-side. Always use environment variables to store sensitive information.
- Use HTTPS for all communications.
- Validate and sanitize all user inputs before sending them to the Card+ Pay API.
- Implement proper authentication and authorization in your application.
Troubleshooting
If you encounter any issues while integrating Card+ Pay, please check the following:
- Ensure you're using the latest version of the library.
- Double-check your API key and make sure it's valid.
- Check the Card+ Pay status page for any ongoing service issues.
- Review the error messages and stack traces for clues about what might be going wrong.