-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path05_Refund_Order.php
41 lines (32 loc) · 1.57 KB
/
05_Refund_Order.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
39
40
41
<?php
// include once ALFAcoins Private API class
require_once '../src/ALFAcoins_privateAPI.php';
require_once '../src/ALFAcoins_Exception.php';
use ALFAcoins\ALFAcoins_privateAPI;
use ALFAcoins\ALFAcoins_Exception;
// shop_name is the API name, replace 'ShopName 123' with your API name. Create API entry at https://www.alfacoins.com/user
$shop_name = 'ShopName 123';
// shop_password_hash is an uppercase md5 hash of API password, replace 'MyShopPassword' with your actual API password
$shop_password = 'MyShopPassword';
// shop_secret_key is your API secret_key, it's shown one time after you created the new API entry, if you didn't write it down you can reset it in your API settings
$shop_secret_key = 'a8a0e3497c8b67b024babc9a4daf5f5c';
// initialize ALFAcoins Private API class with your API settings
$api = new ALFAcoins_privateAPI($shop_name, $shop_password, $shop_secret_key);
// address where refund to
$address = "TR72hsBngLwseFNRkucLxSh54LJLGLrAgS";
// address memo
$memo = null;
// make full refund, more about it - https://www.alfacoins.com/developers#post_requests-refund
try {
echo 'Refund result:' . PHP_EOL;
var_dump($api->refund(409152, 0, $address, $memo, true));
} catch (ALFAcoins_Exception $e) {
echo "Refund method failed: " . $e->getMessage() . PHP_EOL;
}
// partial refund (e.g. 10 USD instead of the full order amount), default currency is set in your settings
try {
echo 'Refund result:' . PHP_EOL;
var_dump($api->refund(409152, 10, $address, $memo, true));
} catch (ALFAcoins_Exception $e) {
echo "Refund method failed: " . $e->getMessage() . PHP_EOL;
}