Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-22-2011, 07:36 AM   PM User | #1
kaidine
New to the CF scene

 
Join Date: Nov 2011
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
kaidine is an unknown quantity at this point
PHP performing on XML response

I send off this:

PHP Code:
<?php
    $data 
"<egateway>
            <eCardExpiryMonth>01</eCardExpiryMonth>
            <eCardExpiryYear>04</eCardExpiryYear>
            <eCardHoldersName>Joe Bloke</eCardHoldersName>
            <eCardNumber>4444333322221111</eCardNumber>
            <eCVN>123</eCVN>
            <eTotalAmount>100</eTotalAmount>
        </egateway>
        "
;
    
$ch curl_init();
    
curl_setopt($chCURLOPT_POSTFIELDS$edata);
    
curl_setopt($chCURLOPT_URL"https://www.example.com/gateway_cvn/testpage.asp");
    
curl_exec($ch);
    
curl_close($ch);
?>
In return, I get the following XML:

Code:
<eResponse>
	<eTrxnStatus>True</eTrxnStatus>
	<eTrxnNumber>20219</eTrxnNumber>
	<eAuthCode>123456</eAuthCode>
	<eReturnAmount>100</eReturnAmount>
	<eTrxnError>00,Transaction Approved(Test CVN Gateway)</eTrxnError>
</eResponse>
Is there a way to make it so this does not show, and instead I can make PHP do something like:

if (eTrxnStatus == True) {// do stuff};

?
kaidine is offline   Reply With Quote
Old 11-22-2011, 10:53 AM   PM User | #2
kaidine
New to the CF scene

 
Join Date: Nov 2011
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
kaidine is an unknown quantity at this point
I'm using:

PHP Code:
$response simplexml_load_string(curl_exec($ch));
    if (
$response -> eTrxnStatus == 'True') {
        echo 
"True 1111111111111.";
    } 
... but getting these errors:
Quote:
PHP Warning:
simplexml_load_string(): Entity: line 1: parser error : Start tag expected, '<' not found
simplexml_load_string(): 1
simplexml_load_string(): ^

PHP Notice: Trying to get property of non-object
The response code I am getting back in XML is:
Code:
<eResponse><eTrxnStatus>True</eTrxnStatus><eTrxnNumber>11673</eTrxnNumber><eTrxnReference/><eReturnAmount>100</eReturnAmount><eTrxnError>00,Transaction Approved(Test CVN Gateway)</eTrxnError></eResponse>
What could be causing this? I can't make any sense of it at all!
kaidine is offline   Reply With Quote
Old 11-22-2011, 11:07 AM   PM User | #3
kaidine
New to the CF scene

 
Join Date: Nov 2011
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
kaidine is an unknown quantity at this point
I solved the problem with:

PHP Code:
curl_setopt($chCURLOPT_RETURNTRANSFER1); 
kaidine is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:55 PM.


Advertisement
Log in to turn off these ads.