/** * @param FinancialTransactionInterface $transaction * @throws \JMS\Payment\CoreBundle\Plugin\Exception\ActionRequiredException * * @return string */ protected function obtainInvoiceId(FinancialTransactionInterface $transaction) { $data = $transaction->getExtendedData(); if ($data->has('invoice_id')) { return $data->get('invoice_id'); } $options = $data->get('options'); $invoice = $this->bitpay->createInvoice($data->get('orderId'), $transaction->getRequestedAmount(), $data->get('posData'), $data->get('options')); $this->throwUnlessSuccessResponse($invoice, $transaction); $data->set('invoice_id', $invoice->id); $data->set('invoice_time', $invoice->invoiceTime); $data->set('url', $invoice->url); $data->set('btc_price', $invoice->btcPrice); $transaction->setReferenceNumber($invoice->id); $actionRequest = new ActionRequiredException('User must confirm transaction'); $actionRequest->setFinancialTransaction($transaction); $actionRequest->setAction(new VisitUrl($invoice->url)); throw $actionRequest; }
public function action_ipn() { $this->auto_render = FALSE; //ipn result validated $ipn_result = Bitpay::bpVerifyNotification(); if (isset($ipn_result['error'])) { Kohana::$log->add(Log::ERROR, $response); } else { //retrieve info for the item in DB $order = new Model_Order(); $order = $order->where('id_order', '=', $ipn_result['orderId'])->where('status', '=', Model_Order::STATUS_CREATED)->limit(1)->find(); if ($order->loaded()) { switch ($ipn_result['status']) { case 'paid': break; case 'confirmed': Kohana::$log->add(Log::DEBUG, 'BitPay bitcoin payment confirmed. Awaiting network confirmation and completed status.'); case 'complete': //mark as paid $order->confirm_payment('bitpay', isset($ipn_result['id']) ? $ipn_result['id'] : ''); $this->response->body('OK'); break; case 'invalid': Kohana::$log->add(Log::ERROR, 'Bitcoin payment is invalid for this order! The payment was not confirmed by the network within 1 hour.'); break; } } } $this->response->body('KO'); }
</ul> </div> <div class="text-right"> <ul class="list-inline"> <?php if (($sk = StripeKO::button($order)) != '') { ?> <li class="text-right"><?php echo $sk; ?> </li> <?php } ?> <?php if (($bp = Bitpay::button($order)) != '') { ?> <li class="text-right"><?php echo $bp; ?> </li> <?php } ?> <?php if (($two = twocheckout::form($order)) != '') { ?> <li class="text-right"><?php echo $two; ?> </li>