diff --git a/code/extensions/PayPalRestExtension.php b/code/extensions/PayPalRestExtension.php new file mode 100644 index 00000000..fa1a7631 --- /dev/null +++ b/code/extensions/PayPalRestExtension.php @@ -0,0 +1,52 @@ +isRestGateway()) { + unset($gatewayData['card']); + } + } + + /** + * @param array $gatewayData + */ + public function onBeforeCompletePurchase(array &$gatewayData) + { + /** + * As described in Omnipay\PayPal\Message\RestPurchaseRequest PayPal + * responds from the payment with the transaction reference and a + * PayerID as GET vars. We gather them and throw them back to PayPal + * for confirmation + */ + if ($this->isRestGateway()) { + $gatewayData['transactionReference'] = $_GET['paymentId']; + $gatewayData['payerId'] = $_GET['PayerID']; + } + } + + /** + * @return bool + */ + public function isRestGateway() + { + return ($this->owner->getPayment()->Gateway === 'PayPal_Rest'); + } +} diff --git a/code/model/Payment.php b/code/model/Payment.php index d3919bd1..a05da383 100644 --- a/code/model/Payment.php +++ b/code/model/Payment.php @@ -10,6 +10,13 @@ * paid or not, and the gateway used to make payment. * * @package payment + * @property string Gateway + * @property Money Money + * @property string Status + * @property string Identifier + * @property string TransactionReference + * @property string SuccessUrl + * @property string FailureUrl */ final class Payment extends DataObject implements PermissionProvider {