SimpleXMLElement Object
(
[transaction] => SimpleXMLElement Object
(
[status] => Success
[reasoncode] => N/A
[transactionid] => J7DXXXX8U0
[description] => The credit card has been accepted.
)
)
Array
(
[transaction] => SimpleXMLElement Object
(
[status] => Success
[reasoncode] => N/A
[transactionid] => J7DXXXX8U0
[description] => The credit card has been accepted.
)
)
// Success response sample
/* $response = "<?xml version='1.0' encoding='utf-8'?>
<string xmlns='http://wsclientapi.everyware.com/'>
<transaction>
<status>Success</status>
<reasoncode>N/A</reasoncode>
<transactionid>J7DXXXX8U0</transactionid>
<description>The credit card has been accepted.</description>
</transaction>
</string>"; */
//Failed response sample
$response = "<?xml version='1.0' encoding='utf-8'?>
<string xmlns='http://wsclientapi.everyware.com/'>
<transaction>
<status>Failed</status>
<reasoncode>409</reasoncode>
<transactionid>N/A</transactionid>
<description>The transaction has been declined.</description>
</transaction>
</string>";
$xml = simplexml_load_string($response);
//Used to print out the xml for testing
?><pre><?php print_r($xml); ?></pre><?php
$array = (array)$xml;
//Used to print out the array for testing
?><pre><?php print_r($array); ?></pre><?php
if ($xml === false) {
$data = array('message' => $response, 'html' => $response);
} else {
// $data = array('message' => $array[0], 'html' => $array[0]);
if ($array->status == "Success") {
// Transaction approved! Do your logic here.
$curdate = new DateTime('NOW', new DateTimeZone('America/Los_Angeles'));
if( isset($array->transactionid) ){
$data = array( 'message' => 'Success', 'html' => 'Success', 'transid' => $array->transactionid, 'auth' => $array->transactionid, 'date' => $curdate->format('m/d/Y h:i:s a') );
} else{
$data = array( 'message' => 'Success', 'html' => 'Success', 'transid' => $array->transactionid, 'date' => $curdate->format('m/d/Y h:i:s a') );
}
} else {
$curdate = new DateTime('NOW', new DateTimeZone('America/Los_Angeles'));
if( isset($response->transactionid) ){
$data = array( 'message' => $array->description, 'html' => 'Failed', 'date' => $curdate->format('m/d/Y h:i:s a'), 'transid' => $array->transactionid );
} else{
$data = array( 'message' => $array->description, 'html' => 'Failed, Not seeing Success or TransactionID', 'date' => $curdate->format('m/d/Y h:i:s a') );
}
}
}
/* if ($xml === false) {
$data = array('message' => $response, 'html' => $response);
file_put_contents("whereDataFalse.txt", $data);
} else {
// $data = array('message' => $array[0], 'html' => $array[0]);
if ($xml->transaction->status == "Success") {
// Transaction approved! Do your logic here.
$curdate = new DateTime('NOW', new DateTimeZone('America/Los_Angeles'));
if( isset($xml->transaction->transactionid) ){
$data = array( 'message' => 'Success', 'html' => 'Success', 'transid' => $xml->transaction->transactionid, 'auth' => $xml->transaction->transactionid, 'date' => $curdate->format('m/d/Y h:i:s a') );
} else{
$data = array( 'message' => 'Success', 'html' => 'Success', 'transid' => $xml->transaction->transactionid, 'date' => $curdate->format('m/d/Y h:i:s a') );
}
} else {
$curdate = new DateTime('NOW', new DateTimeZone('America/Los_Angeles'));
if( isset($xml->transaction->transactionid) ){
$data = array( 'message' => $xml->transaction->description, 'html' => 'Failed', 'date' => $curdate->format('m/d/Y h:i:s a'), 'transid' => $xml->transaction->transactionid );
} else{
$data = array( 'message' => $xml->transaction->description, 'html' => 'Failed, Not seeing Success or TransactionID', 'date' => $curdate->format('m/d/Y h:i:s a') );
}
}
} */
echo json_encode($data);
die();
}
var response = jQuery.parseJSON(data);
// var response = data;
console.log(response);
if( response.message == 'Success' && response.html != 'Failed' && response.html != '' ) {
jQuery('#lead_item_full_trans').hide();
if( response.transid ){
jQuery('#sales_form input#trans_id').val(response.transid);
}
if( response.date ){
jQuery('#sales_form input#trans_date').val(response.date);
}
if( response.auth ){
jQuery('#sales_form input[name=v_auth]').val(response.auth);
}
jQuery('#sales_form input#trans_type').val('Charge');
alert('Card has been successfully charged.');
} else {
if( response.transid ){
jQuery('#sales_form input#trans_id').val(response.transid);
}
if( response.message ){
jQuery('#sales_form input#trans_note').val(response.message);
}
if( response.date ){
jQuery('#sales_form input#trans_date').val(response.date);
}
jQuery('#sales_form input#trans_type').val('Error');
alert(response.message);
}
});
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Fellow title is reserved for select members who demonstrate sustained contributions, industry leadership, and outstanding performance. We will announce the experts being inducted into the Experts Exchange Fellowship during the annual Expert Awards, but unlike other awards, Fellow is a lifelong status. This title may not be given every year if there are no obvious candidates.
The Most Valuable Expert award recognizes technology experts who passionately share their knowledge with the community, demonstrate the core values of this platform, and go the extra mile in all aspects of their contributions. This award is based off of nominations by EE users and experts. Multiple MVEs may be awarded each year.