Skip to content
Permalink
Browse files

initial commit

  • Loading branch information...
MaximKalga committed Apr 23, 2019
0 parents commit 24869c15962a303ae5034fcc4687f2b851490f83
Showing with 100 additions and 0 deletions.
  1. +100 −0 Readme.md
100 Readme.md
@@ -0,0 +1,100 @@
# xPay-Platform-SDK

- [Usage](#usage)
- [API Reference](#api-reference)
- [Request](#request)
- [Signature](#signature)
- [Response](#response)


## Usage

The xPay SDK Platform is used to withdraw users' funds from the platform to their xPay wallets.
To start sending commission payments from the platform, you should request your Platform Keys from an administrator. Users sign up on the platform and add their xpay wallet address in the profile settings. The platform must use [MyXPay](https://myxpay.net/) API to send withdrawal requests.


## API Reference

MyXPay API is organized around REST. Our API has predictable resource-oriented URLs, returns JSON-encoded responses.


## Request

#### Create Withdraw Request

| Param | Description |
| --- | --- |
| URL | https://myxpay.net/api/v2/platform/withdraw/ |
| Method | POST |
| Content-Type | application/json |

#### Request Data Params:

| Param | Description |
| --- | --- |
| api_key | your Platform API Key |
| address | users xPay wallet address |
| amount | amount in xPay with cents |
| signature | calculated signature for callback validation |
| description | optional operation description(doesn't appear in the signature) |

#### Request example:

``` bash
curl --header "Content-Type: application/json" \
--request POST \
--data '{"api_key":"1555830491-J64JlACG5Fnpl2o5L19hxb-FpGJdbmJ","address":"yJuay1EqAsXyI68CS9f1z10noakvt3LPx7kiozxgdmFc7tuVfExRBbr9v6AfEMqc","amount":"12.65","signature":"ab4fd93ec144dc7545908c4b9710f96c0833f5f5d035fd99958e30c77af58d72","description":"optional"}' \
https://myxpay.net/api/v2/platform/withdraw/
```


## Signature

The platform needs to sign requests according to the specified signature method. Any data sent in this way can be used safely. To verify sent withdrawal requests, API validates the signature on the backend. To create a signature, follow this example:

<details>
<summary><strong>Python 3</strong></summary>

``` python
# to create signature join api_key, address, amount and api_secret and make sha256 hash
from hashlib import sha256
api_key = "Your Platform API Key"
address = "Users xPay wallet address"
amount = "xPay amount with two digits"
api_secret = "Your Platform Secret Key"
raw_sign = f"{api_key}{address}{amount}{api_secret}"
signature = sha256(raw_sign.encode('ascii')).hexdigest()
print(signature)
```
</details>

<details>
<summary><strong>PHP</strong></summary>

``` php
<?php
// to create signature join api_key, address, amount and api_secret and make sha256 hash
$apiKey = "Your Platform API Key";
$userWallet = "Users xPay wallet address";
$amount = "xPay amount with two digits";
$apiSecret = "Your Platform Secret Key";
$calculatedSignature = hash("sha256", $apiKey . $userWallet . sprintf("%.02f", round($amount, 2)) . $apiSecret);
echo $calculatedSignature;
```
</details>


## Response

API response consists of status and error, if it exists.
The following responses are available:

| Status | Response |
| --- | --- |
| Success | {'status': 1, 'withdraw_id': '44'} |
| Error | {'status': 0, 'error': 'Wrong signature'} |
| Error | {'status': 0, 'error': 'Wrong API KEY - platform not found'} |
| Error | {'status': 0, 'error': 'Wrong address - wallet not found'} |
| Error | {'status': 0, 'error': 'Wrong amount format'} |

0 comments on commit 24869c1

Please sign in to comment.
You can’t perform that action at this time.