Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/chama/chama.php
+++ b/chama/chama.php
@@ -3,7 +3,7 @@
* Plugin Name: Chama
* Plugin URI: https://www.chamawp.com
* Description: Monetize your content with donations, paid subscriptions, crowdfunding and commissions.
- * Version: 1.0.12
+ * Version: 1.0.13
* Author: Leetoo
* Author URI: https://leetoo.net/
* License: GPLv3 or later
@@ -33,7 +33,7 @@
}
if (! defined('CHAMA_VERSION')) {
- define('CHAMA_VERSION', '1.0.12');
+ define('CHAMA_VERSION', '1.0.13');
}
if (! defined('CHAMAWP_URL')) {
define('CHAMAWP_URL', 'https://www.chamawp.com');
--- a/chama/inc/gateways/stripe/stripe-apple-pay.php
+++ b/chama/inc/gateways/stripe/stripe-apple-pay.php
@@ -1,4 +1,7 @@
<?php
+if (! defined('ABSPATH')) {
+ exit;
+}
/*
* Add query var if Stripe is looking for domain association file.
--- a/chama/inc/protection.php
+++ b/chama/inc/protection.php
@@ -345,7 +345,7 @@
wp_enqueue_style('chama-protected-content');
ob_start();
$protection_message = '';
- if (str_contains($post_level, '0.01')) {
+ if (false !== strpos($post_level, '0.01')) {
$protection_message = 'Only paying members can access this content';
} else {
$protection_message = 'Only for members signed up for at least the ' . $post_level . ' level';
--- a/chama/inc/shared.php
+++ b/chama/inc/shared.php
@@ -2135,3 +2135,104 @@
exit;
}
}
+
+/**
+ * Secret used to sign plugin generated URL payloads. Created once per site.
+ */
+function chama_get_signing_key()
+{
+ $key = get_option('chama_signing_key');
+ if (! $key) {
+ $key = wp_generate_password(64, true, true);
+ update_option('chama_signing_key', $key, false);
+ }
+ return $key;
+}
+
+/**
+ * Encode an array as a URL safe, HMAC signed token.
+ */
+function chama_encode_payload($data)
+{
+ $payload = rtrim(strtr(base64_encode(wp_json_encode($data)), '+/', '-_'), '=');
+ return $payload . '.' . hash_hmac('sha256', $payload, chama_get_signing_key());
+}
+
+/**
+ * Verify and decode a token from chama_encode_payload(). Returns [] if missing or tampered with.
+ */
+function chama_decode_payload($token)
+{
+ if (! is_string($token) || false === strpos($token, '.')) {
+ return [];
+ }
+ list($payload, $signature) = explode('.', $token, 2);
+ if (! hash_equals(hash_hmac('sha256', $payload, chama_get_signing_key()), $signature)) {
+ return [];
+ }
+ $json = base64_decode(strtr($payload, '-_', '+/'), true);
+ $data = $json ? json_decode($json, true) : null;
+ return is_array($data) ? $data : [];
+}
+
+/**
+ * Transaction post types a receipt may point at.
+ */
+function chama_get_transaction_post_types()
+{
+ return ['chama_donation', 'chama_subscription', 'chama_fund', 'chama_com_order'];
+}
+
+/**
+ * Encode a receipt ID for use in a confirmation link.
+ */
+function chama_encode_receipt_id($receipt_id)
+{
+ return chama_encode_payload(['id' => (int) $receipt_id]);
+}
+
+/**
+ * Resolve a receipt token to a post ID. Signed tokens are trusted; legacy
+ * unsigned IDs are only honoured for the owner or an administrator.
+ */
+function chama_get_receipt_id($token)
+{
+ $data = chama_decode_payload($token);
+ $is_signed = isset($data['id']);
+ $receipt_id = $is_signed ? (int) $data['id'] : (int) base64_decode((string) $token, true);
+
+ if ($receipt_id < 1 || ! in_array(get_post_type($receipt_id), chama_get_transaction_post_types(), true)) {
+ return 0;
+ }
+ if ($is_signed) {
+ return $receipt_id;
+ }
+ $owner = (int) get_post_meta($receipt_id, 'chama_user_id', true);
+ return (current_user_can('manage_options') || ($owner && get_current_user_id() === $owner)) ? $receipt_id : 0;
+}
+
+/**
+ * True when the current user may act on a subscription transaction.
+ */
+function chama_can_manage_subscription($subscription_id)
+{
+ if (current_user_can('manage_options')) {
+ return true;
+ }
+ $owner = (int) get_post_meta((int) $subscription_id, 'chama_user_id', true);
+ return $owner > 0 && get_current_user_id() === $owner;
+}
+
+/**
+ * True when reCAPTCHA is configured but no valid response was submitted.
+ * Callers must verify their nonce before calling this.
+ */
+function chama_has_failed_recaptcha()
+{
+ if (! defined('CHAMA_RECAPTCHA_SITE_KEY') || ! CHAMA_RECAPTCHA_SITE_KEY || ! CHAMA_RECAPTCHA_SECRET_KEY) {
+ return false;
+ }
+ // phpcs:ignore WordPress.Security.NonceVerification.Missing -- nonce verified by the calling handler.
+ $response = isset($_POST['chama-captcha-response']) ? sanitize_text_field(wp_unslash($_POST['chama-captcha-response'])) : '';
+ return '' === $response || chama_validate_recaptcha($response);
+}
--- a/chama/inc/template-functions.php
+++ b/chama/inc/template-functions.php
@@ -320,14 +320,8 @@
return;
}
//captcha
- if (isset($_POST['chama-captcha-response']) && ! empty($_POST['chama-captcha-response'])) {
-
- $gRecaptchaResponse = sanitize_text_field(wp_unslash($_POST['chama-captcha-response']));
- $has_invalid_recaptcha = chama_validate_recaptcha($gRecaptchaResponse);
- if ($has_invalid_recaptcha) {
- chama_errors()->add('captcha_error', __('Could not validate the reCaptcha. Please complete it again.', 'chama'));
- }
-
+ if (chama_has_failed_recaptcha()) {
+ chama_errors()->add('captcha_error', __('Could not validate the reCaptcha. Please complete it again.', 'chama'));
}
// retrieve all error messages
$errors = chama_errors()->get_error_messages();
@@ -425,14 +419,8 @@
return;
}
//captcha
- if (isset($_POST['chama-captcha-response']) && ! empty($_POST['chama-captcha-response'])) {
-
- $gRecaptchaResponse = sanitize_text_field(wp_unslash($_POST['chama-captcha-response']));
- $has_invalid_recaptcha = chama_validate_recaptcha($gRecaptchaResponse);
- if ($has_invalid_recaptcha) {
- chama_errors()->add('captcha_error', __('Could not validate the reCaptcha. Please complete it again.', 'chama'));
- }
-
+ if (chama_has_failed_recaptcha()) {
+ chama_errors()->add('captcha_error', __('Could not validate the reCaptcha. Please complete it again.', 'chama'));
}
// retrieve all error messages
@@ -563,8 +551,7 @@
if (empty($errors)) {
wp_update_user([
- 'ID' => $user_ID,
- 'user_pass' => $password,
+ 'ID' => $user->ID,
'user_email' => $email,
'first_name' => $first_name,
'last_name' => $last_name,
@@ -628,7 +615,7 @@
if (empty($errors)) {
wp_update_user([
- 'ID' => $user_ID,
+ 'ID' => $user->ID,
'user_pass' => $password,
]
);
@@ -655,14 +642,8 @@
try {
if (isset($_POST['chama_action']) && $_POST['chama_action'] == 'forgot-password') {
if (isset($_POST['chama_forgot_password_nonce']) && wp_verify_nonce(sanitize_key($_POST['chama_forgot_password_nonce']), 'chama-forgot-password-nonce')) {
- if (isset($_POST['chama-captcha-response']) && ! empty($_POST['chama-captcha-response'])) {
-
- $gRecaptchaResponse = sanitize_text_field(wp_unslash($_POST['chama-captcha-response']));
- $has_invalid_recaptcha = chama_validate_recaptcha($gRecaptchaResponse);
- if ($has_invalid_recaptcha) {
- chama_errors()->add('captcha_error', __('Could not validate the reCaptcha. Please complete it again.', 'chama'));
- }
-
+ if (chama_has_failed_recaptcha()) {
+ chama_errors()->add('captcha_error', __('Could not validate the reCaptcha. Please complete it again.', 'chama'));
}
$email = isset($_POST['chama_email']) ? sanitize_email(wp_unslash($_POST['chama_email'])) : '';
@@ -721,9 +702,13 @@
if (isset($_POST["chama_user_login"])) {
$username = sanitize_text_field(wp_unslash($_POST["chama_user_login"]));
- $user = get_user_by("login", $username);
- if ($user) {
+ $key = isset($_POST['chama_password_reset_key']) ? sanitize_text_field(wp_unslash($_POST['chama_password_reset_key'])) : '';
+ // The emailed one-time key is the only proof of ownership. A nonce is not.
+ $user = check_password_reset_key($key, $username);
+ if (is_wp_error($user)) {
+ chama_errors()->add('password_reset_key_invalid', __('This password reset link is invalid or has expired. Please request a new one.', 'chama'));
+ return;
}
$password = isset($_POST['chama_password']) ? sanitize_text_field(wp_unslash($_POST['chama_password'])) : '';
@@ -743,11 +728,8 @@
// only update the user in if there are no errors
if (empty($errors)) {
- wp_update_user([
- 'ID' => $user->ID,
- 'user_pass' => $password,
- ]
- );
+ // reset_password() also invalidates the key so it cannot be replayed.
+ reset_password($user, $password);
wp_redirect(add_query_arg('password-reset', 'true', CHAMA_RESET_PASSWORD_URL));
exit;
@@ -771,10 +753,9 @@
if (isset($_GET['chama_nonce']) && wp_verify_nonce(sanitize_key($_GET['chama_nonce']), 'chama_resend_confirmation_nonce')) {
- if (isset($_GET["user_id"])) {
- $user_id = sanitize_text_field(wp_unslash($_GET['user_id']));
- $user = get_userdata($user_id);
- $email = $user->user_email;
+ // Always target the logged in user; never a user ID from the URL.
+ $user_id = get_current_user_id();
+ if ($user_id) {
chama_user_register($user_id, true);
wp_redirect(add_query_arg('sent-link', 'true', CHAMA_ACCOUNT_URL));
exit;
@@ -808,7 +789,7 @@
$errors = chama_errors()->get_error_messages();
$payment_data = ['amount' => $one_time_amount, 'type' => 'one-time'];
- $encoded_payment_data = base64_encode(serialize($payment_data));
+ $encoded_payment_data = chama_encode_payload($payment_data);
$payment_link = add_query_arg(
[
'meta' => $encoded_payment_data,
@@ -866,7 +847,7 @@
if ($comission_addons) {
$payment_data['addons'] = $comission_addons;
}
- $encoded_payment_data = base64_encode(serialize($payment_data));
+ $encoded_payment_data = chama_encode_payload($payment_data);
$payment_link = add_query_arg(
[
'meta' => $encoded_payment_data,
@@ -907,11 +888,14 @@
if (isset($_GET["type"]) && isset($_GET['payment_intent']) && isset($_GET['receipt_id'])) {
try {
- $subscription_id = $receipt_id = '';
+ $subscription_id = '';
+ $cpt = '';
$type = sanitize_text_field(wp_unslash($_GET['type']));
$stripe_payment_intent_id = sanitize_text_field(wp_unslash($_GET['payment_intent']));
- if (isset($_GET["receipt_id"])) {
- $receipt_id = sanitize_text_field(wp_unslash($_GET["receipt_id"]));
+ $receipt_id = isset($_GET['receipt_id']) ? absint($_GET['receipt_id']) : 0;
+ // Restrict writes to this plugin's own transaction records.
+ if ($receipt_id && ! in_array(get_post_type($receipt_id), chama_get_transaction_post_types(), true)) {
+ wp_die('Invalid receipt.');
}
//get transaction post
if ($stripe_payment_intent_id) {
@@ -959,7 +943,7 @@
}
if ($receipt_id) {
- $confirmation_receipt_id = base64_encode($receipt_id);
+ $confirmation_receipt_id = chama_encode_receipt_id($receipt_id);
$confirmation_url = $type == 'membership' ?CHAMA_SUBSCRIPTION_CONFIRMATION_URL : CHAMA_PAYMENT_CONFIRMATION_URL;
$receipt_url = add_query_arg(
[
@@ -1125,7 +1109,7 @@
'methods' => 'POST',
'callback' => 'chama_handle_subscription_cancelation',
'permission_callback' => function () {
- return check_ajax_referer('wp_rest', '_wpnonce', false);
+ return is_user_logged_in() && check_ajax_referer('wp_rest', '_wpnonce', false);
},
]);
@@ -1133,7 +1117,7 @@
'methods' => 'POST',
'callback' => 'chama_handle_account_deletion',
'permission_callback' => function () {
- return check_ajax_referer('wp_rest', '_wpnonce', false);
+ return is_user_logged_in() && check_ajax_referer('wp_rest', '_wpnonce', false);
},
]);
@@ -1141,7 +1125,7 @@
'methods' => 'POST',
'callback' => 'chama_handle_subscription_pause',
'permission_callback' => function () {
- return check_ajax_referer('wp_rest', '_wpnonce', false);
+ return is_user_logged_in() && check_ajax_referer('wp_rest', '_wpnonce', false);
},
]);
@@ -1149,7 +1133,7 @@
'methods' => 'POST',
'callback' => 'chama_handle_subscription_resume',
'permission_callback' => function () {
- return check_ajax_referer('wp_rest', '_wpnonce', false);
+ return is_user_logged_in() && check_ajax_referer('wp_rest', '_wpnonce', false);
},
]);
@@ -1268,6 +1252,10 @@
if (isset($params['_wpnonce']) && wp_verify_nonce($params['_wpnonce'], 'wp_rest')) {
try {
$subscription_id = (int) $params['id'];
+ // Only the subscriber, or an administrator, may act on a subscription.
+ if (! chama_can_manage_subscription($subscription_id)) {
+ return new WP_REST_Response(['status' => 'error', 'message' => 'You are not allowed to perform this action.'], 403);
+ }
if ($subscription_id) {
$stripe_subscription_id = get_post_meta($subscription_id, 'chama_stripe_subscription_id', true);
$user_id = get_post_meta($subscription_id, 'chama_user_id', true);
@@ -1308,6 +1296,10 @@
if (isset($params['_wpnonce']) && wp_verify_nonce($params['_wpnonce'], 'wp_rest')) {
try {
$subscription_id = (int) $params['id'];
+ // Only the subscriber, or an administrator, may act on a subscription.
+ if (! chama_can_manage_subscription($subscription_id)) {
+ return new WP_REST_Response(['status' => 'error', 'message' => 'You are not allowed to perform this action.'], 403);
+ }
if ($subscription_id) {
$stripe_subscription_id = get_post_meta($subscription_id, 'chama_stripe_subscription_id', true);
$user_id = get_post_meta($subscription_id, 'chama_user_id', true);
@@ -1351,6 +1343,10 @@
if (isset($params['_wpnonce']) && wp_verify_nonce($params['_wpnonce'], 'wp_rest')) {
try {
$subscription_id = (int) $params['id'];
+ // Only the subscriber, or an administrator, may act on a subscription.
+ if (! chama_can_manage_subscription($subscription_id)) {
+ return new WP_REST_Response(['status' => 'error', 'message' => 'You are not allowed to perform this action.'], 403);
+ }
if ($subscription_id) {
$stripe_subscription_id = get_post_meta($subscription_id, 'chama_stripe_subscription_id', true);
$user_id = get_post_meta($subscription_id, 'chama_user_id', true);
@@ -2418,15 +2414,9 @@
return;
}
//captcha
- if (isset($_POST['chama-captcha-response']) && ! empty($_POST['chama-captcha-response'])) {
-
- $gRecaptchaResponse = sanitize_text_field(wp_unslash($_POST['chama-captcha-response']));
- $has_invalid_recaptcha = chama_validate_recaptcha($gRecaptchaResponse);
- if ($has_invalid_recaptcha) {
- chama_errors()->add('captcha_error', __('Could not validate the reCaptcha. Please complete it again.', 'chama'));
- return;
- }
-
+ if (chama_has_failed_recaptcha()) {
+ chama_errors()->add('captcha_error', __('Could not validate the reCaptcha. Please complete it again.', 'chama'));
+ return;
}
if (isset($_POST["chama_newsletter_email"])) {
--- a/chama/inc/utilities.php
+++ b/chama/inc/utilities.php
@@ -21,6 +21,9 @@
}
function chama_synchronize_subscription_renewals_ajax()
{
+ if (! current_user_can('manage_options')) {
+ return;
+ }
if (! isset($_POST['chama_nonce']) || ! wp_verify_nonce(sanitize_key($_POST['chama_nonce']), 'chama_sync_subscription_renewals_nonce')) {
return;
}
@@ -205,6 +208,9 @@
function chama_cancel_subscription_ajax()
{
+ if (! current_user_can('manage_options')) {
+ return;
+ }
if (! isset($_POST['chama_nonce']) || ! wp_verify_nonce(sanitize_key($_POST['chama_nonce']), 'chama_cancel_subscription_nonce')) {
return;
}
--- a/chama/inc/webhooks.php
+++ b/chama/inc/webhooks.php
@@ -6,6 +6,44 @@
die('Sorry, you cannot access this page.');
}
+/**
+ * Verify an incoming Stripe webhook payload and return the trusted Event.
+ *
+ * Prefers signature verification when a signing secret is stored. Otherwise the
+ * event is re-fetched from Stripe by ID, which a forged payload cannot satisfy.
+ * Returns null when the payload cannot be trusted.
+ */
+if (! function_exists('chama_verify_stripe_webhook_event')):
+ function chama_verify_stripe_webhook_event($payload)
+{
+ $mode = chama_is_live_mode() ? 'live' : 'test';
+ $secret = trim((string) get_option('chama_stripe_' . $mode . '_webhook_secret'));
+
+ if ($secret) {
+ $signature = isset($_SERVER['HTTP_STRIPE_SIGNATURE']) ? sanitize_text_field(wp_unslash($_SERVER['HTTP_STRIPE_SIGNATURE'])) : '';
+ try {
+ return ChamaWPVendorStripeWebhook::constructEvent($payload, $signature, $secret);
+ } catch (Exception $e) {
+ return null;
+ }
+ }
+
+ // No signing secret configured: confirm the event exists in our Stripe account.
+ $decoded = json_decode($payload, true);
+ $event_id = isset($decoded['id']) ? sanitize_text_field($decoded['id']) : '';
+ $secret_key = chama_is_live_mode() ? CHAMA_STRIPE_LIVE_SECRET_KEY : CHAMA_STRIPE_TEST_SECRET_KEY;
+ if (! $event_id || ! $secret_key) {
+ return null;
+ }
+ try {
+ $stripe = new ChamaWPVendorStripeStripeClient($secret_key);
+ return $stripe->events->retrieve($event_id);
+ } catch (Exception $e) {
+ return null;
+ }
+}
+endif;
+
add_action('init', 'chama_process_stripe_webhook');
if (! function_exists('chama_process_stripe_webhook')):
function chama_process_stripe_webhook()
@@ -23,16 +61,10 @@
echo 'Missing payload.';
exit;
}
- $event = null;
- try {
- $event = ChamaWPVendorStripeEvent::constructFrom(
- json_decode($payload, true)
- );
- } catch (UnexpectedValueException $e) {
- // Invalid payload
+ $event = chama_verify_stripe_webhook_event($payload);
+ if (! $event) {
http_response_code(400);
- die('⚠️ Webhook error while parsing basic request.');
- exit();
+ die('⚠️ Webhook signature or event could not be verified.');
}
// Switch through known Stripe webhook event types
switch ($event->type) {
--- a/chama/index.php
+++ b/chama/index.php
@@ -1,2 +1,4 @@
<?php
-die('Sorry, you cannot access this page.');
No newline at end of file
+if (! defined('ABSPATH')) {
+ exit;
+}
--- a/chama/templates/content-accounttransactions.php
+++ b/chama/templates/content-accounttransactions.php
@@ -133,7 +133,7 @@
$transaction_date = get_post_meta($id, $cpt . '_date_time', true);
$transaction_date_formatted = gmdate("F, j, Y", strtotime($transaction_date));
$status = get_post_meta($id, 'chama_payment_status', true);
- $confirmation_receipt_id = base64_encode($id);
+ $confirmation_receipt_id = chama_encode_receipt_id($id);
$description = get_post_meta($id, $cpt . '_description', true);
$subscription_status = get_post_meta($id, 'chama_subscription_status', true);
$receipt_url = add_query_arg(
--- a/chama/templates/content-campaignsnapshot.php
+++ b/chama/templates/content-campaignsnapshot.php
@@ -31,7 +31,7 @@
$social_url = $social_title = $facebook_url = $x_url = $whatsapp_url = $linkedin_url = '' ;
//setup payment link
$payment_data = array('amount' => $minimum_amount, 'type' => 'crowdfunding', 'campaign-id' => $post_id, 'description' => $title);
- $encoded_payment_data = base64_encode(serialize($payment_data));
+ $encoded_payment_data = chama_encode_payload($payment_data);
$payment_link = add_query_arg(
array(
'meta' => $encoded_payment_data,
--- a/chama/templates/content-payment.php
+++ b/chama/templates/content-payment.php
@@ -6,7 +6,9 @@
$validate_with_recaptcha = CHAMA_RECAPTCHA_SITE_KEY && CHAMA_RECAPTCHA_SECRET_KEY;
$publishable_key = chama_is_live_mode() ? CHAMA_STRIPE_LIVE_PUBLISHABLE_KEY : CHAMA_STRIPE_TEST_PUBLISHABLE_KEY;
$meta = sanitize_text_field( wp_unslash( filter_input(INPUT_GET, 'meta', FILTER_SANITIZE_FULL_SPECIAL_CHARS) ) );
- $show_payment_options = !empty( $meta );
+ // Signed payload only; never deserialise untrusted input.
+ $payment_data = chama_decode_payload($meta);
+ $show_payment_options = ! empty($payment_data);
$init_amount = 0;
$init_amount_cents = 0;
$display_amount = '';
@@ -26,8 +28,7 @@
$stripe_customer_session_client_secret = '';
if ($show_payment_options) {
- $payment_data = unserialize(base64_decode($meta));
- $type = $payment_data['type'];
+ $type = isset($payment_data['type']) ? $payment_data['type'] : '';
if (is_user_logged_in()) {
$user = wp_get_current_user();
$user_id = $user->ID;
--- a/chama/templates/content-paymentconfirmation.php
+++ b/chama/templates/content-paymentconfirmation.php
@@ -10,8 +10,8 @@
$type = isset($_GET['type']) ? sanitize_text_field( wp_unslash( $_GET['type'] ) ) : '';
- if ($receipt_id_encoded && $type) {
- $receipt_id = base64_decode($receipt_id_encoded);
+ $receipt_id = chama_get_receipt_id($receipt_id_encoded);
+ if ($receipt_id && $type) {
$email = get_post_meta($receipt_id, 'chama_email', true);
$full_name = get_post_meta($receipt_id, 'chama_full_name', true);
$status = get_post_meta($receipt_id, 'chama_payment_status', true);
--- a/chama/templates/content-resetpassword.php
+++ b/chama/templates/content-resetpassword.php
@@ -65,6 +65,7 @@
</p>
<input type="hidden" name="chama_action" value="reset-password"/>
<input type="hidden" name="chama_user_login" value="<?php echo esc_attr($user_login); ?>"/>
+ <input type="hidden" name="chama_password_reset_key" value="<?php echo esc_attr($key); ?>"/>
<input type="hidden" name="chama_password_reset_nonce" value="<?php echo esc_attr(wp_create_nonce('chama-password-reset-nonce')); ?>"/>
<input type="submit" class="chama-account-submit <?php echo esc_attr($disable ? 'chama-disabled-button' : 'chama-button' ); ?>" value="<?php esc_attr_e('Save Password', 'chama');?>" <?php echo esc_attr($disable ? 'disabled' : '' ); ?> />
</p>
--- a/chama/templates/content-subscription.php
+++ b/chama/templates/content-subscription.php
@@ -6,7 +6,9 @@
$validate_with_recaptcha = CHAMA_RECAPTCHA_SITE_KEY && CHAMA_RECAPTCHA_SECRET_KEY;
$publishable_key = chama_is_live_mode() ? CHAMA_STRIPE_LIVE_PUBLISHABLE_KEY : CHAMA_STRIPE_TEST_PUBLISHABLE_KEY;
$meta = sanitize_text_field( wp_unslash( filter_input(INPUT_GET, 'meta', FILTER_SANITIZE_FULL_SPECIAL_CHARS) ) );
-$show_subscription_options = !empty( $meta );
+// Signed payload only; never deserialise untrusted input.
+$payment_data = chama_decode_payload($meta);
+$show_subscription_options = ! empty($payment_data);
$init_amount = 0;
$init_amount_cents = 0;
$display_amount = '';
@@ -24,7 +26,6 @@
$stripe_customer_session_client_secret = '';
if ($show_subscription_options) {
- $payment_data = unserialize(base64_decode($meta));
if (is_user_logged_in()) {
$user = wp_get_current_user();
$user_id = $user->ID;
--- a/chama/templates/content-subscriptionconfirmation.php
+++ b/chama/templates/content-subscriptionconfirmation.php
@@ -9,8 +9,8 @@
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
$type = isset($_GET['type']) ? sanitize_text_field( wp_unslash( $_GET['type'] ) ) : '';
- if ($receipt_id_encoded && $type) {
- $receipt_id = base64_decode($receipt_id_encoded);
+$receipt_id = chama_get_receipt_id($receipt_id_encoded);
+ if ($receipt_id && $type) {
$email = get_post_meta($receipt_id, 'chama_email', true);
$full_name = get_post_meta($receipt_id, 'chama_full_name', true);
$payment_status = get_post_meta($receipt_id, 'chama_payment_status', true);
--- a/chama/templates/content-tiers.php
+++ b/chama/templates/content-tiers.php
@@ -41,7 +41,7 @@
$product_id = get_post_meta($post_id, 'tier_stripe_product_id', true);
$price_id = get_post_meta($post_id, 'tier_stripe_price_id', true);
$subscription_data = array('amount' => $price, 'type' => 'membership', 'tier' => $title, 'tier_id' => $post_id, 'product_id' => $product_id, 'price_id' => $price_id);
- $encoded_subscription_data = base64_encode(serialize($subscription_data));
+ $encoded_subscription_data = chama_encode_payload($subscription_data);
$subscription_link = add_query_arg(
array(
'meta' => $encoded_subscription_data,
--- a/chama/views/admin-branding-bar.php
+++ b/chama/views/admin-branding-bar.php
@@ -92,7 +92,9 @@
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
$post_id = isset($_GET['post']) ? sanitize_text_field(wp_unslash($_GET['post'])) : '';
if ($post_type) {
- $labels = get_post_type_labels(get_post_type_object($post_type));
+ // get_post_type_object()->labels is the public equivalent of the private get_post_type_labels().
+ $post_type_object = get_post_type_object($post_type);
+ $labels = $post_type_object ? $post_type_object->labels : null;
switch ($post_type) {
case 'chama_tier':
case 'chama_commission':
@@ -121,7 +123,7 @@
case 'chama_com_order':
$breadcrumb = $is_all ? $labels->name : $breadcrumb;
$breadcrumb = $is_edit ? 'Commission Order - ' . $post_id : $breadcrumb;
- $$test_mode_order = $post_type == 'chama_com_order' && $post_id ? get_post_meta($post_id, 'chama_is_test_commission_order', true) : false;
+ $test_mode_order = $post_type == 'chama_com_order' && $post_id ? get_post_meta($post_id, 'chama_is_test_commission_order', true) : false;
break;
}
}