Файл: app/Rules/ValidateStripeCredentialsRule.php
Строк: 36
<?php
namespace AppRules;
use IlluminateContractsValidationRule;
class ValidateStripeCredentialsRule implements Rule
{
/**
* @var
*/
private $message;
/**
* Create a new rule instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Determine if the validation rule passes.
*
* @param string $attribute
* @param mixed $value
* @return bool
*/
public function passes($attribute, $value)
{
try {
StripeStripe::setApiKey($value);
StripeToken::retrieve(
'validate_credentials'
);
} catch (StripeExceptionAuthenticationException $e) {
$this->message = $e->getMessage();
return false;
} catch (Exception $e) {
return true;
}
return true;
}
/**
* Get the validation error message.
*
* @return string
*/
public function message()
{
return $this->message;
}
}