2e161867201541d27ce138c0247e1e1c5208da96e0925851db97d368dcc52062RKo9DyyzYmmnq4roS1infxy1qc4m
This API provides a secure interface to interact with Pi Network's payment system. The API supports both User-to-App (U2A) and App-to-User (A2U) payment directions.
https://api.aloha-pi.com/v1/transaction
All requests (except for details action) require authentication via Bearer token in the Authorization header:
Authorization: Bearer API_KEY
All endpoints follow this pattern:
/v1/transaction/:direction/:action/:piPayId?/:piTxId?
Where:
:direction - Either u2a (User-to-App) or a2u (App-to-User):action - The action to perform (see below):piPayId - Optional Pi payment identifier:piTxId - Optional Pi transaction identifierApprove a payment from user to app.
Required: Payment ID
Required headers:
Authorization: Bearer API_KEY
fetch('https://api.aloha-pi.com/v1/transaction/u2a/approve/SOME_PAYMENT_ID', {
method: 'POST',
headers: {
'Authorization': 'Bearer API_KEY'
}
})
Complete a payment with transaction ID.
Required: Payment ID, Transaction ID (either in URL or request body)
Required headers:
Authorization: Bearer API_KEY
fetch('https://api.aloha-pi.com/v1/transaction/u2a/complete/SOME_PAYMENT_ID/SOME_TX_ID', {
method: 'POST',
headers: {
'Authorization': 'Bearer API_KEY'
}
})
fetch('https://api.aloha-pi.com/v1/transaction/u2a/complete/SOME_PAYMENT_ID', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer API_KEY'
},
body: JSON.stringify({
txid: 'SOME_TX_ID'
})
})
Handle user abort of payment.
Required: Payment ID
Required headers:
Authorization: Bearer API_KEY
fetch('https://api.aloha-pi.com/v1/transaction/u2a/abort/SOME_PAYMENT_ID', {
method: 'POST',
headers: {
'Authorization': 'Bearer API_KEY'
}
})
Get payment details.
Required: Payment ID
fetch('https://api.aloha-pi.com/v1/transaction/u2a/details/SOME_PAYMENT_ID', {
method: 'GET',
headers: {
'Authorization': 'Bearer API_KEY'
}
})
Create a new payment from app to user.
Required headers:
Content-Type: application/json Authorization: Bearer API_KEY
Request body:
{
"payment": {
"amount": 1,
"memo": "Payment for product XYZ",
"metadata": {"orderId": "12345", "productId": "xyz-001"},
"uid": "a1111111-aaaa-bbbb-2222-ccccccc3333d"
}
}
fetch('https://api.aloha-pi.com/v1/transaction/a2u/create', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer API_KEY'
},
body: JSON.stringify({
payment: {
amount: 1,
memo: "Payment for product XYZ",
metadata: {orderId: "12345", productId: "xyz-001"},
uid: "a1111111-aaaa-bbbb-2222-ccccccc3333d"
}
})
})
Cancel a pending payment.
Required: Payment ID
Required headers:
Authorization: Bearer API_KEY
fetch('https://api.aloha-pi.com/v1/transaction/a2u/cancel/SOME_PAYMENT_ID', {
method: 'POST',
headers: {
'Authorization': 'Bearer API_KEY'
}
})
Get all incomplete payments.
Required headers:
Authorization: Bearer API_KEY
fetch('https://api.aloha-pi.com/v1/transaction/a2u/incomplete', {
method: 'GET',
headers: {
'Authorization': 'Bearer API_KEY'
}
})
Get payment details.
Required: Payment ID
fetch('https://api.aloha-pi.com/v1/transaction/a2u/details/SOME_PAYMENT_ID', {
method: 'GET',
headers: {
'Authorization': 'Bearer API_KEY'
}
})
All responses follow this format:
{
"success": true,
"action": "",
"direction": "",
"piResData": { ... }, // Payment data from Pi Network
"sbResData": { ... } // Database operation results (when applicable)
}
{
"success": false,
"action": "", // Only included if action was processed
"direction": "", // Only included if direction was processed
"error": "Error message"
}
details action)