forked from lemonwaysas/php-client-directkit-xml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSendPayment.php
93 lines (86 loc) · 3.27 KB
/
SendPayment.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
<?php
namespace LemonWay\Examples;
use LemonWay\Models\Wallet;
use LemonWay\Models\Card;
require_once '../LemonWay/Autoloader.php';
require_once 'ExamplesBootstrap.php';
$api = ExamplesBootstrap::getApiInstance();
/**
* Case : Send a payment from one wallet to another
* Steps :
* - RegisterWallet : creating 2 customer wallets
* - MoneyIn : crediting the first wallet
* - SendPayment : sending the remaining amount to another wallet
* - GetPaymentDetails : search the payment
*/
//Create first wallet
$wallet1 = ExamplesDatas::getRandomId();
$res = $api->RegisterWallet(array('wallet' => $wallet1,
'clientMail' => $wallet1.'@mail.fr',
'clientTitle' => Wallet::UNKNOWN,
'clientFirstName' => 'Paul',
'clientLastName' => 'Dupond'));
if (isset($res->lwError)){
print '<br/>Error, code '.$res->lwError->CODE.' : '.$res->lwError->MSG;
return;
}
print '<br/>Wallet1 created : ' . $res->wallet->ID;
//Credit first wallet
$res2 = $api->MoneyIn(array('wkToken'=>ExamplesDatas::getRandomId(),
'wallet'=>$wallet1,
'amountTot'=>'10.00',
'amountCom'=>'2.00',
'comment'=>'comment',
'cardType'=>Card::TYPE_CB,
'cardNumber'=>ExamplesDatas::CARD_SUCCESS_WITHOUT_3D,
'cardCrypto'=>ExamplesDatas::CARD_CRYPTO,
'cardDate'=>ExamplesDatas::CARD_DATE,
'autoCommission'=>Wallet::NO_AUTO_COMMISSION,
'isPreAuth'=>Wallet::NO_ATOS_PRE_AUTH));
if (isset($res2->lwError)){
print '<br/>Error, code '.$res2->lwError->CODE.' : '.$res2->lwError->MSG;
return;
}
print '<br/>Money-in successful. ID: '. $res2->operation->ID;
//Create second wallet
$wallet2 = ExamplesDatas::getRandomId();
$res3 = $api->RegisterWallet(array('wallet' => $wallet2,
'clientMail' => $wallet2.'@mail.fr',
'clientTitle' => Wallet::UNKNOWN,
'clientFirstName' => 'Paul',
'clientLastName' => 'Dupond2'));
if (isset($res3->lwError)){
print '<br/>Error, code '.$res3->lwError->CODE.' : '.$res3->lwError->MSG;
return;
}
print '<br/>Wallet2 created : ' . $res3->wallet->ID;
//Send money from wallet1 to wallet2
$amount = $res2->operation->CRED;
$res4 = $api->SendPayment(array('debitWallet' => $wallet1,
'creditWallet' => $wallet2,
'amount' => $amount,
'message' => 'my message'));
if (isset($res4->lwError)){
print '<br/>Error, code '.$res4->lwError->CODE.' : '.$res4->lwError->MSG;
return;
}
print '<br/>Payment successful : '. $res4->operation->ID;
//GetPaymentDetails
$res5 = $api->GetPaymentDetails(array('transactionId' => '',
'transactionComment' => 'my message',
'privateData' => ''));
if (isset($res5->lwError)){
print '<br/>Error, code '.$res5->lwError->CODE.' : '.$res5->lwError->MSG;
return;
}
print '<br/>Payment Details : <br />';
print '<br/>Payment ID : '. $res5->operations[0]->ID;
print '<br/>Payment Date : '. $res5->operations[0]->DATE;
print '<br/>Payment Sen : '. $res5->operations[0]->SEN;
print '<br/>Payment Rec : '. $res5->operations[0]->REC;
print '<br/>Payment Deb : '. $res5->operations[0]->DEB;
print '<br/>Payment Com : '. $res5->operations[0]->COM;
print '<br/>Payment Msg : '. $res5->operations[0]->MSG;
print '<br/>Payment Status : '. $res5->operations[0]->STATUS;
print '<br/>Payment Private data : '. $res5->operations[0]->PRIVATE_DATA;
print '<br/>Payment scheduled date : '. $res5->operations[0]->SCHEDULED_DATE;