-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinit.php
38 lines (33 loc) · 1.38 KB
/
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
<?php
use RainLab\User\Models\User as UserModel;
use Shohabbos\Payeer\Models\Transaction;
use Shohabbos\Pixel\Models\Settings;
use Shohabbos\Payeer\Models\Settings as PayeerSettings;
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 += (Settings::get('rate_'.PayeerSettings::get('currency')) * $amount);
$user->save();
});