예제 #1
0
파일: pay.php 프로젝트: atofighi/payline
$url = 'http://localhost/payline/_example/pay.php';
$api = '';
require_once '../src/Payline.php';
$pay = new ATofighi\Payline($api);
$transactions = new TransactionManager();
$views = new ViewManager();
$views->globalData['input_amount'] = $input['amount'];
$views->globalData['url'] = $url;
switch ($input['action']) {
    case 'check':
        $r = $pay->get($input['trans_id'], $input['id_get']);
        if ($r == 1) {
            $tr = $transactions->get($input['id_get']);
            if ($tr) {
                if ($tr['status'] == 1) {
                    $views->display('layout', ['title' => 'خطا', 'error' => 'این تراکنش قبلا انجام شده بود!']);
                } else {
                    $tr['status'] = 1;
                    $tr['trans'] = $input['trans_id'];
                    $transactions->put($input['id_get'], $tr);
                    $views->display('layout', ['title' => 'سپاس', 'ok' => 'تراکنش با موفقیت انجام شد!']);
                }
            } else {
                $views->display('layout', ['title' => 'خطا', 'error' => 'تراکنش منقضی شده است.']);
            }
        } else {
            $views->display('layout', ['title' => 'خطا', 'error' => $pay->getError($r)]);
        }
        break;
    default:
        if ($input['submit']) {