function it_handles_non_supported_requests(BitpayClient $bitPayClient, Capture $request)
 {
     $model = new Transaction();
     $model->createRequest(null, null);
     $bitPayClient->createInvoice($model->getRequest()->jsonSerialize())->willThrow('\\Exception');
     $request->getModel()->willReturn($model);
     $this->shouldThrow('\\Payum\\Core\\Exception\\RequestNotSupportedException')->duringExecute($request);
 }
Example #2
0
<?php

/**
 * @author      Peter Fox <*****@*****.**>
 * @copyright   Peter Fox 2014
 *
 * @package     payum-bitpay
 */
require_once __DIR__ . '/config.php';
use Payum\Core\Request\Capture;
use Payum\Core\Request\GetHumanStatus;
use PayumBitPay\Model\Transaction;
// Create the Transaction and configure the invoice request
$model = new Transaction();
$model->createRequest(0.0001, 'BTC')->setItemCode('TEST-ITEM-001')->setItemDesc('This is a test item using Payum BitPay')->setOrderID('TEST-ORDER-001');
// Request the invoice and check the current status
$payment = $registry->getPayment('bitpay');
$payment->execute(new Capture($model));
$payment->execute($status = new GetHumanStatus($model));
// If the status is new then it was created, BitPay will only make a request as complete
// when the invoice is paid and the blockchain has confirmed the payment which
// you would typically handle with HTTPS notifications
if ($status->isNew()) {
    echo "You can access your invoice at {$model->getResponse()->getUrl()}\n";
} else {
    if ($status->isFailed()) {
        echo "An error occured\n";
    } else {
        echo "Something went wrong but we don`t know the exact status\n";
    }
}