Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure handling #5

Merged
merged 7 commits into from
Dec 30, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions CRM/Core/Payment/OmnipayMultiProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ function doDirectPayment(&$params, $component = 'contribute') {
$this->gateway = Omnipay::create(str_replace('omnipay_', '', $this->_paymentProcessor['payment_processor_type']));
$this->setProcessorFields();
$this->setTransactionID(CRM_Utils_Array::value('contributionID', $params));
$this->storeReturnUrls($params['qfKey']);
$this->storeReturnUrls($params['qfKey'], CRM_Utils_Array::value('participantID', $params), CRM_Utils_Array::value('eventID', $params));
$this->saveBillingAddressIfRequired($params);

try {
Expand Down Expand Up @@ -545,12 +545,21 @@ public function processPaymentNotification($params) {
$this->handleError('error', $this->transaction_id . $e->getMessage(), 'ipn_completion', 9000, 'An error may have occurred. Please check your receipt is correct');
}
}
$_REQUEST = $originalRequest;
CRM_Utils_System::redirect($this->getStoredUrl('success'));
}
elseif ($this->transaction_id) {
civicrm_api3('contribution', 'create', array('id' => $this->transaction_id, 'contribution_status_id' => 'Failed'));
}
$userMessage = $response->getMessage();
if (method_exists($response, 'getInvalidFields') && ($invalidFields = $response->getInvalidFields()) != array()) {
$userMessage = ts('Invalid data entered in fields ' . implode(', ', $invalidFields));
}

$this->handleError('error', $this->transaction_id . ' ' . $response->getMessage(), 'processor_error', 9002, $userMessage);

$_REQUEST = $originalRequest;
CRM_Utils_System::redirect($this->getStoredUrl('success'));
CRM_Utils_System::redirect($this->getStoredUrl('fail'));
}

/**
Expand Down
26 changes: 25 additions & 1 deletion CRM/Core/Payment/PaymentExtended.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,28 @@ protected function getReturnSuccessUrl($qfKey) {
),
TRUE, NULL, FALSE
);
}

/**
* @param $key
* @param null $participantID
* @param null $eventID
* @return string
*/
protected function getReturnFailUrl($key, $participantID = NULL, $eventID = NULL) {
$test = $this->_is_test ? '&action=preview' : '';
if ($this->_component == "event") {
return CRM_Utils_System::url('civicrm/event/register',
"reset=1&cc=fail&participantId={$participantID}&id={$eventID}{$test}&qfKey={$key}",
FALSE, NULL, FALSE
);
}
else {
return CRM_Utils_System::url('civicrm/contribute/transact',
"_qf_Main_display=1&cancel=1&qfKey={$key}{$test}",
FALSE, NULL, FALSE
);
}
}

/**
Expand Down Expand Up @@ -142,9 +163,12 @@ protected function getGoBackUrl($qfKey) {
/**
* Store the URL for browser redirection in the session for use upon return
* @param $qfKey
* @param null $participantID
* @param null $eventID
*/
protected function storeReturnUrls($qfKey) {
protected function storeReturnUrls($qfKey, $participantID = NULL, $eventID = NULL) {
CRM_Core_Session::singleton()->set("ipn_success_url_{$this->transaction_id}", $this->getReturnSuccessUrl($qfKey));
CRM_Core_Session::singleton()->set("ipn_fail_url_{$this->transaction_id}", $this->getReturnFailUrl($qfKey, $participantID, $eventID));
}

/**
Expand Down
12 changes: 6 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

require_once __DIR__ . '/composer' . '/autoload_real.php';

return ComposerAutoloaderInitd7ce6b0ecc411238e36cfba3cfd63906::getLoader();
return ComposerAutoloaderInit2f446acaf1c72b6d037f252974f9891f::getLoader();
8 changes: 4 additions & 4 deletions vendor/composer/autoload_real.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// autoload_real.php @generated by Composer

class ComposerAutoloaderInitd7ce6b0ecc411238e36cfba3cfd63906
class ComposerAutoloaderInit2f446acaf1c72b6d037f252974f9891f
{
private static $loader;

Expand All @@ -19,9 +19,9 @@ public static function getLoader()
return self::$loader;
}

spl_autoload_register(array('ComposerAutoloaderInitd7ce6b0ecc411238e36cfba3cfd63906', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit2f446acaf1c72b6d037f252974f9891f', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInitd7ce6b0ecc411238e36cfba3cfd63906', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit2f446acaf1c72b6d037f252974f9891f', 'loadClassLoader'));

$includePaths = require __DIR__ . '/include_paths.php';
array_push($includePaths, get_include_path());
Expand All @@ -48,7 +48,7 @@ public static function getLoader()
}
}

function composerRequired7ce6b0ecc411238e36cfba3cfd63906($file)
function composerRequire2f446acaf1c72b6d037f252974f9891f($file)
{
require $file;
}
198 changes: 99 additions & 99 deletions vendor/composer/installed.json
Original file line number Diff line number Diff line change
Expand Up @@ -2201,50 +2201,6 @@
"purchase"
]
},
{
"name": "dioscouri/omnipay-cybersource",
"version": "dev-master",
"version_normalized": "9999999-dev",
"source": {
"type": "git",
"url": "https://github.com/eileenmcnaughton/omnipay-cybersource.git",
"reference": "159121d4e1d03ef9d1bc8cc7456ff3c3aebca5b7"
},
"require": {
"omnipay/common": "~2.0"
},
"require-dev": {
"omnipay/tests": "~2.0"
},
"time": "2014-10-29 08:42:24",
"type": "library",
"installation-source": "source",
"autoload": {
"psr-4": {
"Omnipay\\Cybersource\\": "src/"
}
},
"license": [
"MIT"
],
"authors": [
{
"name": "Rafael Diaz-Tushman",
"email": "rdiaztushman@dioscouri.com"
}
],
"description": "Cybersource support for Omnipay payment processing library",
"homepage": "https://github.com/dioscouri/omnipay-cybersource",
"keywords": [
"cybersource",
"gateway",
"merchant",
"omnipay",
"pay",
"payment",
"purchase"
]
},
{
"name": "omnipay/common",
"version": "2.3.2",
Expand Down Expand Up @@ -2733,61 +2689,6 @@
"standards"
]
},
{
"name": "symfony/http-foundation",
"version": "2.7.x-dev",
"version_normalized": "2.7.9999999.9999999-dev",
"target-dir": "Symfony/Component/HttpFoundation",
"source": {
"type": "git",
"url": "https://github.com/symfony/HttpFoundation.git",
"reference": "a16860109680ad9aa016744b6b8fda489b637163"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/a16860109680ad9aa016744b6b8fda489b637163",
"reference": "a16860109680ad9aa016744b6b8fda489b637163",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"require-dev": {
"symfony/expression-language": "~2.4"
},
"time": "2014-12-22 16:45:18",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.7-dev"
}
},
"installation-source": "source",
"autoload": {
"psr-0": {
"Symfony\\Component\\HttpFoundation\\": ""
},
"classmap": [
"Symfony/Component/HttpFoundation/Resources/stubs"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Symfony Community",
"homepage": "http://symfony.com/contributors"
},
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
}
],
"description": "Symfony HttpFoundation Component",
"homepage": "http://symfony.com"
},
{
"name": "symfony/yaml",
"version": "2.7.x-dev",
Expand Down Expand Up @@ -2988,5 +2889,104 @@
"payment",
"purchase"
]
},
{
"name": "dioscouri/omnipay-cybersource",
"version": "dev-master",
"version_normalized": "9999999-dev",
"source": {
"type": "git",
"url": "https://github.com/eileenmcnaughton/omnipay-cybersource.git",
"reference": "1507d67f189c40e879686984941ebaaa3b51ecf7"
},
"require": {
"omnipay/common": "~2.0"
},
"require-dev": {
"omnipay/tests": "~2.0"
},
"time": "2014-12-23 23:43:51",
"type": "library",
"installation-source": "source",
"autoload": {
"psr-4": {
"Omnipay\\Cybersource\\": "src/"
}
},
"license": [
"MIT"
],
"authors": [
{
"name": "Rafael Diaz-Tushman",
"email": "rdiaztushman@dioscouri.com"
}
],
"description": "Cybersource support for Omnipay payment processing library",
"homepage": "https://github.com/dioscouri/omnipay-cybersource",
"keywords": [
"cybersource",
"gateway",
"merchant",
"omnipay",
"pay",
"payment",
"purchase"
]
},
{
"name": "symfony/http-foundation",
"version": "2.7.x-dev",
"version_normalized": "2.7.9999999.9999999-dev",
"target-dir": "Symfony/Component/HttpFoundation",
"source": {
"type": "git",
"url": "https://github.com/symfony/HttpFoundation.git",
"reference": "75aa9d57bb6377fa89ad40014105ae9bdee28999"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/75aa9d57bb6377fa89ad40014105ae9bdee28999",
"reference": "75aa9d57bb6377fa89ad40014105ae9bdee28999",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"require-dev": {
"symfony/expression-language": "~2.4"
},
"time": "2014-12-23 17:36:18",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.7-dev"
}
},
"installation-source": "source",
"autoload": {
"psr-0": {
"Symfony\\Component\\HttpFoundation\\": ""
},
"classmap": [
"Symfony/Component/HttpFoundation/Resources/stubs"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Symfony Community",
"homepage": "http://symfony.com/contributors"
},
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
}
],
"description": "Symfony HttpFoundation Component",
"homepage": "http://symfony.com"
}
]
Loading