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);
 }
 /**
  * @param Capture $request
  *
  * @throws RequestNotSupportedException if the action dose not support the request.
  */
 public function execute($request)
 {
     /** @var Transaction $model */
     $model = $request->getModel();
     try {
         $invoice = $this->bitPayClient->createInvoice($model->getRequest()->jsonSerialize());
     } catch (\Exception $ex) {
         throw new RequestNotSupportedException($ex->getMessage());
     }
     $model->setResponse($invoice);
 }
Example #3
0
 * @copyright   Peter Fox 2014
 *
 * @package     payum-bitpay
 */
require_once __DIR__ . '/../vendor/autoload.php';
use Payum\Core\Registry\SimpleRegistry;
use Payum\Core\Payment;
use Symm\BitpayClient\BitpayClient;
use PayumBitPay\BitPayCaptureAction as CaptureAction;
use PayumBitPay\BitPayStatusAction as StatusAction;
use PayumBitPay\BitPayNotificationAction as NotifyAction;
use PayumBitPay\Model\Transaction;
date_default_timezone_set('UTC');
// Read in the BitPay api key defined in the project root in .bitpay.key
$key = file_get_contents(__DIR__ . '/../.bitpay.key');
$bitPayClient = BitpayClient::createClient($key);
class TestStorage extends \Payum\Core\Storage\AbstractStorage
{
    /**
     * @param Transaction $model
     *
     * @return void
     */
    protected function doUpdateModel($model)
    {
        echo "Invoice {$model->getResponse()->getId()} has been stored\n";
    }
    /**
     * @param object $model
     *
     * @return void
Example #4
0
 public function testTestClientUsesTheTestHost()
 {
     $client = BitpayClient::createTestClient($this->apiKey);
     $baseUrl = $client->getConfig('base_url');
     $this->assertEquals('https://test.bitpay.com/api', $baseUrl);
 }