mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
Test Stripe credentials when adding gateway
This commit is contained in:
parent
af8a5b5360
commit
af78a3dd2d
@ -60,6 +60,8 @@ class AccountGatewayController extends BaseController
|
||||
$data['hiddenFields'] = Gateway::$hiddenFields;
|
||||
$data['selectGateways'] = Gateway::where('id', '=', $accountGateway->gateway_id)->get();
|
||||
|
||||
$this->testGateway($accountGateway);
|
||||
|
||||
return View::make('accounts.account_gateway', $data);
|
||||
}
|
||||
|
||||
@ -322,6 +324,16 @@ class AccountGatewayController extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
private function testGateway($accountGateway)
|
||||
{
|
||||
$paymentDriver = $accountGateway->paymentDriver();
|
||||
$result = $paymentDriver->isValid();
|
||||
|
||||
if ($result !== true) {
|
||||
Session::flash('error', $result . ' - ' . trans('texts.gateway_config_error'));
|
||||
}
|
||||
}
|
||||
|
||||
protected function getWePayUpdateUri($accountGateway)
|
||||
{
|
||||
if ($accountGateway->gateway_id != GATEWAY_WEPAY) {
|
||||
|
@ -44,6 +44,11 @@ class BasePaymentDriver
|
||||
return $this->accountGateway->gateway_id == $gatewayId;
|
||||
}
|
||||
|
||||
public function isValid()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// optionally pass a paymentMethod to determine the type from the token
|
||||
protected function isGatewayType($gatewayType, $paymentMethod = false)
|
||||
{
|
||||
|
@ -39,6 +39,21 @@ class StripePaymentDriver extends BasePaymentDriver
|
||||
return $rules;
|
||||
}
|
||||
|
||||
public function isValid()
|
||||
{
|
||||
$result = $this->makeStripeCall(
|
||||
'GET',
|
||||
'charges',
|
||||
'limit=1'
|
||||
);
|
||||
|
||||
if (array_get($result, 'object') == 'list') {
|
||||
return true;
|
||||
} else {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
protected function checkCustomerExists($customer)
|
||||
{
|
||||
$response = $this->gateway()
|
||||
|
@ -2049,6 +2049,8 @@ $LANG = array(
|
||||
'no_contact_selected' => 'Please select a contact',
|
||||
'no_client_selected' => 'Please select a client',
|
||||
|
||||
'gateway_config_error' => 'It may help to set new passwords or generate new API keys.',
|
||||
|
||||
);
|
||||
|
||||
return $LANG;
|
||||
|
Loading…
x
Reference in New Issue
Block a user