Skip to content

Instantly share code, notes, and snippets.

@merk
Created August 10, 2011 04:38
Show Gist options
  • Save merk/1136130 to your computer and use it in GitHub Desktop.
Save merk/1136130 to your computer and use it in GitHub Desktop.
Velociraptors!
<?php
// ... <inside a large payment processing function, where velociraptors can be heard> ...
$form = $this->getForm($formName);
foreach ((array) $errors as $errNo => $error)
{
switch ($errNo)
{
case "0" : // Transaction Successful
continue;
case "4" : $result = "Expired Card";
$form->getElement('expDateMonth')->addError('Expired Card or Invalid expiry date');
$form->getElement('expDateYear')->addError('Expired Card or Invalid expiry date');
continue;
case "U" : $result = "Card Security Code Failed"; goto addCSCError; break;
case "V" : $result = "Address Verification and Card Security Code Failed"; goto addCSCError; break;
case "?" : $result = "Transaction status is unknown"; goto addError; break;
case "1" : $result = "Unknown Error"; goto addError; break;
case "2" : $result = "Bank Declined Transaction"; goto addError; break;
case "3" : $result = "No Reply from Bank"; goto addError; break;
case "5" : $result = "Insufficient funds"; goto addError; break;
case "6" : $result = "Error Communicating with Bank"; goto addError; break;
case "7" : $result = "Payment Server System Error"; goto addError; break;
case "8" : $result = "Transaction Type Not Supported"; goto addError; break;
case "9" : $result = "Bank declined transaction (Do not contact Bank)"; goto addError; break;
case "A" : $result = "Transaction Aborted"; goto addError; break;
case "C" : $result = "Transaction Cancelled"; goto addError; break;
case "D" : $result = "Deferred transaction has been received and is awaiting processing"; goto addError; break;
case "F" : $result = "3D Secure Authentication failed"; goto addError; break;
case "I" : $result = "Card Security Code verification failed"; goto addError; break;
case "L" : $result = "Shopping Transaction Locked (Please try the transaction again later)"; goto addError; break;
case "N" : $result = "Cardholder is not enrolled in Authentication scheme"; goto addError; break;
case "P" : $result = "Transaction has been received by the Payment Adaptor and is being processed"; goto addError; break;
case "R" : $result = "Transaction was not processed - Reached limit of retry attempts allowed"; goto addError; break;
case "S" : $result = "Duplicate SessionID (OrderInfo)"; goto addError; break;
case "T" : $result = "Address Verification Failed"; goto addError; break;
default: $result = "An unknown error has occurred."; goto addError;
}
continue;
addError:
$form->getElement('ccNumber')->addError($result);
continue;
addCSCError:
$form->getElement('securityNumber')->addError($result);
continue;
}
@ornicar
Copy link

ornicar commented Aug 10, 2011

ah, payment processing. They are the curse (or one of them) of web developers

@merk
Copy link
Author

merk commented Aug 10, 2011

Yeah, unfortunately this system is not a candidate for refactoring either. The whole payment module is riddled with issues. :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment