/** * @test */ public function shouldMarkFailedIfStatusFailed() { $action = new StatusAction(); $model = array('status' => Constants::STATUS_FAILED); $action->execute($status = new GetHumanStatus($model)); $this->assertTrue($status->isFailed()); }
/** * @test */ public function shouldMarkFailedIfModelHasErrorSet() { $action = new StatusAction(); $model = array('error' => array('code' => 'foo')); $action->execute($status = new GetHumanStatus($model)); $this->assertTrue($status->isFailed()); }
/** * @test */ public function shouldMarkFailedIfHashIsInvalid() { $action = new StatusAction(); $action->setApi(new Api(['alternate_passphrase' => 'passphares', 'payee_account' => 'account', 'display_name' => 'payment', 'sandbox' => true])); $model = [Api::FIELD_V2_HASH => 'invalid', Api::FIELD_PAYEE_ACCOUNT => 'account', Api::FIELD_PAYER_ACCOUNT => 'account', Api::FIELD_PAYMENT_AMOUNT => 0.01, Api::FIELD_PAYMENT_BATCH_NUM => 1, Api::FIELD_PAYMENT_ID => 15, API::FIELD_PAYMENT_UNITS => 'USD', API::FIELD_SUGGESTED_MEMO => 'test payment', API::FIELD_TIMESTAMPGMT => 1456652247]; $action->execute($status = new GetHumanStatus($model)); $this->assertTrue($status->isFailed()); }
/** * @test */ public function shouldMarkFailedIfStatusIsFailed() { $action = new StatusAction(); $action->execute($status = new GetHumanStatus(['http_status_code' => 200, 'transaction' => ['response_code' => 20000, 'status' => 'failed']])); $this->assertTrue($status->isFailed()); }
/** * @test */ public function shouldNotMatchOthersThenSuspendedStatus() { $statusRequest = new GetHumanStatus(new \stdClass()); $statusRequest->markSuspended(); $this->assertTrue($statusRequest->isSuspended()); $this->assertFalse($statusRequest->isCaptured()); $this->assertFalse($statusRequest->isExpired()); $this->assertFalse($statusRequest->isCanceled()); $this->assertFalse($statusRequest->isPending()); $this->assertFalse($statusRequest->isFailed()); $this->assertFalse($statusRequest->isNew()); $this->assertFalse($statusRequest->isUnknown()); }
/** * @test */ public function shouldMarkFailedIfExecCodeFailed() { $action = new StatusAction(); $action->execute($status = new GetHumanStatus(array('EXECCODE' => Api::EXECCODE_BANK_ERROR))); $this->assertTrue($status->isFailed()); }
/** * @test */ public function shouldMarkFailedIfStatusDenied() { $action = new StatusAction(); $action->execute($getStatus = new GetHumanStatus(array('status' => \KlarnaFlags::DENIED))); $this->assertTrue($getStatus->isFailed()); }
/** * @test */ public function shouldMarkFailedIfAuthResultIsError() { $action = new StatusAction(); $action->execute($status = new GetHumanStatus(['authResult' => 'ERROR'])); $this->assertTrue($status->isFailed()); }
<?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"; } }
/** * @test */ public function shouldNotMatchOthersThenPayedoutStatus() { $getStatus = new GetHumanStatus(new \stdClass()); $getStatus->markPayedout(); $this->assertTrue($getStatus->isPayedout()); $this->assertFalse($getStatus->isCaptured()); $this->assertFalse($getStatus->isAuthorized()); $this->assertFalse($getStatus->isExpired()); $this->assertFalse($getStatus->isCanceled()); $this->assertFalse($getStatus->isPending()); $this->assertFalse($getStatus->isFailed()); $this->assertFalse($getStatus->isNew()); $this->assertFalse($getStatus->isUnknown()); }