refactor: 规范状态码、抛出异常的使用
This commit is contained in:
@@ -41,7 +41,7 @@ class StripeAlipay {
|
||||
$currency = $this->config['currency'];
|
||||
$exchange = $this->exchange('CNY', strtoupper($currency));
|
||||
if (!$exchange) {
|
||||
throw new ApiException(500, __('Currency conversion has timed out, please try again later'));
|
||||
throw new ApiException(__('Currency conversion has timed out, please try again later'));
|
||||
}
|
||||
Stripe::setApiKey($this->config['stripe_sk_live']);
|
||||
$source = Source::create([
|
||||
@@ -59,7 +59,7 @@ class StripeAlipay {
|
||||
]
|
||||
]);
|
||||
if (!$source['redirect']['url']) {
|
||||
throw new ApiException(500, __('Payment gateway request failed'));
|
||||
throw new ApiException(__('Payment gateway request failed'));
|
||||
}
|
||||
return [
|
||||
'type' => 1,
|
||||
@@ -77,7 +77,7 @@ class StripeAlipay {
|
||||
$this->config['stripe_webhook_key']
|
||||
);
|
||||
} catch (\Stripe\Error\SignatureVerification $e) {
|
||||
throw new ApiException(400);
|
||||
abort(400);
|
||||
}
|
||||
switch ($event->type) {
|
||||
case 'source.chargeable':
|
||||
@@ -104,7 +104,7 @@ class StripeAlipay {
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new ApiException(500, 'event is not support');
|
||||
throw new ApiException('event is not support');
|
||||
}
|
||||
return('success');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user