[guadec-web] Really, really, don't redirect from the gopay notifications url
- From: Rui Matos <rtcm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [guadec-web] Really, really, don't redirect from the gopay notifications url
- Date: Thu, 4 Jul 2013 09:03:09 +0000 (UTC)
commit 6b0922e6802894c4e5ef78c1a0fd68abe0421cdd
Author: Rui Matos <tiagomatos gmail com>
Date: Thu Jul 4 11:01:20 2013 +0200
Really, really, don't redirect from the gopay notifications url
wordcamp-base/registration.php | 28 +++++++++++++++++-----------
wordcamp-base/template-gopay-notify.php | 2 +-
2 files changed, 18 insertions(+), 12 deletions(-)
---
diff --git a/wordcamp-base/registration.php b/wordcamp-base/registration.php
index 6067f89..35cee75 100644
--- a/wordcamp-base/registration.php
+++ b/wordcamp-base/registration.php
@@ -282,13 +282,14 @@ class Registration {
}
}
-function error_page($msg, $url = null)
+function error_page($msg, $redirect = true)
{
- if ($url == null) {
- $url = get_permalink(get_page_by_title('Registration Error')->ID);
+ error_log($msg);
+ if (!$redirect) {
+ exit;
}
- error_log($msg);
+ $url = get_permalink(get_page_by_title('Registration Error')->ID);
header('Location: ' . $url);
exit;
}
@@ -329,13 +330,16 @@ function validate_code($code)
return true;
}
-function complete_registration($reg)
+function complete_registration($reg, $redirect = true)
{
$user = get_userdata($reg->user_ID);
$reg->set_completed();
send_tax_document($reg, $user);
send_registration_email($reg, $user);
+ if (!$redirect) {
+ exit;
+ }
header('Location: ' . get_permalink());
}
@@ -351,7 +355,7 @@ function check_gopay_params()
return true;
}
-function maybe_finish_payment($reg)
+function maybe_finish_payment($reg, $gopay_notify = false)
{
$returnedPaymentSessionId = $_GET['paymentSessionId'];
$returnedGoId = $_GET['targetGoId'];
@@ -360,7 +364,7 @@ function maybe_finish_payment($reg)
if ($returnedOrderNumber != $reg->ID
|| $returnedPaymentSessionId != $reg->payment_session_id) {
- error_page("got wrong secrets from gopay to finish registration $returnedOrderNumber with session
$returnedPaymentSessionId");
+ error_page("got wrong secrets from gopay to finish registration $returnedOrderNumber with session
$returnedPaymentSessionId", !$gopay_notify);
}
try {
@@ -381,19 +385,21 @@ function maybe_finish_payment($reg)
SECURE_KEY);
switch ($result["sessionState"]) {
case GopayHelper::PAID:
- complete_registration($reg);
+ complete_registration($reg, !$gopay_notify);
break;
case GopayHelper::AUTHORIZED:
case GopayHelper::PAYMENT_METHOD_CHOSEN:
// do nothing, we'll wait for further notifications or manual invervention
- header('Location: ' . get_permalink());
+ if (!$gopay_notify) {
+ header('Location: ' . get_permalink());
+ }
break;
default:
$reg->delete();
- error_page("payment for registration $reg->ID unsuccessful: " . $result["sessionState"]);
+ error_page("payment for registration $reg->ID unsuccessful: " . $result["sessionState"],
!$gopay_notify);
}
} catch (Exception $e) {
- error_page($e->getMessage());
+ error_page($e->getMessage(), !$gopay_notify);
}
}
diff --git a/wordcamp-base/template-gopay-notify.php b/wordcamp-base/template-gopay-notify.php
index ecaabbc..3deb3ff 100644
--- a/wordcamp-base/template-gopay-notify.php
+++ b/wordcamp-base/template-gopay-notify.php
@@ -17,6 +17,6 @@ if ($reg->completed) {
exit;
}
-maybe_finish_payment($reg);
+maybe_finish_payment($reg, true);
?>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]