From 9f350c0c5bafcf5fcfc9c8490d0a9b51fea3f7cd Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Thu, 7 Sep 2017 10:23:35 +0300 Subject: [PATCH] Working on gocardless --- .../GoCardlessV2RedirectPaymentDriver.php | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/app/Ninja/PaymentDrivers/GoCardlessV2RedirectPaymentDriver.php b/app/Ninja/PaymentDrivers/GoCardlessV2RedirectPaymentDriver.php index 012ffe1508..322212a88f 100644 --- a/app/Ninja/PaymentDrivers/GoCardlessV2RedirectPaymentDriver.php +++ b/app/Ninja/PaymentDrivers/GoCardlessV2RedirectPaymentDriver.php @@ -82,6 +82,27 @@ class GoCardlessV2RedirectPaymentDriver extends BasePaymentDriver \Log::info('handleWebHook... ' . $_SERVER['HTTP_WEBHOOK_SIGNATURE']); \Log::info(json_encode($input)); + /* + // We recommend storing your webhook endpoint secret in an environment variable + // for security, but you could include it as a string directly in your code + $token = getenv("GC_WEBHOOK_SECRET"); + + $raw_payload = file_get_contents('php://input'); + + $headers = getallheaders(); + $provided_signature = $headers["Webhook-Signature"]; + + $calculated_signature = hash_hmac("sha256", $raw_payload, $token); + + if ($provided_signature == $calculated_signature) { + // Process the events... + + header("HTTP/1.1 200 OK"); + } else { + header("HTTP/1.1 498 Invalid Token"); + } + */ + $event = $this->gateway()->parseNotification( file_get_contents('php://input'), $_SERVER['HTTP_WEBHOOK_SIGNATURE']