• Good day all. I am struggling on how to fix this error. I’ve already google this but cannot find any solution:(

    I want to develop custom payment gateway plugin and integrate to an externel API. I am sending request using XML POST in wordpress using wp_remote_post.

    
       public function process_payment( $order_id ) {
       $order = wc_get_order( $order_id );
    
       $url = "https://gateway.wepayez.com/pay/gateway";
       $xml = "<xml>
       <body><![CDATA[Desmark EWallet Using Gcash]]></body>  
       <callback_url><![CDATA[https://www.desmark.com.ph]]></callback_url>
       <device_info><![CDATA[12345678]]></device_info>  
       <mch_create_ip><![CDATA[127.0.0.1]]></mch_create_ip>  
       <mch_id><![CDATA[150560000001]]></mch_id>  
       <nonce_str><![CDATA[2209193392]]></nonce_str>  
       <notify_url><![CDATA[https.www.desmark.com.ph]]></notify_url>  
       <out_trade_no><![CDATA[kenttest127500000591]]></out_trade_no>  
       <service><![CDATA[unified.checkout.prepay]]></service>           
       <sign><![CDATA[CF4CB88A05435B7311F21DDCA901E5720A6EE6283C503906819A962758824BC5]]></sign>  
       <sign_type><![CDATA[SHA256]]></sign_type>
       <total_fee><![CDATA[200]]></total_fee> 
       </xml>";
    
       $response_json = wp_remote_post( 
    $url, 
    array(
        'method' => 'POST',
        'timeout' => 45,
        'redirection' => 5,
        'httpversion' => '1.0',
        'headers' => array("Content-type" => "text/xml"),
        'body' => array('xml' => $xml),
        'sslverify' => false
    )
        );  
        $response = json_encode($response_json);
        echo $response;
    

    and this is the response i’ve got. hope someone can help me how to send request using the sample xml data above. you’re help means a lot to me.

    
        {"headers":{},"body":"<xml><version><![CDATA[2.0]]><\/version>\n<charset><![CDATA[UTF-8]]><\/charset>\n<status><![CDATA[400]]><\/status>\n<message><![CDATA[Parse xml error,please use UTF-8 encoded]]><\/message>\n<\/xml>","response":{"code":200,"message":"OK"},"cookies":[],"filename":null,"http_response":{"data":null,"headers":null,"status":null}}
    

    —This is the example response that I want to get—

    <xml><charset><![CDATA[UTF-8]]></charset>
    <code_url><![CDATA[https://app.wepayez.com/spay/webpay?token=d852522b84fd17a928bfd4f70be4101e37713822528bd39c52b972664542e248]]></code_url>
    <mch_id><![CDATA[150560000001]]></mch_id>
    <nonce_str><![CDATA[2209193392]]></nonce_str>
    <result_code><![CDATA[0]]></result_code>
    <sign><![CDATA[D76B70E35686B1C72522A7C053F3820F1F3221D93475DD8E1B2783F9526E1196]]></sign>
    <sign_type><![CDATA[SHA256]]></sign_type>
    <status><![CDATA[0]]></status>
    <uuid><![CDATA[0256e996cec1a37de0fb8c5caba01f810]]></uuid>
    <version><![CDATA[2.0]]></version>
    </xml>
    • This topic was modified 3 years, 10 months ago by Choians18.
    • This topic was modified 3 years, 10 months ago by Yui. Reason: formatting

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Dion

    (@diondesigns)

    THe message is self-explanatory — your XML encoding is incorrect. You may want to change the <xml> tag to <xml encoding="UTF-8"> and get rid of the <charset> tag. If that doesn’t work, then I suggest you ask the folks at wepayez.com what they require in their XML.

    Thread Starter Choians18

    (@arllanz18)

    Thanks for the reply sir. I will update you if it works. Thanks

    Thread Starter Choians18

    (@arllanz18)

    @diondesigns hi sir. Thank you very much! My problem is solved. GOD bless you.
    I’ve changed the tag and body in wp_remote_post.

    $url = "https://gateway.wepayez.com/pay/gateway";
    
    $xml = "<xml version=\"1.0\" encoding=\"utf-8\">
    <body><![CDATA[Desmark EWallet Using Gcash]]></body>  
    <callback_url><![CDATA[https://www.desmark.com.ph]]></callback_url>
    <device_info><![CDATA[12345678]]></device_info>  
    <mch_create_ip><![CDATA[127.0.0.1]]></mch_create_ip>  
    <mch_id><![CDATA[150560000001]]></mch_id>  
    <nonce_str><![CDATA[2209193392]]></nonce_str>  
    <notify_url><![CDATA[https.www.desmark.com.ph]]></notify_url>  
    <out_trade_no><![CDATA[kenttest127500000591]]></out_trade_no>  
    <service><![CDATA[unified.checkout.prepay]]></service>           
    <sign><![CDATA[CF4CB88A05435B7311F21DDCA901E5720A6EE6283C503906819A962758824BC5]]></sign>  
    <sign_type><![CDATA[SHA256]]></sign_type>
    <total_fee><![CDATA[200]]></total_fee> 
    </xml>";
    
    $response_json = wp_remote_post( 
        $url, 
        array(
            'method' => 'POST',
            'timeout' => 45,
            'redirection' => 5,
            'httpversion' => '1.0',
    		'headers' => array("Content-type" => "application/xml"),
            'body' => $xml,
            'sslverify' => false
        )
    );
Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘How to send XML POST request in wordpress wp_remote_post’ is closed to new replies.