Welcome Guest, Not a member yet? Register   Sign In
Send XML data to processor. XML-RPC?
#1

[eluser]Travis O[/eluser]
I have this credit card processor, MyVirtualMerchant, and I need to send xml data to a processor URL they provide. I've read through their user guide and the XML-RPC material in the CI user guide and unfortunately, I just don't understand.

MyVirtualMerchant gives me this address
Code:
https://www.myvirtualmerchant.com/VirtualMerchant/processxml.do
to work with. I need to send this data
Code:
<txn>
        <ssl_merchant_ID>11111</ssl_merchant_ID>
        <ssl_user_id>WEBSITE</ssl_user_id>
        <ssl_pin>11111</ssl_pin>
        <ssl_transaction_type>ccsale</ssl_transaction_type>
        <ssl_card_number>1111111111111</ssl_card_number>
        <ssl_exp_date>11111</ssl_exp_date>
        <ssl_amount>1.00</ssl_amount>
        <ssl_salestax>0.00</ssl_salestax>
        <ssl_cvv2cvc2_indicator>1</ssl_cvv2cvc2_indicator>
        <ssl_cvv2cvc2>111</ssl_cvv2cvc2>
        <ssl_invoice_number>TEST XML</ssl_invoice_number>
        <ssl_customer_code>1111</ssl_customer_code>
        <ssl_first_name>User</ssl_first_name>
        <ssl_last_name>Name</ssl_last_name>
        <ssl_avs_address>1234 main st.</ssl_avs_address>
        <ssl_address2>apt b</ssl_address2>
        <ssl_city>any town</ssl_city>
        <ssl_state>ST</ssl_state>
        <ssl_avs_zip>55555</ssl_avs_zip>
        <ssl_phone>555-555-5555</ssl_phone>
        <ssl_email>[email protected]</ssl_email>
    </txn>

I tried using the XML-RPC class in CI, but I can't get it to work. I think I am sending the XML data in the wrong format.

MyVirtualMerchant provides me with this example
Code:
…/VirtualMerchant/processxml.do?xmldata=<txn><ssl_merchant_ID>123456</ssl_merchant_ID><ssl_user_id>123456</ssl_user_id><ssl_pin>V6NJ3A</ssl_pin><ssl_transaction_type>ccsale</ssl_transaction_type><ssl_card_number>1111111111111111</ssl_card_number><ssl_exp_date>1210</ssl_exp_date><ssl_amount>2.34</ssl_amount><ssl_salestax>0.00</ssl_salestax><ssl_cvv2cvc2_indicator>1</ssl_cvv2cvc2_indicator><ssl_cvv2cvc2>321</ssl_cvv2cvc2><ssl_invoice_number>1234</ssl_invoice_number><ssl_customer_code>1111</ssl_customer_code><ssl_first_name>customer</ssl_first_name><ssl_last_name>name</ssl_last_name><ssl_avs_address>1234 main st.</ssl_avs_address><ssl_address2>apt b</ssl_address2><ssl_city>any town</ssl_city><ssl_state>ST</ssl_state><ssl_avs_zip>55555</ssl_avs_zip><ssl_phone>555-555-5555</ssl_phone><ssl_email>[email protected]</ssl_email></txn>

Any help would be appreciated.
#2

[eluser]BrianDHall[/eluser]
I programmed a very similar payment module for a recent project.

Here is how I handled it:

Code:
$xml = $this->load->view('gateway_xml_form.php', $buyerdata, true);

        $url = 'https://urltopostto.com/process.cgi';
        $rawresponce = $this->curl->simple_post($url, array('xxxRequestMode' => 'X', 'xxxRequestData' => $xml), array(CURLOPT_FORBID_REUSE => TRUE, CURLOPT_FRESH_CONNECT => TRUE) );

        $return['rawresponce'] = $rawresponce;
        $xmlresponce = new SimpleXMLElement($rawresponce);

The view I'm loading is just like what you posted, put into a file with variables for all the stuff I want to change like billing name, etc. Cheating? Yes. Is it so much easier and faster than messing with generating valid XML? Oh yes.

Note that I am using the CURL library for CodeIgniter, which works great. I use simplexml because it is really easy to parse the XML response and get what I want.

So I just load up a variable with my purchase data, pass it to the view (which is just an XML template), and toss it over to CURL to post it to the gateway and get the response.

It works so great, I highly recommend it.
#3

[eluser]Travis O[/eluser]
Thank you for your reply. I've never used cURL (mostly because it was intimidating), but after looking into the CI cURL library, it seems that this is pretty easy to do. I will definitely give your method a try and report back. :-)
#4

[eluser]BrianDHall[/eluser]
I felt exactly the same way about curl and spent a day trying to figure it out before finding the CI library. Then boom, done in a few hours having never used curl before. The CI library really makes it much easier to make good use of it.

Oh, incase it wasn't obvious I loaded the 'rawresponce' into a variable to save into the database incase something ever went wrong and I needed to go back and see what happened. Never had to use it yet Smile

Then you can do something like $xmlresponce->page to access the 'page' element of the returned XML ('page' is what my processor calls their approval or disapproval code).

I spent more time trying to get past how hard I thought it was going to be than actually doing it.




Theme © iAndrew 2016 - Forum software by © MyBB