Esempio n. 1
0
 protected function doActionConnect()
 {
     $method = \XLite\Core\Database::getRepo('\\XLite\\Model\\Payment\\Method')->createQueryBuilder('p')->where('p.service_name = \'BitPay\'')->getResult()[0];
     $bitpayWrapper = new XcartWrapper($method);
     $connection = $bitpayWrapper->setting('connection');
     $private_key = $bitpayWrapper->setting('private_key');
     if (!empty($private_key) || $connection !== 'disconnected') {
         $bitpayWrapper->checkConnection();
     }
     \XLite\Core\Event::connectionState($connection);
 }
Esempio n. 2
0
 public function processCallback(\XLite\Model\Payment\Transaction $transaction)
 {
     $post = file_get_contents("php://input");
     if (true === empty($post)) {
         return array('error' => 'No post data');
         error_log("No post data");
     }
     $json = json_decode($post, true);
     if (true === is_string($json)) {
         return array('error' => $json);
         error_log($json);
     }
     if (false === array_key_exists('posData', $json)) {
         return array('error' => 'no posData');
         error_log("no posData");
     }
     if (false === array_key_exists('id', $json)) {
         return 'Cannot find invoice ID';
         error_log("Cannot find invoice ID");
     }
     $method = \XLite\Core\Database::getRepo('\\XLite\\Model\\Payment\\Method')->createQueryBuilder('p')->where('p.service_name = \'BitPay\'')->getResult()[0];
     $bitpayWrapper = new XcartWrapper($method);
     $response = $bitpayWrapper->getInvoice($json['id']);
     $invoiceId = $response->getPosData();
     switch ($response->getStatus()) {
         case 'paid':
             error_log("Paid for Invoice ID: " . $invoiceId);
             error_log("The payment has been received, but the transaction has not been confirmed on the bitcoin network. This will be updated when the transaction has been confirmed.");
             $status = $transaction::STATUS_PENDING;
             break;
         case 'confirmed':
             error_log("Confirmed for Invoice ID: " . $invoiceId);
             error_log("The payment has been received, and the transaction has been confirmed on the bitcoin network. This will be updated when the transaction has been completed.");
             $status = $transaction::STATUS_PENDING;
             break;
         case 'complete':
             error_log("Complete for Invoice ID: " . $invoiceId);
             error_log("The transaction is now complete.");
             $status = $transaction::STATUS_SUCCESS;
             break;
     }
     $transaction->setStatus($status);
 }