Exemple #1
3
 /**
  * @Route("/api/pay/confirm/{hash}", name="api-confirm-payment", options={"expose"=true})
  * @param Request $request
  * @param string $hash
  * @return JsonResponse
  */
 public function confirmOrder(Request $request, $hash)
 {
     $liqpay = new \LiqPay($this->public_key, $this->private_key);
     $res = $liqpay->api("payment/status", array('version' => '3', 'order_id' => $hash));
     /** @var EntityManager $em */
     $em = $this->getDoctrine()->getManager();
     /** @var User $user */
     $user = $this->getUser();
     $order = $em->getRepository('NaidusvoeBundle:Order')->findOneBy(['hash' => $hash]);
     if ($user->getId() !== $order->getUserId()) {
         new JsonResponse(['status' => 'error', 'message' => 'NOT_ALLOWED']);
     }
     $payment = $em->getRepository('NaidusvoeBundle:Payment')->findOneBy(['hash' => $hash]);
     if ($payment === null) {
         switch ($res['status']) {
             case 'success':
             case 'sandbox':
                 return $this->handleConfirmation($order, $res);
             case 'failure':
             case 'error':
             case '3ds_verify':
             case 'wait_secure':
             case 'wait_accept':
             case 'processing':
                 break;
             default:
                 break;
         }
         return new JsonResponse(['status' => 'error', 'message' => 'PAYMENT_FAILED']);
     } else {
         return new JsonResponse(['status' => 'ok', 'details' => $payment->getDetails()]);
     }
 }
Exemple #2
0
<?php

require 'classes/database.class.php';
require 'classes/LiqPay.php';
require 'classes/email.class.php';
require 'classes/smsclient.class.php';
$params = (require 'params.php');
$publicKey = $params['liqpay']['publicKey'];
$privateKey = $params['liqpay']['privateKey'];
$liqpay = new LiqPay($publicKey, $privateKey);
$db = new Database();
$email = new Email();
$allInActiveOrder = $db->getInactiveOrders();
$sms = new SmsClient($params['SmsUkraine']['login'], $params['SmsUkraine']['password']);
foreach ($allInActiveOrder as $order) {
    $res = $liqpay->api("payment/status", array('version' => '3', 'order_id' => $order['clientId']));
    if ($res->result == 'error') {
        if ($db->sendErrorSms($order['clientId'])) {
            if ($db->setAsError($order['clientId'])) {
                $sms->sendSMS('BurgerJoint', $order['phoneNumber'], 'Ваше замовлення скасовано. Для детальної iнформацiї звертайтесь за телефоном +38 (068) 235 50 29');
            }
        }
    } elseif ($res->result == 'ok') {
        if ($res->amount != $order['amount']) {
            $temp = ['res' => $res->amount, 'amount' => $order['amount'], 'check' => $res->amount != $order['amount']];
            $db->setAsError($res->order_id);
            $sms->sendSMS('BurgerJoint', $res->sender_phone, 'Ваше замовлення скасовано. Для детальної iнформацiї звертайтесь за телефоном +38 (068) 235 50 29');
            $htmlString = $email->postDataToString(array_merge((array) $res, ['-' => '-'], $order, $temp));
            $email->sendEmail('Данi не спiвпадають' . $htmlString, false, $order['clientId']);
        } else {
            if ($db->setAsPaid($order['clientId'])) {
<?php

require 'classes/LiqPay.php';
$params = (require 'params.php');
$publicKey = $params['liqpay']['publicKey'];
$privateKey = $params['liqpay']['privateKey'];
$id = $_GET['id'];
$liqpay = new LiqPay($publicKey, $privateKey);
$res = $liqpay->api("payment/status", array('version' => '3', 'order_id' => $id));
if ($res->result == 'ok') {
    header("Location: /index.html#/success");
} elseif ($res->result == 'error') {
    header("Location: /index.html#/failure");
} else {
    header("Location: /index.html#/pending");
}