|
|
@@ -24,43 +24,7 @@ class KlarnaController extends Controller
|
|
|
|
|
|
public function hook()
|
|
|
{
|
|
|
- $param = @file_get_contents('php://input');
|
|
|
- $header = $this->getAllHeaders();
|
|
|
- $data = [
|
|
|
- 'timestamp' => $header['x-timestamp'],
|
|
|
- 'signature' => $header['x-signature'],
|
|
|
- 'content' => $param
|
|
|
- ];
|
|
|
- $result = $this->airwallex->checkSignature($data, 'secret');
|
|
|
- if (!$result) {
|
|
|
- @header("HTTP/1.0 400 Bad Request");
|
|
|
- exit;
|
|
|
- }
|
|
|
- $notifyData = json_decode($param, true);
|
|
|
- $orderNo = $notifyData['data']['object']['merchant_order_id'] ?: 0;
|
|
|
- if (empty($orderNo)) {
|
|
|
- @header("HTTP/1.0 400 Bad Request");
|
|
|
- exit;
|
|
|
- }
|
|
|
- $prefix = $this->airwallex->getPrefix();
|
|
|
- if (strpos($orderNo, $prefix) === false) {
|
|
|
- @header("HTTP/1.0 200 ok");
|
|
|
- exit;
|
|
|
- }
|
|
|
- $type = $notifyData['name'];
|
|
|
- $orderId = str_replace($prefix, '', $orderNo);
|
|
|
- $transactionId = $notifyData['data']['object']['id'] ?: '';
|
|
|
- switch ($type) {
|
|
|
- case 'payment_intent.requires_capture':
|
|
|
- case 'payment_intent.succeeded':
|
|
|
- $this->airwallex->paymentSucceeded($orderId, $transactionId);
|
|
|
- @header("HTTP/1.0 200 ok");
|
|
|
- break;
|
|
|
- default:
|
|
|
- // 对于未知事件类型,记录日志但仍返回成功
|
|
|
- @header("HTTP/1.0 200 ok");
|
|
|
- break;
|
|
|
- }
|
|
|
+ echo '123';exit;
|
|
|
}
|
|
|
|
|
|
}
|