-1

I am using usaEpay for my mobile app. I was using my friend's server and there was no problem.

Then I rented a server for my own. switched the backend to the new server. I am using the exact same code. I implemented rapid SSL to my site. But I cannot make a payment.

This is the error;

Error reading from card processing gateway.
Unsupported SSL protocol version

My php api is the same as this; https://github.com/usaepay/usaepay-php/blob/master/usaepay.php

this is my payOrder.php class

require('connector.php');
include ('phpseclib/Crypt/RSA.php');
include ('usaepay/usaepay.php');


$request = json_decode($HTTP_RAW_POST_DATA, true);
$token = $request['token'];
$orderid = $request['orderid'];
$ccInfo = base64_decode($request['ccinfo']);
$address = $request['address']; 

if(strlen($out_plain) >= 25) {

    $query = "SELECT * FROM xxxx_order WHERE order_id = $orderid";
    $result = mysql_query($query);
    $order = mysql_fetch_assoc($result);
    $total = $order['order_total'];

    $creditcard = explode("||", $out_plain);
    $ccnumber = $creditcard[0];
    $cvvnumber = $creditcard[1];
    $cctype = $creditcard[2];
    $ccmonth = $creditcard[3];
    $ccyear = $creditcard[4];
    $ccdate = $ccmonth.$ccyear;
    $ccname = $creditcard[5];
    $address = explode("||", $address);
    $street = $address[0];
    $city = $address[1];
    $state = $address[2];
    $zip = $address[3];
    $name = $address[4];
    $umcommand = "cc:sale" ;
    $umkey = "mykey" ;
    $pin = "mypin";

    $tran=new umTransaction;
    $tran->key = "mytrkey";
    $tran->pin = "mypin";
    $tran->usesandbox = false;
    $tran->testmode = 0;
    $tran->command = "cc:sale";
    $tran->card = $ccnumber;
    $tran->exp = $ccdate;
    $tran->amount = $total;
    $tran->invoice = $orderid;
    $tran->cardholder = $ccname;
    $tran->street = $street;
    $tran->zip = $zip;
    $tran->description = "App sale";
    $tran->cvv2 = $cvvnumber;

    flush();

    if($tran->Process()) {
        $auth = $tran->authcode;
        $refnum = $tran->refnum;
        $response = "$auth---$refnum";
        $query = "UPDATE `mydb` SET `order_status`= 2, UMresponse =                         
        $check = false;
        $count = 0;

        do {
            $check = mysql_query($query);
            $count++;
        } while ($check == false && $count < 50);

        array_push($arr, array("status" => "success", "request" =>           "check", "order_status" => "success"));
    } else {
        $tranresult = $tran->result;
        $tranerror = $tran->error;
        $trancurl = ""; 
        if(@$tran->curlerror) $trancurl = $tran->curlerror;

        $response = "$tranresult---$tranerror---$trancurl";
        $query = "UPDATE `mydb` SET `order_status`= 4, UMresponse = '$response' WHERE order_id = $orderid";

        $check = false;
        $count = 0;

        do {
            $check = mysql_query($query);
            $count++;
        } while ($check == false && $count < 50);

        array_push($arr, array("status" => "success", "request" => "check", "order_status" => "declined"));
    }

    /*
    $hashseed = mktime ();   // mktime returns the current time in seconds since epoch.
    $hashdata = $umcommand . ":" . $pin . ":" . $total . ":" . $orderid . ":" . $hashseed ;

    $hash = md5 ( $hashdata );
    $umhash = "m/$hashseed/$hash/y";

    $fields = array(`enter code here`
        "UMkey"     => urlencode($umkey),
        "UMredir"   => urlencode("myurl"),
        "UMinvoice" => urlencode($orderid),
        "UMamount"  => urlencode($total),
        "UMname"    => urlencode($ccname),
        "UMstreet"  => urlencode($street),
        "city"      => urlencode($city),
        "City"      => urlencode($city),
        "state"     => urlencode($state),
        "State"     => urlencode($state),
        "UMzip"     => urlencode($zip),
        "cardtype"  => urlencode($cctype),
        "UMcard"    => urlencode($ccnumber),
        "UMexpir"   => urlencode($ccdate),
        "UMcommand" => urlencode("cc:sale"),
        "UMhash"    => $umhash,
        "UMechofields" => "yes",
        "OrderRef"  => $orderid
    );

    $fields_string = "";
    foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
    rtrim($fields_string, '&');

    $url = "https://www.usaepay.com/gate.php";
    // $fields = "UMkey=".urlencode($umkey)."&UMredir=".urlencode("myurl**strong text**")."&UMinvoice=$orderid&UMamount=".urlencode($total)."&UMname=".urlencode($ccname)."&UMstreet=".urlencode($street)."&city=".urlencode($city)."&state=".urlencode($state)."&UMzip=".urlencode($zip)."&cardtype=".urlencode($cctype)."&UMcard=".urlencode($ccnumber)."&UMexpir=".urlencode($ccdate)."&UMcommand=".urlencode("cc:sale");

    // array_push($arr, array("url" => $url, "fields" => $fields_string));

    //open connection
    $ch = curl_init();

    //set the url, number of POST vars, POST data
    curl_setopt($ch,CURLOPT_URL, $url);
    curl_setopt($ch,CURLOPT_POST, count($fields));
    curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);

    //execute post
    $result = curl_exec($ch);

    if($result == true) {
        array_push($arr, array("status" => "success", "request" => "send", "msg" => "Payment request sent"));
    }
    else {
        array_push($arr, array("status" => "error", "request" => "send", "msg" => "Failed to connect to the payment system"));
    }

    //close connection
    curl_close($ch);
    */
} else {
    array_push($arr, array("status" => "error", "request" => "send", "msg" => "Decryption failure, please check fields before submission"));
} else {
    array_push($arr, array("status" => "error", "request" => "send", "msg" => "User token not verified"));
}

header('Content-Type: application/json');
echo json_encode($arr);

Any help would be overly appreciated. What is my problem ?

Peyman Mohamadpour
  • 17,954
  • 24
  • 89
  • 100
CanCode
  • 19
  • 1

1 Answers1

0

I think the error message said it clearly that your communication with payment gateway is rejected or refused due to unsupported SSL version, you should check your server setting and compare with your friend's server. BTW, looking at your PHP code, do you know that mysql extension has been deprecated since PHP v5.5.0 and total removed from PHP 7? I'd suggest that you read PHP The right way about the Database part and the php.net documentation.

hcheung
  • 3,377
  • 3
  • 11
  • 23