0% found this document useful (0 votes)
70 views15 pages

1) Swap Xlab With Ether

The document describes the API documentation for an Xcel Pay system. It includes: 1) APIs for swapping Xlab tokens for Ether or Bitcoin, including requesting deposit addresses and verifying transactions. 2) APIs for purchasing instant packages with Xlab tokens using Ether or Bitcoin as payment, including requesting payment addresses and verifying transactions. 3) APIs for looking up mobile numbers to top up with Xlab tokens and reviewing available package amounts. The APIs provide endpoints, request/response parameters and examples of success/failure responses for each feature described.

Uploaded by

Redmen Ishab
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views15 pages

1) Swap Xlab With Ether

The document describes the API documentation for an Xcel Pay system. It includes: 1) APIs for swapping Xlab tokens for Ether or Bitcoin, including requesting deposit addresses and verifying transactions. 2) APIs for purchasing instant packages with Xlab tokens using Ether or Bitcoin as payment, including requesting payment addresses and verifying transactions. 3) APIs for looking up mobile numbers to top up with Xlab tokens and reviewing available package amounts. The APIs provide endpoints, request/response parameters and examples of success/failure responses for each feature described.

Uploaded by

Redmen Ishab
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

Xcel Pay Documentation

Xlab Swap Feature

1) Swap Xlab with Ether

a) Request ethereum address to send ether

Api Route : url/api/swap

Method: POST

Required parameters (request):

{
"walletAddress" : "0x5366E1257B3Ca59e2F24f3755D44dEf5a76A0643",
"exchangeType" : "ETH"
}

a) walletAddress → wallet address of user to send xlab to


b) exchangeType → exchange type (ETH in this case)

Response :

Success Response :
{

"status": 200, → status code


"success": true, →”true” when success, “false” when success is false
"receivingAddress": "n18z4k26bESxsakzuYAcjULLRjPPaHMksd",
"_id": "5e550e53f917844865f38a0f",
"message": "address generated"
}

a) status → status code


b) success → true when success false when fails
c) receiving address → address in which user should send ether (admin’s ethereum
address)
d) _id → id of the swap collection created
e) message → response message from the server
Failure Response :
{
"status": 400,
"success": false
}

Possible error cases :

1) If user’s ethereum wallet address is not provided


2) If exchange type is not provided
3) If any error occurred while generating ethereum address to send ether to

b) verify transaction hash returned when ether is sent to generated ethereum


address

Api Route : url/api/transaction/swap

Method : POST

Request

{
"swap_id":"5e550e22469ead483ba46425",
"tx_hash":"2c7763dd8042460f56cb1c537bad1547656c64b5d6c1ca975d9c800ab56d219c
"
}

swap_id : Id of the collection generated while requesting for ethereum address


tx_hash : transaction hash returned after sending ether to admin ethereum address

Response

Success Response
{
"status": 200,
"success": true,
"message": "Transaction successfully verified"
}

Failure Response
{
"status": 400,
"message": "Invalid transaction hash"
}

Failure Cases

1) transaction hash is invalid

Xlab is sent to users address as soon as system verifies the transaction

1) Swap Xlab with Bitcoin

a) Request bitcoin address to send ether

Api Route : url/api/swap

Method: POST

Required parameters (request):

{
"walletAddress" : "0x5366E1257B3Ca59e2F24f3755D44dEf5a76A0643",
"exchangeType" : "BTC"
}

a) walletAddress → wallet address of user to send xlab to (Ethereum address of user)


b) exchangeType → exchange type (BTC in this case)

Response :

Success Response :
{

"status": 200, → status code


"success": true, →”true” when success, “false” when success is false
"receivingAddress": "n18z4k26bESxsakzuYAcjULLRjPPaHMksd",
"_id": "5e550e53f917844865f38a0f",
"message": "address generated"
}

a) status → status code


b) success → true when success false when fails
c) receiving address → address in which user should send ether (admin’s ethereum
address)
d) _id → id of the swap collection created
e) message → response message from the server

Failure Response :
{
"status": 400,
"success": false
}

Possible error cases :

1) If user’s ethereum wallet address is not provided


2) If exchange type is not provided
3) If any error occurred while generating Btc address to send btc to

b) verify transaction hash returned when bitcoin is sent to generated bitcoin address

Api Route : url/api/transaction/swap

Method : POST

Request

{
"swap_id":"5e550e22469ead483ba46425",
"tx_hash":"2c7763dd8042460f56cb1c537bad1547656c64b5d6c1ca975d9c800ab56d219c
"
}

swap_id : Id of the collection generated while requesting for ethereum address


tx_hash : transaction hash returned after sending btc to admin btc address

Response

Success Response
{
"status": 200,
"success": true,
"message": "Transaction successfully verified"
}

Failure Response
{
"status": 400,
"message": "Invalid transaction hash"
}

Failure Cases

1) transaction hash is invalid

Xlab is sent to users address as soon as system verifies the transaction

Instant Packages Features

1) Get all instant packages

Api route : url/api/package

Method: GET

Response
{
"status": 200,
"data": [
{
"_id": "5e4bc4179623901473284337",
"name": "Platinum Package",
"type": "platinum",
"price": 0.2,
"bonus": 0.2,
"xlabAmount": 666.6666666666667,
"equivalentBTC": 0.000020545210089206174,
"equivalentETH": 0.0007497628874868324
}
],
"message": "Packages retrieved!"
}

status → status code


data → list of packages
_id : package id
name : name of package
type : type of packages
price : price of package in usd
bonus : bonus in percentage
xlabAmount : equivalent xlab
equivalentBTC : equivalent btc
equivalentEH : equivalent eth

2) Buy Instant Packages using Ether

a) request to by package

Api Route : url/api/package/buy

Method : Post

Request :
{
"package_id":"5e4bc4179623901473284339",
"walletAddress":"0xaEc12065c9bDC87d0F7C69FbFF17373B0F278e66",
"exchangeType":"ETH"
}

package_id → id of package to buy


walletAddress → address of user to send xlab to
echange type → type of exchange (ETH in this case)

Response

a) Success response

{
"status": 200,
"success": true,
"receivingAddress": "n226rf4F6aHgMQDrVqGHwDCLUhPEqZrQyK",
"_id": "5e563237f11cfb444e7aa7c8",
"message": "package successfully purchased"
}

b) Failure response

i) if package id is not provided


{
"status": 400,
"success": false,
"message": "Package Id not found"
}

ii if wallet address is not provided

{
"status": 400,
"success": false,
"message": "please provide users wallet address"
}

iii) If exchange type is not provided

{
"status": 400,
"success": false,
"message": "please provide exchange type"
}

3) Verify Ether Package Transaction

Api Route : url/api/transaction/package

Method : POST

Request

{
"package_id":"5e561f7d656d49351ec7e31e",

"tx_hash":"4eda0ba1cacfe699049db36049cb9d5412ab6f108685fbded4a88a8bd30c81c4"

package_id : id received from response when user buy’s package (not available package
id)

tx_hash : hash returned after user sends eth to admin address


Response

a) Success response

{
"status": 200,
"success": true,
"message": “ Transaction successfully verified”
}

b) Failure response

i) when invalid package purchase id is sent

{
"status": 400,
"success": false,
"message": "Package purchase details not found"
}

ii) When invalid transaction hash is sent

{
"status": 400,
"success": false,
"message": "Invalid transaction hash"
}

Xlab with bonus added is sent to users address as soon as system verifies the transaction

2) Buy Instant Packages using Bitcoin

a) request to by package

Api Route : url/api/package/buy

Method : Post
Request :
{
"package_id":"5e4bc4179623901473284339",
"walletAddress":"0xaEc12065c9bDC87d0F7C69FbFF17373B0F278e66",
"exchangeType":"BTC"
}

package_id → id of package to buy


walletAddress → address of user to send xlab to
echange type → type of exchange (BTC in this case)

Response

a) Success response

{
"status": 200,
"success": true,
"receivingAddress": "n226rf4F6aHgMQDrVqGHwDCLUhPEqZrQyK",
"_id": "5e563237f11cfb444e7aa7c8",
"message": "package successfully purchased"
}

b) Failure response

i) if package id is not provided

{
"status": 400,
"success": false,
"message": "Package Id not found"
}

ii if wallet address is not provided

{
"status": 400,
"success": false,
"message": "please provide users wallet address"
}
iii) If exchange type is not provided

{
"status": 400,
"success": false,
"message": "please provide exchange type"
}

3) Verify BTC Package Transaction

Api Route : url/api/transaction/package

Method : POST

Request

{
"package_id":"5e561f7d656d49351ec7e31e",

"tx_hash":"4eda0ba1cacfe699049db36049cb9d5412ab6f108685fbded4a88a8bd30c81c4"

package_id : id received from response when user buy’s package (not available package
id)

tx_hash : hash returned after user sends btc to admin address

Response

a) Success response

{
"status": 200,
"success": true,
"message": “ Transaction successfully verified”
}

b) Failure response

i) when invalid package purchase id is sent

{
"status": 400,
"success": false,
"message": "Package purchase details not found"
}
ii) When invalid transaction hash is sent

{
"status": 400,
"success": false,
"message": "Invalid transaction hash"
}

Xlab with added bonus is sent to users address as soon as system verifies the transaction

TOPUP WITH XLAB FEATURE

a) create a look up request

I) Request
uri/api/topup/lookup_number?number=9779823419712

2)response

{
"status": 200,
"data": {
"operator": {
"name": "Ncell Nepal",
"slug": "ncell-nepal",
"logoImage": "https://www.bitrefill.com/content/cn/d_operator.png/ncell-nepal",
"countryCode": "NP",
"type": "refill",
"number": "9779823419712",
"stats": {
"popularity": 3.979511426319937,
"packageSize": 1.6
},
"recipientType": "phone_number",
"isPinBased": false,
"isRanged": true,
"currency": "NPR",
"packages": [
{
"value": "500",
"eurPrice": 4.32,
"satoshiPrice": 86000,
"usdPrice": 4.72,
"userPrice": 86000
},
{
"value": "1000",
"eurPrice": 8.64,
"satoshiPrice": 172000,
"usdPrice": 9.44,
"userPrice": 172000
},
{
"value": "1500",
"eurPrice": 12.96,
"satoshiPrice": 258000,
"usdPrice": 14.16,
"userPrice": 258000
},
{
"value": "2000",
"eurPrice": 17.28,
"satoshiPrice": 344000,
"usdPrice": 18.88,
"userPrice": 344000
},
{
"value": "2500",
"eurPrice": 21.6,
"satoshiPrice": 429900,
"usdPrice": 23.6,
"userPrice": 429900
},
{
"value": "3000",
"eurPrice": 25.92,
"satoshiPrice": 515900,
"usdPrice": 28.32,
"userPrice": 515900
},
{
"value": "3500",
"eurPrice": 30.23,
"satoshiPrice": 601900,
"usdPrice": 33.03,
"userPrice": 601900
},
{
"value": "4000",
"eurPrice": 34.55,
"satoshiPrice": 687900,
"usdPrice": 37.75,
"userPrice": 687900
},
{
"value": "4500",
"eurPrice": 38.87,
"satoshiPrice": 773900,
"usdPrice": 42.47,
"userPrice": 773900
},
{
"value": "5000",
"eurPrice": 43.19,
"satoshiPrice": 859800,
"usdPrice": 47.19,
"userPrice": 859800
}
],
"range": {
"min": 10,
"max": 5000,
"step": 1,
"customerPriceRate": 0.008636793544077516,
"customerSatoshiPriceRate": 171.95861792851343,
"customerEurPriceRate": 0.008636793544077516,
"userPriceRate": 171.95861792851343,
"purchaseFee": null
},
"extraInfo": "Orders in Nepal are subject to a local VAT tax of 2%"
},
"userRef": "c3765e7a-ff95-418d-9d2c-8245b3d5b326"
},
"message": "TopUp request send"
}

operatorSlug: "ntc-nepal"
B) request for top up valuePackage: "10"
mobileNumber: "9779860251012"
Request paymentMethod: "ethereum"
method: POST senderAddress: "0xdfa7E6962d65870F34388E12fF1380e66c1F8
email: null
url/api/topup/order/{ref_id} refId: "7f5fc1b5-2a53-4920-a16d-cd585ce5204a"
remarks: null
body: { symbol: "ETH"
"mobileNumber":"9779823419712",
fee: 0.00021
"valuePackage":"100",
"paymentMethod":"XLAB",
"senderAddress":"0x1599d2d14e1fcd251f42bc5cfeea4f70201d8000",
"amount":"100"
}

mobileNumber: mobile number to topup


valuePackage: value package returned from lookup
paymentMethod: XLAB in this case
senderAddress: wallet address adress of xcelpay user
amount: total amount in xlab thats need to be sent

response :
{
"status": 200,
"data": {
"address": "0xe374ff78b72ec12a34977b68fa84046c68d4e0d7",
"amount": "100"
},
"message": "TopUp order requested. Please send amount in given address"
}

address: address that the user needs to send xlab to


amount: amount of xlab that needs to be sent(returning back the same amount that is sent
in request)

c) verify the transaction hash

request

method: POST

uri/api/topup/verify

{
"refId":"c3765e7a-ff95-418d-9d2c-8245b3d5b326", (required)
"txHash":"0xde2d94c77d27f59fad1868c3fe266816920dd51e82f7a125a7343734518d370
4" (required)
}

refId: reference id of the topup request

txHash: hash returned after sending xlab to previous returned address

Response

{
"status": 200,
"message": "transaction hash saved"
}

The system will keep on looking for topups that has been verified and send balance to the
user number as soon as all the work is completed

You might also like