Пример #1
0
$shippingState = isset($shippingState) ? $shippingState : '-';
//组装参数
$data = array('mode' => Configuration::get('GOFPAY_MODE'), 'websiteid' => Configuration::get('GOFPAY_WEBSITE_ID'), 'orderid' => $orderNo, 'domain' => $_SERVER['HTTP_HOST'], 'email' => $email, 'ipaddress' => get_client_ip(), 'currency' => $orderCurrency, 'amount' => $orderAmount, 'discount' => $discount, 'tax' => '0.00', 'freight' => $shipFee, 'billingfirstname' => $billingFirstName, 'billinglastname' => $billingLastName, 'billingaddress1' => $billingAddress1, 'billingaddress2' => $billingAddress2, 'billingcity' => $billingCity, 'billingcountry' => $billingCountry, 'billingstate' => $billingState, 'billingzipcode' => $billingZipcode, 'billingtelephone' => $billingTelephone, 'shippingfirstname' => $shippingFirstName, 'shippinglastname' => $shippingLastName, 'shippingaddress1' => $shippingAddress1, 'shippingaddress2' => $shippingAddress2, 'shippingcity' => $shippingCity, 'shippingcountry' => $shippingCountry, 'shippingstate' => $shippingState, 'shippingzipcode' => $shippingZipcode, 'shippingtelephone' => $shippingTelephone, 'creditcardname' => $billingFirstName . ' ' . $billingLastName, 'creditcardnumber' => $_REQUEST["gofpay_creditcard_number"], 'creditcardcsc2' => $_REQUEST["gofpay_security_code"], 'creditcardexpire' => $_REQUEST["gofpay_expire_year"] . $_REQUEST["gofpay_expire_month"], 'signature' => md5(Configuration::get('GOFPAY_WEBSITE_ID') . $orderNo . $email . $orderCurrency . $orderAmount . '0.00' . '0.00' . $shipFee . Configuration::get('GOFPAY_SECRET_KEY')));
if (Configuration::get('GOFPAY_GATEWAY_COUPON_STATUS')) {
    $data['coupon'] = isset($_REQUEST["gofpay_coupon_code"]) ? $_REQUEST["gofpay_coupon_code"] : '';
}
// 商品信息
$arr = $cart->getProducts();
for ($i = 0; $i < sizeof($arr); $i++) {
    $data['productsku' . ($i + 1)] = $arr[$i]["id_product"];
    $data['productname' . ($i + 1)] = $arr[$i]['name'];
    $data['productprice' . ($i + 1)] = number_format($arr[$i]["price"], 2, '.', '');
    $data['productquantity' . ($i + 1)] = $arr[$i]["cart_quantity"];
}
//发送交易
$gqresponse = execPayment($data, $useSSL);
//解析返回信息
$transactionid = $gqresponse['transactionid'];
$orderid = $gqresponse['orderid'];
$status = $gqresponse['status'];
$reason = $gqresponse['reason'];
$extradata = $gqresponse['extradata'];
$url = $gqresponse['url'];
$currency = $gqresponse['currency'];
$amount = $gqresponse['amount'];
$originalcurrency = $gqresponse['originalcurrency'];
$originalamount = $gqresponse['originalamount'];
$signature = $gqresponse['signature'];
if ($status == 'Error') {
    $payResult = '6';
    switch ($reason) {
Пример #2
0
 }
 if (!isset($cart)) {
     if (!isset($cookie->id_cart) || !isset($cookie->id_user)) {
         Paylog::msg(0, "102", "检测不到id_cart或者id_user");
         die(json_encode(array("isError" => "YES", "msg" => "Payment failed!, Response Code:102")));
     }
     $cart = new Cart($cookie->id_cart);
 }
 $additionInfo = array('CardPAN' => $_POST['neworder_cardNo'], 'CVV2' => $_POST['neworder_cardSecurityCode'], 'ExpirationMonth' => $_POST['neworder_cardExpireMonth'], 'ExpirationYear' => $_POST['neworder_cardExpireYear']);
 $paymentid = (int) $_POST['neworder_paymentid'];
 $neworder = new neworder();
 if ($cart->id_user == 0 or $cart->id_address == 0) {
     Paylog::msg($cart->id, "103", "用户ID为0或者地址ID为0或者支付模块未启用");
     die(json_encode(array("isError" => "YES", "msg" => "Payment failed!, Response Code:103")));
 }
 $payResultJson = execPayment($cart, $additionInfo);
 if (!$payResultJson) {
     //支付过程提交请求失败.
     Paylog::msg($cart->id, "201", "支付请求没有连接到服务器");
     die(json_encode(array("isError" => "YES", "msg" => "Payment failed!, Response Code:201")));
 }
 $status = $payResultJson['status'];
 $siteOrderNo = $payResultJson["orderNo"];
 $amount = $payResultJson["amount"];
 $currCode = $payResultJson["orderCurrency"];
 $errorMessage = $payResultJson["msg"];
 $messages = $neworder->getMessages();
 $orderNoLabel = $messages["lblOrderNumber"];
 $amountLabel = $messages["lblpayment"];
 $isPendingPayment = $payResultJson["isPendingPayment"];
 if ($status == "0000") {