forked from lemonwaysas/php-client-directkit-xml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMoneyInCheque.php
58 lines (52 loc) · 1.93 KB
/
MoneyInCheque.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
<?php
namespace LemonWay\Examples;
use LemonWay\Models\Wallet;
require_once '../LemonWay/Autoloader.php';
require_once 'ExamplesBootstrap.php';
$api = ExamplesBootstrap::getApiInstance();
/**
* Case : Money-in Cheque
* Steps :
* - RegisterWallet : creating customer wallet
* - MoneyInChequeInit : provisionning cheque with 15 EUR, and automatically sending 1 EUR to your wallet (merchant).
* - GetMoneyInChequeDetails : search history
*
* Note :
* - Lemon Way will automatically debit its fees from merchant wallet
*/
$walletID = ExamplesDatas::getRandomId();
$res = $api->RegisterWallet(array('wallet' => $walletID,
'clientMail' => $walletID.'@mail.fr',
'clientTitle' => Wallet::MISTER,
'clientFirstName' => 'Paul',
'clientLastName' => 'Dupond'));
if (isset($res->lwError))
print 'Error, code '.$res->lwError->CODE.' : '.$res->lwError->MSG;
else {
print '<br/>Wallet created : ' . $res->wallet->ID;
//MoneyIn Cheque Init
$res2 = $api->MoneyInChequeInit(array('wallet' => $walletID,
'amountTot' => '15.00',
'amountCom' => '1.00',
'comment' => 'comment',
'autoCommission' => Wallet::NO_AUTO_COMMISSION,
'transferId' => ''));
if (isset($res2->lwError)){
print 'Error, code '.$res2->lwError->CODE.' : '.$res2->lwError->MSG;
return;
}
print '<br/>ID : '. $res2->operation->ID;
print '<br/>AMOUNT CREDITED TO ACCOUNT (After merchant fees): '. $res2->operation->CRED;
print '<br/>COMMISSION : '. $res2->operation->COM;
//GetMoneyInChequeDetails history
$res = $api->GetMoneyInChequeDetails(array('updateDate' => '1373448225'));
if (isset($res->lwError)) {
print 'Error, code '.$res->lwError->CODE.' : '.$res->lwError->MSG;
} else {
foreach ($res->operations as $operation) {
echo '<pre>';
print_r($operation);
echo '</pre>';
}
}
}