Skip to content

Commit ceeb1c1

Browse files
Fix Omnipay error on redirect #6.
Omnipay provides no additional info or parameters in the return url so resorting to storing & retrieving from session
1 parent ceaa886 commit ceeb1c1

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

CRM/Core/Payment/OmnipayMultiProcessor.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ private function getCreditCardOptions($params, $component) {
380380
}
381381
$creditCardOptions = array(
382382
'amount' => $amount,
383-
// Contribution page in 4.4 passes currencyID - not sure which passes currency (if any).
383+
// Contribution page in 4.4 (confirmed Event online, 4.7) passes currencyID - not sure which passes currency (if any).
384384
'currency' => strtoupper(!empty($params['currencyID']) ? $params['currencyID'] : $params['currency']),
385385
'description' => $this->getPaymentDescription($params),
386386
'transactionId' => $this->transaction_id,
@@ -808,11 +808,17 @@ public function processPaymentNotification($params) {
808808
$this->createGateway($params['processor_id']);
809809
$originalRequest = $_REQUEST;
810810
$_REQUEST = $params;
811-
$response = $this->gateway->completePurchase($params)->send();
811+
try {
812+
$response = $this->gateway->completePurchase($params)->send();
812813

813-
if ($response->getTransactionId()) {
814-
$this->setTransactionID($response->getTransactionId());
814+
if ($response->getTransactionId()) {
815+
$this->setTransactionID($response->getTransactionId());
816+
}
815817
}
818+
catch (\Omnipay\Common\Exception\InvalidRequestException $e) {
819+
$this->redirectOrExit('success');
820+
}
821+
816822
if ($response->isSuccessful()) {
817823
try {
818824
//cope with CRM14950 not being implemented

CRM/Core/Payment/PaymentExtended.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,9 @@ protected function getNotifyUrl($allowLocalHost = FALSE) {
214214
*/
215215
protected function storeReturnUrls($qfKey, $participantID = NULL, $eventID = NULL) {
216216
CRM_Core_Session::singleton()->set("ipn_success_url_{$this->transaction_id}", $this->getReturnSuccessUrl($qfKey));
217+
CRM_Core_Session::singleton()->set("ipn_success_url_fallback", $this->getReturnSuccessUrl($qfKey));
217218
CRM_Core_Session::singleton()->set("ipn_fail_url_{$this->transaction_id}", $this->getReturnFailUrl($qfKey, $participantID, $eventID));
219+
CRM_Core_Session::singleton()->set("ipn_fail_url_fallback", $this->getReturnFailUrl($qfKey, $participantID, $eventID));
218220
}
219221

220222
/**
@@ -237,7 +239,7 @@ protected function storeTransparentRedirectFormData($key, $data) {
237239
* Url to redirect to
238240
*/
239241
protected function getStoredUrl($type) {
240-
return CRM_Core_Session::singleton()->get("ipn_{$type}_url_{$this->transaction_id}");
242+
return CRM_Core_Session::singleton()->get("ipn_{$type}_url_" . ($this->transaction_id ? : 'fallback'));
241243
}
242244

243245
/**

0 commit comments

Comments
 (0)