コード例 #1
0
 /**
  * {@inheritDoc}
  */
 public function setStatus($status)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setStatus', array($status));
     return parent::setStatus($status);
 }
コード例 #2
0
ファイル: BitPayPayment.php プロジェクト: bitpay/xcart-plugin
 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);
 }