-
Notifications
You must be signed in to change notification settings - Fork 2
/
sample-init.php
54 lines (47 loc) · 1.71 KB
/
sample-init.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
<?php
use RainLab\User\Models\User as UserModel;
use Shohabbos\Payeer\Models\Transaction;
use Shohabbos\Portal\Models\Payment;
$payment = new Payment();
$payment->user_id = 1;
$payment->is_buy = true;
$payment->amount = 0.1;
$payment->payment_system = 'payeer';
$payment->date = date('Y-m-d H:i:s');
$payment->save();
Event::listen('shohabbos.payeer.existsAccount', function ($id, &$result) {
// find order or account
$result = UserModel::find($id);
});
Event::listen('shohabbos.payeer.checkAmount', function ($amount, $currency, &$result) {
// check amount
});
Event::listen('shohabbos.payeer.saveTransaction', function ($postData) {
// save transaction
$transaction = new Transaction();
$transaction->m_operation_id = $_POST['m_operation_id'];
$transaction->m_operation_ps = $_POST['m_operation_ps'];
$transaction->m_operation_date = $_POST['m_operation_date'];
$transaction->m_operation_pay_date = $_POST['m_operation_pay_date'];
$transaction->m_shop = $_POST['m_shop'];
$transaction->m_orderid = $_POST['m_orderid'];
$transaction->m_amount = $_POST['m_amount'];
$transaction->m_curr = $_POST['m_curr'];
$transaction->m_desc = $_POST['m_desc'];
$transaction->m_status = $_POST['m_status'];
$transaction->save();
});
Event::listen('shohabbos.payeer.successPayment', function ($id, $amount, $currency) {
// add balance or check order as paid
$user = UserModel::find($id);
$user->balance += $amount;
$user->save();
// add to history payments
$payment = new Payment();
$payment->user_id = $id;
$payment->is_buy = true;
$payment->amount = $amount;
$payment->payment_system = 'payeer';
$payment->date = date('Y-m-d H:i:s');
$payment->save();
});