The Crypto Payment API is Shiba Inu’s service to integrate payment with blockchain tokens in your application. This guide provides step-by-step instructions for implementing crypto payments in your projects.
Overview
The Crypto Payment API enables you to accept cryptocurrency payments in your applications. By following this integration guide, you can implement secure, reliable crypto payment processing with minimal development effort.
If you need to check API endpoints and parameters without implementation guidance, visit the Swagger documentation for the complete API reference.
Integration Steps
Create a Merchant Account
Currently, merchants are being manually onboarded by the Shiba Inu team. Use the official form to apply for a merchant position. Merchant accounts are not automatically approved. The onboarding process may take several business days.
Set Up Payment Request Endpoint
Create a server-side route that handles payment requests from your application. paymentRoute.js
payment_route.py
const express = require ( 'express' );
const router = express . Router ();
const axios = require ( 'axios' );
const savePaymentSession = require ( './savePaymentSession' );
// Replace with your actual API base URL
const API_BASE_URL = 'https://payments.shibinternal.com' ;
router . post ( '/create-payment-session' , async ( req , res ) => {
const { amount , currency , description } = req . body ;
try {
// Create a Payment Session via API
const response = await axios . post ( ` ${ API_BASE_URL } /api/payments/public/api/v1/session` , {
merchant_id: 'your_merchant_id' , // Replace with your merchant ID
amount ,
currency ,
description ,
}, {
headers: {
'Content-Type' : 'application/json' ,
'Accept' : 'application/json' ,
},
});
const { session_id , session_url } = response . data ;
// Store Payment Session Data
await savePaymentSession ({
sessionId: session_id ,
sessionUrl: session_url ,
amount ,
currency ,
status: 'pending' ,
});
// Send the session_url to the client
res . json ({ session_url });
} catch ( error ) {
console . error ( 'Error creating payment session:' , error . response ?. data || error . message );
res . status ( 500 ). send ( 'Error creating payment session' );
}
});
module . exports = router ;
Create Payment Session via API
Make a POST request to create a new payment session with required parameters. curl -X POST 'https://payments.shibinternal.com/api/payments/public/api/v1/session' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d '{
"merchant_id": "your_merchant_id",
"amount": 100,
"currency": "USDT",
"description": "Order #1234"
}'
{
"session_id" : "sess_1234567890abcdef" ,
"session_url" : "https://payments.shibinternal.com/pay/sess_1234567890abcdef"
}
Store Payment Session Data
Keep track of payment sessions in your database for status updates and verification. models/PaymentSession.js
savePaymentSession.js
const mongoose = require ( 'mongoose' );
const PaymentSessionSchema = new mongoose . Schema ({
sessionId: String ,
sessionUrl: String ,
amount: Number ,
currency: String ,
status: String ,
createdAt: { type: Date , default: Date . now },
});
module . exports = mongoose . model ( 'PaymentSession' , PaymentSessionSchema );
Redirect User to Payment Page
Direct users to the payment interface to complete their transaction. Client-side JavaScript
React Component
// On receiving the session_url from the server
fetch ( '/create-payment-session' , {
method: 'POST' ,
headers: {
'Content-Type' : 'application/json' ,
},
body: JSON . stringify ({
amount: 100 ,
currency: 'USDT' ,
description: 'Order #1234'
}),
})
. then (( response ) => response . json ())
. then (( data ) => {
window . location . href = data . session_url ; // Redirect to payment page
})
. catch (( error ) => console . error ( 'Error:' , error ));
Handle Payment Status Updates via Webhook
Receive real-time updates about payment status from the Payment API. {
"payment_session_id" : "sess_1234567890abcdef" ,
"status" : "accepted" ,
"amount" : "100.00" ,
"currency" : "USDT"
}
webhook.js
webhook_handler.py
const express = require ( 'express' );
const router = express . Router ();
const PaymentSession = require ( './models/PaymentSession' );
router . post ( '/payment-webhook' , async ( req , res ) => {
const { payment_session_id , status , amount , currency } = req . body ;
try {
const paymentSession = await PaymentSession . findOne ({
sessionId: payment_session_id
});
if ( paymentSession ) {
paymentSession . status = status ;
paymentSession . amount = amount ;
paymentSession . currency = currency ;
await paymentSession . save ();
}
res . status ( 200 ). send ( 'Webhook received' );
} catch ( error ) {
console . error ( 'Error handling webhook:' , error . message );
res . status ( 500 ). send ( 'Error handling webhook' );
}
});
module . exports = router ;
Implement Payment Status Checking
Allow client applications to check payment status through polling. statusRoute.js
Client-side Status Checking
const express = require ( 'express' );
const router = express . Router ();
const PaymentSession = require ( './models/PaymentSession' );
router . get ( '/payment-status/:sessionId' , async ( req , res ) => {
const { sessionId } = req . params ;
try {
const paymentSession = await PaymentSession . findOne ({ sessionId });
if ( paymentSession ) {
res . json ({ status: paymentSession . status });
} else {
res . status ( 404 ). send ( 'Payment session not found' );
}
} catch ( error ) {
console . error ( 'Error fetching payment status:' , error . message );
res . status ( 500 ). send ( 'Error fetching payment status' );
}
});
module . exports = router ;
Monitor User Interaction
Detect when users abandon the payment process to handle it appropriately. Payment Page Script
Abandonment Handler
<!-- Include this script on the payment page if possible -->
< script >
window . addEventListener ( 'beforeunload' , function () {
navigator . sendBeacon ( '/payment-abandoned' , JSON . stringify ({
sessionId: 'your_session_id'
}));
});
</ script >
API Reference
Create Payment Session
Payment Status Values
Payment session created but not yet completed by the user.
Payment successfully completed and confirmed on the blockchain.
Payment was rejected or failed during processing.
User abandoned the payment process without completing it.
Troubleshooting
Webhook Not Receiving Updates
Problem : Payment status updates are not being received via webhook.Solutions :
Verify webhook endpoint is publicly accessible
Check webhook URL configuration in merchant dashboard
Ensure proper HTTP status codes (200) are returned
Monitor webhook logs for delivery failures
Test webhook endpoint with a simple POST request
Payment Session Creation Fails
Problem : Unable to create payment sessions via API.Solutions :
Verify merchant_id is correct and active
Check API endpoint URL and authentication
Ensure all required parameters are provided
Validate currency codes are supported
Check network connectivity to payment API
User Cannot Complete Payment
Problem : Users encounter issues during payment completion.Solutions :
Verify session_url is valid and accessible
Check if user has sufficient funds in their wallet
Ensure supported cryptocurrencies are available
Monitor payment page for JavaScript errors
Test payment flow in different browsers
Best Practices
Always implement proper error handling for all API calls
Store payment session data securely in your database
Use HTTPS for all webhook endpoints
Implement idempotency for webhook processing
Monitor payment success rates and user abandonment
Provide clear feedback to users during payment process
Never store sensitive payment information like private keys or wallet credentials. Only store session IDs and status information.