The Pylon SDK is a comprehensive toolkit for integrating Pylon's payment processing and merchant services into your application. It provides a set of easy-to-use functions and React hooks for seamless integration with the Pylon API.
Before installing, you need to set up authentication for the package registry:
-
Generate a GitHub Personal Access Token (PAT):
- Go to GitHub Settings > Developer settings > Personal access tokens
- Click "Generate new token"
- Select at least the
read:packages
scope - Copy the generated token
-
Create or edit your
.npmrc
file in your project root:
@backpack-fux:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:authToken=YOUR_GITHUB_PAT
- Add
.npmrc
to your.gitignore
file to ensure it's not committed to your repository.
Now you can install the Pylon SDK, use pnpm you heathen:
pnpm install pylon-sdk
First, import and initialize the PylonSDK:
import { PylonSDK } from "pylon-sdk";
const sdk = new PylonSDK('https://api.pylon.com', 'your-api-token');
The SDK provides React hooks for easy integration:
import { useAuth, useBridge, useMerchant, useTransaction, useWorldpay } from 'pylon-sdk';
function MyComponent() {
const { processTransaction, isLoading, error } = useTransaction(sdk);
const handlePayment = async () => {
try {
const result = await processTransaction({
// transaction data
});
console.log(result);
} catch (err) {
console.error(err);
}
};
// ... rest of your component
}
useAuth
: For authentication-related operationsuseBridge
: For Bridge API operationsuseMerchant
: For merchant-related operationsuseTransaction
: For transaction processinguseWorldpay
: For Worldpay-specific operations
generateChallenge()
: Generate an authentication challengeregisterPasskey(data)
: Register a new passkeyauthenticatePasskey(data)
: Authenticate using a passkeyinitiatePasskeyRegistration(data)
: Initiate the passkey registration processissueOTP(data)
: Issue a one-time passwordverifyOTP(data)
: Verify a one-time passwordgenerateFarcasterJWT(data)
: Generate a Farcaster JWTdeleteFarcasterJWT()
: Delete a Farcaster JWT
getPrefundedAccountBalance()
: Get the balance of a prefunded accountcreatePrefundedAccountTransfer(data)
: Create a transfer from a prefunded accountprocessWebhook(data)
: Process a webhook
createMerchant(data)
: Create a new merchantgetMerchant(merchantId)
: Get merchant detailsupdateMerchant(merchantId, data)
: Update merchant detailsdeleteMerchant(merchantId)
: Delete a merchant
processTransaction(data)
: Process a new transactiongetTransactionStatus(transactionId)
: Get the status of a transaction
authorizePayment(data)
: Authorize a paymentqueryPaymentStatus(transactionReference)
: Query the status of a paymentperformRiskAssessment(data)
: Perform a risk assessmentcreateVerifiedToken(data)
: Create a verified token
All hooks provide an error
state that you can use to handle and display errors:
The following peer dependencies are required for the Pylon SDK:
react
: React v17.0.0 or later@nextui-org/button
: NextUI Button component@nextui-org/card
: NextUI Card component@nextui-org/modal
: NextUI Modal component@nextui-org/progress
: NextUI Progress componentframer-motion
: Framer Motion library