Index: src/XF/Payment/AbstractProvider.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/XF/Payment/AbstractProvider.php (revision 466e882018942ddd1f087a00d09bcb926cc3cb7c)
+++ src/XF/Payment/AbstractProvider.php (date 1523436429000)
@@ -127,10 +127,12 @@
public function validatePurchaser(CallbackState $state)
{
- if (!$state->getPurchaser())
+ $handler = $state->getPurchasableHandler();
+
+ if (!$handler->validatePurchaser($state, $error))
{
$state->logType = 'error';
- $state->logMessage = 'Could not find user with user_id ' . $state->getPurchaseRequest()->user_id . '.';
+ $state->logMessage = $error;
return false;
}
return true;
Index: src/XF/Purchasable/AbstractPurchasable.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/XF/Purchasable/AbstractPurchasable.php (revision 466e882018942ddd1f087a00d09bcb926cc3cb7c)
+++ src/XF/Purchasable/AbstractPurchasable.php (date 1523436515000)
@@ -72,6 +72,24 @@
*/
abstract public function reversePurchase(CallbackState $state);
+ public function validatePurchaser(CallbackState $state, &$error = null)
+ {
+ if (!$state->getPurchaser())
+ {
+ if ($state->getPurchaseRequest()->user_id)
+ {
+ $error = 'Could not find user with user_id ' . $state->getPurchaseRequest()->user_id . '.';
+ }
+ else
+ {
+ $error = 'Purchasable type ' . $this->purchasableTypeId . ' does not support payments from guests.';
+ }
+
+ return false;
+ }
+ return true;
+ }
+
/**
* Given a payment profile ID, we can enumerate the purchasable items
* which are used by these profiles. Useful to block accidental deletion