wp_remote_post and form post
Actually it is more general question but now i am trying to use it on wordpress site so I preferred to post it here.
I am trying to understand the difference between remote post and form post.
When I query a string and post it to remote server, I get the result as string and with "print $response" see it on browser console. But I want it to be displayed as html on browser. Am I expecting wrong thing or could i do such thing?
Basically I want to see raw response as html.
EDIT
In case of being more expressive.. I am trying to write credit card payment gateway inside woocommerce
Inside process_payment function which is called at the end of customer order, I am posting all info to bank server like below:
public function process_payment( $order_id ) {
global $woocommerce;
....
...
$okUrl = "http://localhost/xxx/wc-api/paymentpos/";
$failUrl = "http://localhost/xxx/wc-api/paymentpos/";
$payload = array(.....);
$response = wp_remote_post( $environment_url, array(
'method' = 'POST',
'body' = http_build_query( $payload ),
'timeout' = 45,
'sslverify' = false,
) );
$respbody = wp_remote_retrieve_body($response);
print $respbody;
}
After that, bank server should reply to payment_callback() which is like
public function payment_callback(){
global $woocommerce;
wc_add_notice( 'OK', 'success' );
.....
exit();
}
I am getting $respbody as below on console.
!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
html
head
META http-equiv="Content-Type" content="text/html; charset=UTF-8"
script type="text/javascript" language="javascript"
function moveWindow() {
document.returnform.submit();
}
/script
/head
body onLoad="javascript:moveWindow()"
form action="http://localhost/xxx/wc-api/paymentpos/" method="post" name="returnform"
input type="hidden" name="EXTRA.ERTELEMESABITTARIH" value="20121123"
....
input type="hidden" name="okUrl" value="http://localhost/xxx/wc-api/paymentpos/"
...
input type="hidden" name="mdStatus" value="2"
input type="hidden" name="HASH" value="QZVV9Zfv4tlzi36WJNbLVlbuWY8="
input type="hidden" name="rnd" value="GSZV87rHM+Ol5WDiMbtC"
input type="hidden" name="HASHPARAMS" value="clientid:oid:AuthCode:ProcReturnCode:Response:mdStatus:cavv:eci:md:rnd:"
input type="hidden" name="HASHPARAMSVAL" value="100200000160451Declined2499850:FE7D7E1062435636DEA77FD3F96CE40C68334FAFE6458F2FC530F26814B29935:4043:##100200000GSZV87rHM+Ol5WDiMbtC"
...
!-- To support javascript unaware/disabled browsers --
noscript
centerbr
Please Click to continue.br
input type="submit" name="submit" value="Submit" id="btnSbmt"/center
/noscript
/form
/body
/html
{"result":"failure","messages":"","refresh":"false","reload":"false"}
This response should trigger payment_callback() function. Manually I could trigger payment_callback() like http://localhost/xxx/wc-api/paymentpos/. But this response could not trigger. I am suspicious about I could handle wp_remote_post response correctly.
Topic wp-remote-post forms query-posts Wordpress
Category Web