forked from lemonwaysas/php-client-directkit-xml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GetWalletDetails.php
163 lines (149 loc) · 5.48 KB
/
GetWalletDetails.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<?php
namespace LemonWay\Examples;
use LemonWay\Models\KycDoc;
use LemonWay\Models\SddMandate;
use LemonWay\Models\Wallet;
require_once '../LemonWay/Autoloader.php';
require_once 'ExamplesBootstrap.php';
$api = ExamplesBootstrap::getApiInstance();
/**
* Case : Get wallet details
* Steps :
* - RegisterWallet : creating customer wallet
* - UploadFile : upload a file
* - RegisterIBAN : attach an IBAN to the wallet
* - RegisterCard : attach a card to the wallet
* - RegisterSddMandate : attach an SDD mandate to the wallet
* - GetWalletDetails : get wallet details, will return basic info plus KYC that was uploaded, IBANs and SDD mandates attached to it
* - UnregisterCard : delete a card
* - GetWalletDetails : get wallet details, will return basic info plus KYC that was uploaded, IBANs and SDD mandates attached to it
*/
//RegisterWallet
$walletID = ExamplesDatas::getRandomId();
$res = $api->RegisterWallet(array('wallet' => $walletID,
'clientMail' => $walletID.'@mail.fr',
'clientTitle' => Wallet::UNKNOWN,
'clientFirstName' => 'Paul',
'clientLastName' => 'Dupond'));
if (isset($res->lwError)){
print 'Error, code '.$res->lwError->CODE.' : '.$res->lwError->MSG;
return;
}
print '<br/>Wallet created : ' . $res->wallet->ID;
//UploadFile
$buffer = file_get_contents(ExamplesDatas::FILE_UPLOAD, true);
$res2 = $api->UploadFile(array('wallet'=>$walletID,
'fileName'=>'thefilename.jpeg',
'type'=>KycDoc::TYPE_PROOF_OF_ADDRESS,
'buffer'=>base64_encode($buffer)));
if (isset($res2->lwError)){
print '<br/>Error, code '.$res2->lwError->CODE.' : '.$res2->lwError->MSG;
return;
}
print '<hr/><br/>Upload successful, file ID : '.$res2->kycDoc->ID;
//RegisterIBAN
$res3 = $api->RegisterIBAN(array('wallet'=>$walletID,
'holder' => ExamplesDatas::IBAN_HOLDER,
'bic' => ExamplesDatas::IBAN_BIC,
'iban' => ExamplesDatas::IBAN_NUMBER,
'dom1' => ExamplesDatas::IBAN_AD1,
'dom2' => ExamplesDatas::IBAN_AD2));
if (isset($res3->lwError)){
print '<br/>Error, code '.$res3->lwError->CODE.' : '.$res3->lwError->MSG;
return;
}
print '<hr/><br/>IBAN registration successful. Iban ID : '. $res3->iban->ID;
//RegisterSddMandate
$res4 = $api->RegisterSddMandate(array('wallet'=>$walletID,
'holder' => ExamplesDatas::IBAN_HOLDER,
'bic' => ExamplesDatas::IBAN_BIC,
'iban' => ExamplesDatas::IBAN_NUMBER,
'isRecurring' => SddMandate::RECURRING));
if (isset($res4->lwError)){
print '<br/>Error, code '.$res4->lwError->CODE.' : '.$res4->lwError->MSG;
return;
}
print '<hr/><br/>SDD mandate registration successful. Mandate ID : '. $res4->sddMandate->ID;
//RegisterCard
$resc = $api->RegisterCard(array('wallet'=>$walletID,
'cardType'=>'0',
'cardNumber'=>ExamplesDatas::CARD_SUCCESS_WITHOUT_3D,
'cardCode'=>ExamplesDatas::CARD_CRYPTO,
'cardDate'=>ExamplesDatas::CARD_DATE));
if (isset($resc->lwError)){
print 'Error, code '.$resc->lwError->CODE.' : '.$resc->lwError->MSG;
return;
}
print '<hr/><br/>Card saved. ID : '.$resc->card->ID;
print '<br/>Card EXTRA AUTH : '.$resc->card->EXTRA->AUTH;
print '<br/>Card EXTRA CTRY : '.$resc->card->EXTRA->CTRY;
//GetWalletDetails
$res5 = $api->GetWalletDetails(array('wallet'=>$walletID));
if (isset($res5->lwError)){
print '<br/>Error, code '.$res5->lwError->CODE.' : '.$res5->lwError->MSG;
return;
}
print '<hr/><br/>Wallet details found : ';
print '<br/>ID : '.$res5->wallet->ID;
print '<br/>BALANCE : '.$res5->wallet->BAL;
print '<br/>FULL NAME : '.$res5->wallet->NAME;
print '<br/>EMAIL : '.$res5->wallet->EMAIL;
print '<br/>BALANCE : '.$res5->wallet->BAL;
print '<br/>STATUS : '.$res5->wallet->STATUS;
print '<br/>BLOCKED : '.($res5->wallet->BLOCKED == Wallet::WALLET_BLOCKED ? 'BLOCKED' : 'NOT BLOCKED' );
foreach ($res5->wallet->kycDocs as $kycDoc)
{
print '<br/><br/>Kyc Document found :';
print '<br/>ID : '.$kycDoc->ID;
print '<br/>STATUS : '.$kycDoc->STATUS;
print '<br/>TYPE : '.$kycDoc->TYPE;
print '<br/>Validity limit : '.$kycDoc->VD;
}
foreach ($res5->wallet->ibans as $iban)
{
print '<br/><br/>IBAN found :';
print '<br/>ID : '.$iban->ID;
print '<br/>STATUS : '.$iban->STATUS;
print '<br/>IBAN NUMBER : '.$iban->IBAN;
print '<br/>BIC : '.$iban->BIC;
}
foreach ($res5->wallet->sddMandates as $sddMandate)
{
print '<br/><br/>SDD Mandate found :';
print '<br/>ID : '.$sddMandate->ID;
print '<br/>STATUS : '.$sddMandate->STATUS;
print '<br/>IBAN NUMBER : '.$sddMandate->IBAN;
print '<br/>BIC : '.$sddMandate->BIC;
}
foreach ($res5->wallet->cards as $card)
{
print '<br/><br/>Card found :';
print '<br/>ID : '.$card->ID;
print '<br/>EXTRA IS3DS : '.$card->EXTRA->IS3DS;
}
//UnRegisterCard
$resun = $api->UnRegisterCard(array('wallet'=>$walletID,
'cardId'=>$resc->card->ID));
if (isset($resun->lwError)){
print 'Error, code '.$resun->lwError->CODE.' : '.$resun->lwError->MSG;
return;
}
print '<hr/><br/>Card unregistered. ID : '.$resun->card->ID;
//GetWalletDetails
$res5 = $api->GetWalletDetails(array('wallet'=>$walletID));
if (isset($res5->lwError)){
print '<br/>Error, code '.$res5->lwError->CODE.' : '.$res5->lwError->MSG;
return;
}
print '<hr/><br/>Wallet details found : ';
print '<br/>ID : '.$res5->wallet->ID;
print '<br/>EMAIL : '.$res5->wallet->EMAIL;
if(count($res5->wallet->cards) == 0){
print '<br/>NO CARD FOUND IN THIS WALLET';
}
foreach ($res5->wallet->cards as $card)
{
print '<br/><br/>Card found :';
print '<br/>ID : '.$card->ID;
print '<br/>EXTRA IS3DS : '.$card->EXTRA->IS3DS;
}