Replies: 0
I am working on a payment plugin for woocommerce, but the $response
when I use a test card works correctly and gives me the correct parameters, but when I use a real card theresponse
returns me HTML code.
My function to make the payment is:
public function process_payment( $order_id ) {
global $woocommerce;
// Get this Order's information so that we know
// who to charge and how much
$customer_order = new WC_Order( $order_id );
$environment_url = 'https://credomatic.compassmerchantsolutions.com/api/transact.php';
$time = time();
$key_id = $this->key_id;
$orderid = str_replace( "#", "", $customer_order->get_order_number() );
$hash = md5($orderid."|".$customer_order->order_total."|".$time."|".$this->api_key);
// This is where the fun stuff begins
$payload = array(
"key_id" => $key_id,
"hash" => $hash,
"time" => $time,
"amount" => $customer_order->order_total,
"ccnumber" => str_replace( array(' ', '-' ), '', $_POST['bac_payment-card-number'] ),
"ccexp" => str_replace( array( '/', ' '), '', $_POST['bac_payment-card-expiry'] ),
"orderid" => $orderid,
"cvv" => ( isset( $_POST['bac_payment-card-cvc'] ) ) ? $_POST['bac_payment-card-cvc'] : '',
"type" => "auth",
"redirect" => "https://testsite.com/paymentvalidator.php"
);
// Send this payload to Authorize.net for processing
$response = wp_remote_post( $environment_url, array(
'method' => 'POST',
'body' => http_build_query( $payload ),
'timeout' => 90,
'sslverify' => false,
) );
if ( is_wp_error( $response ) )
throw new Exception( __( 'We are currently experiencing problems trying to connect to this payment gateway. Sorry for the inconvenience.'.$payload, 'bac-payment' ) );
if ( empty( $response['body'] ) )
throw new Exception( __( 'BAC\'s Response was empty.', 'bac-payment' ) );
// Retrieve the body's resopnse if no errors found
$response_body = wp_remote_retrieve_body( $response );
With test card: $ response
returns:
Array
(
[headers] => Requests_Utility_CaseInsensitiveDictionary Object
(
[data:protected] => Array
(
[date] => Wed, 11 Dec 2019 20:31:13 GMT
[server] => Apache
[x-powered-by] => PHP/5.6.40
[strict-transport-security] => max-age=31536000; includeSubDomains
[content-length] => 293
[content-type] => text/html; charset=UTF-8
)
)
[body] => https://testsite.com/paymentvalidator.php?response=1&responsetext=SUCCESS&authcode=123456&transactionid=5062787706&avsresponse=&cvvresponse=N&orderid=9142&type=sale&response_code=100&username=13783068&time=1576096273&amount=11.00&hash=a5d8276d11041ead7ec3f390d1df6707
[response] => Array
(
[code] => 200
[message] => OK
)
.
.
.
[status_code] => 200
[protocol_version] => 1.1
[success] => 1
[redirects] => 1
[url] => https://testsite.com/paymentvalidator.php?response=1&responsetext=SUCCESS&authcode=123456&transactionid=5062787706&avsresponse=&cvvresponse=N&orderid=9142&type=sale&response_code=100&username=13783068&time=1576096273&amount=11.00&hash=a5d8276d11041ead7ec3f390d1df6707
[history] => Array
.
.
.
But with a real card: $response returns:
Array
(
[headers] => Requests_Utility_CaseInsensitiveDictionary Object
(
[data:protected] => Array
(
[date] => Fri, 13 Dec 2019 16:38:02 GMT
[server] => Apache
[x-gw-session-id] => 8d4bbf45eabe4a5edac4aeba06cb8753
[content-length] => 1175
[content-type] => text/html; charset=UTF-8
)
)
[body] => <HTML><HEAD><SCRIPT Language="Javascript">function onLoadHandler(){document.frmLaunchACS.submit();}</SCRIPT></HEAD><body onLoad="onLoadHandler();"><br><br><br><br><center><FORM name="frmLaunchACS" method="Post" action="https://0eaf.cardinalcommerce.com/EAFService/jsp/v1/redirect"><input type=hidden name="PaReq" value="P.02c473b41ce5b88887fc8936601d76171ef6ef34e10d1f0472e21e0c4a725c3d10b4d051fb***"><input type=hidden name="TermUrl" value="https://credomatic.compassmerchantsolutions.com/api/transact.php?username=user11&APISID=8d4bbf45eabe4a5edac8753¢inel_transaction_id=mURX2oj4BDd977pRFP30&cardholder_auth_key=745701d7f2f1b3ffedddc72d16c1x"><input type=hidden name="MD" value="none"><noscript> <br><br> <center> <font color="red"> <h1>Processing your Payer Authentication Transaction</h1> <h2>JavaScript is currently disabled or is not supported by your browser.<br></h2> <h3>Please click Submit to continue the processing of your transaction.</h3> </font> <input type="submit" value="Submit"> </center> </noscript> </FORM></center></BODY></HTML>
[response] => Array
(
[code] => 200
[message] => OK
)
.
.
.
[status_code] => 200
[protocol_version] => 1.1
[success] => 1
[redirects] => 0
[url] => https://credomatic.compassmerchantsolutions.com/api/transact.php
[history] => Array
.
.
.
What could be the reason for the error in returning the parameters?
-
This topic was modified 53 minutes ago by cyberespia.