-
Notifications
You must be signed in to change notification settings - Fork 2
/
XapoCreditAPI.php
38 lines (32 loc) · 1.13 KB
/
XapoCreditAPI.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
require 'XapoUtil.php';
// Xapo Credit API
class XapoCreditAPI {
public $appID;
public $appSecret;
public $serviceUrl;
function __construct($serviceUrl, $appID, $appSecret) {
$this->serviceUrl = $serviceUrl;
$this->appID = $appID;
$this->appSecret = $appSecret;
$this->resource = "/credit/";
}
public function credit($to, $currency, $unique_request_id, $amount, $comments) {
// build the payload
$payload = new stdClass;
$payload->to = $to;
$payload->currency = $currency;
$payload->amount = $amount;
$payload->comments = $comments;
$payload->timestamp = time();
$payload->unique_request_id = $unique_request_id;
// convert to json and encrypt
$json = json_encode($payload);
$hash = XapoUtil::encrypt($json, $this->appSecret);
$payload = array("appID" => $this->appID, "hash" => $hash);
// call de API
$result = XapoUtil::callAPI("POST", $this->serviceUrl . $this->resource, $payload);
return json_decode($result);
}
}
?>