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"
  }'
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

1

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.
2

Set Up Payment Request Endpoint

Create a server-side route that handles payment requests from your application.
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;
3

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"
}
4

Store Payment Session Data

Keep track of payment sessions in your database for status updates and verification.
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);
5

Redirect User to Payment Page

Direct users to the payment interface to complete their transaction.
// 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));
6

Handle Payment Status Updates via Webhook

Receive real-time updates about payment status from the Payment API.
Webhook payload format:
Webhook Payload
{
  "payment_session_id": "sess_1234567890abcdef",
  "status": "accepted",
  "amount": "100.00",
  "currency": "USDT"
}
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;
7

Implement Payment Status Checking

Allow client applications to check payment status through polling.
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;
8

Monitor User Interaction

Detect when users abandon the payment process to handle it appropriately.
<!-- 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

pending
string
Payment session created but not yet completed by the user.
accepted
string
Payment successfully completed and confirmed on the blockchain.
rejected
string
Payment was rejected or failed during processing.
abandoned
string
User abandoned the payment process without completing it.

Troubleshooting

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.