forked from ATM-Consulting-archives/dolibarr_module_slimpay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.php
101 lines (77 loc) · 2.17 KB
/
test.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
require_once 'lib/vendor/autoload.php';
require_once ('config.php');
use \HapiClient\Http;
use \HapiClient\Hal;
// hbmqwlrpwz5idas
// f%Oj5AvCJlMYiD~8m6#UG~c~sZ3q
// The HAPI Client
$hapiClient = new Http\HapiClient(
$conf->global->SLIMPAY_URLAPI,
'/',
'https://api.slimpay.net/alps/v1',
new Http\Auth\Oauth2BasicAuthentication(
'/oauth/token',
$conf->global->SLIMPAY_USER,
$conf->global->SLIMPAY_PASSWORD
)
);
//
// The Relations Namespace
$relNs = 'https://api.slimpay.net/alps#';
$rel = new Hal\CustomRel($relNs . 'get-creditors');
$follow = new Http\Follow($rel, 'GET', [
'reference' => $conf->global->SLIMPAY_CREDITORREF
]);
$res = $hapiClient->sendFollow($follow);
var_dump($res);
// The Resource's state
$state = $res->getState();
var_dump($state);
// Follow create-orders
$rel = new Hal\CustomRel($relNs . 'create-orders');
$follow = new Http\Follow($rel, 'POST', null, new Http\JsonBody(array(
'locale' => 'fr',
'reference' => null,
'started' => true,
'creditor' => array(
'reference' => $conf->global->SLIMPAY_CREDITORREF
),
'subscriber' => array(
'reference' => 'subscriber012222'
),
'items' => array(
array(
'type' => 'cardTransaction',
'cardTransaction' => array(
'amount' => '100',
'executionDate' => null,
'operation' => 'authorizationDebit',
'reference' => null
)
)
)
)
));
$res = $hapiClient->sendFollow($follow);
// The Resource's state
$state = $res->getState();
print 'create-orders<BR>';
var_dump($res, $state);
/*
// Follow get-creditor
$rel = new Hal\CustomRel($relNs . 'get-creditor');
$follow = new Http\Follow($rel, 'GET');
$res = $hapiClient->sendFollow($follow, $res);
// The Resource's state
$state = $res->getState();
print 'get-creditor<BR>';
var_dump($res, $state);
// Follow get-subscriber
$rel = new Hal\CustomRel($relNs . 'get-subscriber');
$follow = new Http\Follow($rel, 'GET');
$res = $hapiClient->sendFollow($follow, $res);
// The Resource's state
$state = $res->getState();
print 'get-subscriber<BR>';
var_dump($res, $state);*/