Ejemplo n.º 1
0
 function post()
 {
     if ($this->checkAuth()) {
         if (AvailablePaymentMethodsData::hasBitPay()) {
             $jsonObj = json_decode(file_get_contents("php://input"));
             if (json_last_error() == JSON_ERROR_NONE) {
                 //file_put_contents('IPNData.txt', print_r($jsonObj, true));
                 $payment = new PaymentSystem();
                 $posDataObj = json_decode($jsonObj->posData);
                 $invoiceArr = explode(',', $posDataObj->invoiceList);
                 if (json_last_error() == JSON_ERROR_NONE) {
                     //file_put_contents('IPNPosData.txt', print_r($invoiceArr, true));
                     // todo: maybe confirm posData for extra Security?
                     if ($payment->confirmBitPayPaidComplete($jsonObj->id)) {
                         // todo: compare amounts paid vs invoice amount
                         //file_put_contents('here1.txt', $posDataObj->userID);
                         $payment->updateInvoicesPaid($invoiceArr, $jsonObj->id, PaymentMethod::BitPay, $posDataObj->userID);
                     } else {
                         if ($payment->confirmBitPayPending($jsonObj->id)) {
                             //file_put_contents('here2.txt', $posDataObj->userID);
                             $payment->updateInvoicesPending($invoiceArr, $posDataObj->userID);
                         }
                     }
                 } else {
                     // todo: record error somewhere
                 }
                 echo json_encode(StatusReturn::S200());
             } else {
                 echo json_encode(StatusReturn::E400('Bad JSON!'));
             }
         } else {
             echo json_encode(StatusReturn::E404('404 Not Found!'));
         }
     }
 }
Ejemplo n.º 2
0
 function delete_xhr($type, $paymentProfileID)
 {
     if ($this->checkAuth()) {
         $headers = getallheaders();
         $userPay = new PaymentSystem();
         $userPay->loadUser(mb_strtolower($headers['Auth-User']));
         if ($type == 'profiles') {
             if (isset($paymentProfileID) && $userPay->delPaymentProfile($paymentProfileID)) {
                 echo json_encode(StatusReturn::S200());
             } else {
                 echo json_encode(StatusReturn::E400('Profile Missing!'));
             }
         } else {
             echo json_encode(StatusReturn::E404('404 Not Found!'));
         }
     }
 }