hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : PHP help needed[Urgent]
Reply

Forum Jump

PHP help needed[Urgent]

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 06-09-2008, 01:00 AM
Passwordz Passwordz is offline
Disabled
 
Join Date: Mar 2008
Posts: 102
*

PHP help needed[Urgent]


I want some help on PHP coding for a payment gateway !

Information


My Payment gateway provider returns a value 0 , if the payment was successful, and other values ranging from 1 to 9 , in case of error.

Now, problem, is :-

I have passed the status value (which i get from payment gateway after payment) to $status , and have the following below code for it...



Code:
if ($status != 0) {
$error_message = "Transaction Failed. Code: " . $status; }


Now it works fine and echo's this ,

" Transaction Failed. Code: THE STATUS CODE HERE"



But what i want is, it should echo the status description message and not the status code.


The status messages are given below ..


Code:
function getResponseDescription($status) {

    switch ($status) {
        case "0" : $result = "Transaction Successful"; break;
        case "?" : $result = "Transaction status is unknown"; break;
        case "1" : $result = "Unknown Error"; break;
        case "2" : $result = "Bank Declined Transaction"; break;
        case "3" : $result = "No Reply from Bank"; break;
        case "4" : $result = "Expired Card"; break;
        case "5" : $result = "Insufficient funds"; break;
        case "6" : $result = "Error Communicating with Bank"; break;
        case "7" : $result = "Payment Server System Error"; break;
        case "8" : $result = "Transaction Type Not Supported"; break;
        case "9" : $result = "Bank declined transaction (Do not contact Bank)"; break;
        case "A" : $result = "Transaction Aborted"; break;
        case "C" : $result = "Transaction Cancelled"; break;
        case "D" : $result = "Deferred transaction has been received and is awaiting processing"; break;
        case "F" : $result = "3D Secure Authentication failed"; break;
        case "I" : $result = "Card Security Code verification failed"; break;
        case "L" : $result = "Shopping Transaction Locked (Please try the transaction again later)"; break;
        case "N" : $result = "Cardholder is not enrolled in Authentication scheme"; break;
        case "P" : $result = "Transaction has been received by the Payment Adaptor and is being processed"; break;
        case "R" : $result = "Transaction was not processed - Reached limit of retry attempts allowed"; break;
        case "S" : $result = "Duplicate SessionID (OrderInfo)"; break;
        case "T" : $result = "Address Verification Failed"; break;
        case "U" : $result = "Card Security Code Failed"; break;
        case "V" : $result = "Address Verification and Card Security Code Failed"; break;
        default  : $result = "Unable to be determined"; 
    }
    return $result;
}


I have made above function to get STATUS Message, but how should i echo them ?



I mean,


what shall i write in

Code:
if ($status != 0) {
$error_message = "Transaction Failed. Code: " . $status; }

so $error_message = "gives output of status response description"


Thank You



Sponsored Links
  #2  
Old 06-09-2008, 01:23 AM
zinga zinga is offline
Junior Guru Wannabe
 
Join Date: Apr 2008
Posts: 36
Something like this I guess:
PHP Code:
if ($status != 0) {
$error_message "Transaction Failed (Code $status).  Reason: ".getResponseDescription($status);} 

  #3  
Old 06-09-2008, 01:37 AM
Passwordz Passwordz is offline
Disabled
 
Join Date: Mar 2008
Posts: 102
No, Zinga

It worked for me, for any future help, this is the code :

$error_message = "Transaction Failed. Code: " . getResponseDescription($status);


[/ThreadClosed]

Sponsored Links
  #4  
Old 06-09-2008, 02:32 AM
prickett233 prickett233 is offline
WHT Addict
 
Join Date: Jan 2007
Posts: 158
lol, asking for help then giving Zinga an inferior lesson.

Reply

Related posts from TheWhir.com
Title Type Date Posted
Hackers Gain Access to Namecheap Accounts Using Login Data Stolen from Third-Party Sites Web Hosting News 2014-09-02 11:36:37
Stanford Researchers Increase Cost Effectiveness of Cloud and Contribute to Cleantech Web Hosting News 2014-05-01 08:31:18
GoDaddy Acquires Invoicing Tool Ronin Web Hosting News 2013-10-02 12:22:52
InfoRelay Online System Launches Cloud Hosting Platform SnapScale v2.1 Web Hosting News 2013-05-06 11:51:16
Software AG Acquires Cloud PaaS Vendor LongJump Web Hosting News 2013-04-26 12:05:25


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:
WHT Membership
WHT Membership



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?