Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
122 lines (105 sloc) 2.11 KB
<?php
/**
* @link https://craftcms.com/
* @copyright Copyright (c) Pixel & Tonic, Inc.
* @license https://craftcms.github.io/license/
*/
namespace craft\commerce\models\responses;
use Craft;
use craft\commerce\base\RequestResponseInterface;
use craft\commerce\models\payments\CreditCardPaymentForm;
/**
* This is a dummy gateway request response.
*
* @author Pixel & Tonic, Inc. <support@pixelandtonic.com>
* @since 2.0
*/
class Dummy implements RequestResponseInterface
{
private $_success = true;
// Public Methods
// =========================================================================
public function __construct(CreditCardPaymentForm $form = null)
{
if ($form !== null && (substr($form->number, -1) % 2 === 1)) {
$this->_success = false;
}
}
/**
* @inheritdoc
*/
public function isSuccessful(): bool
{
return $this->_success;
}
/**
* @inheritdoc
*/
public function isRedirect(): bool
{
return false;
}
/**
* @inheritdoc
*/
public function getRedirectMethod(): string
{
return '';
}
/**
* @inheritdoc
*/
public function getRedirectData(): array
{
return [];
}
/**
* @inheritdoc
*/
public function getRedirectUrl(): string
{
return '';
}
/**
* @inheritdoc
*/
public function getTransactionReference(): string
{
return date('Y-m-d-H-i-s');
}
/**
* @inheritdoc
*/
public function getCode(): string
{
return $this->_success ? '' : 'payment.failed';
}
/**
* @inheritdoc
*/
public function getMessage(): string
{
return $this->_success ? '' : Craft::t('commerce', 'Dummy gateway payment failed.');
}
/**
* @inheritdoc
*/
public function redirect()
{
return null;
}
/**
* @inheritdoc
*/
public function getData()
{
return '';
}
/**
* @inheritdoc
*/
public function isProcessing(): bool
{
return false;
}
}
You can’t perform that action at this time.