示例#1
0
文件: card.php 项目: qujian/ydwx
        $card_jsapi_ticket = YDWXHook::do_hook(YDWXHook::GET_HOST_CARD_JSAPI_TICKET, $appid);
    } else {
        $card_jsapi_ticket = YDWXHook::do_hook(YDWXHook::GET_CARD_JSAPI_TICKET);
    }
    $array = array($nonceStr, $card_jsapi_ticket, $time, $shopId, $cardType, $cardId);
    $array = YDWXRequest::ignoreNull($array);
    sort($array);
    $cardSignStr = sha1(join("", $array));
    echo json_encode(ydwx_success(array("shopId" => $shopId, "cardType" => $cardType, "cardId" => $cardId, "nonceStr" => $nonceStr, "time" => $time, "cardSign" => $cardSignStr)));
    die;
}
if ($action == "addCard") {
    $exts = $_POST['exts'];
    $appid = $_POST['appid'];
    if (YDWX_WEIXIN_COMPONENT_APP_ID) {
        $card_jsapi_ticket = YDWXHook::do_hook(YDWXHook::GET_HOST_CARD_JSAPI_TICKET, $appid);
    } else {
        $card_jsapi_ticket = YDWXHook::do_hook(YDWXHook::GET_CARD_JSAPI_TICKET);
    }
    $array = array();
    foreach ($exts as $ext) {
        $extObj = new YDWXCardExt();
        $extObj->cardId = $ext['cardId'];
        $extObj->code = @$ext['code'];
        $extObj->openid = @$ext['openid'];
        $extObj->jsApiTicket = $card_jsapi_ticket;
        $array[] = $extObj->toArray();
    }
    echo json_encode(ydwx_success($array));
    die;
}
示例#2
0
文件: pay.php 项目: qujian/ydwx
<?php

/**
 * 微信支付统一下单接口,生成预支付id,由ydwx的jsPayApi负责调起,与其配合完成微信内H5js调起支付
 */
chdir(dirname(__FILE__));
//把工作目录切换到文件所在目录
include_once dirname(__FILE__) . '/__config__.php';
$appid = $_POST['appid'];
$arg = new YDWXPayUnifiedOrderRequest();
$arg->openid = $_POST['openid'];
$arg->out_trade_no = $_POST['trace_no'];
$arg->total_fee = intval($_POST['price'] * 100);
$arg->attach = $_POST['attach'];
$arg->body = $_POST['pay_desc'];
try {
    $mchkey = YDWX_WEIXIN_COMPONENT_APP_ID ? YDWXHook::do_hook(YDWXHook::GET_HOST_MCH_KEY, $appid) : YDWX_WEIXIN_MCH_KEY;
    $msg = ydwx_pay_unifiedorder($arg);
    $str = "appId=" . $appid . "&nonceStr=" . $_POST['noncestr'] . "&package=prepay_id=" . $msg->prepay_id . "&signType=MD5&timeStamp=" . $_POST['timestamp'];
    $sign = strtoupper(md5($str . "&key=" . $mchkey));
    echo json_encode(ydwx_success(array("prepay_id" => $msg->prepay_id, "paySign" => $sign, "trade_no" => $_POST['trace_no'])));
    die;
} catch (YDWXException $e) {
    echo json_encode(ydwx_error($e->getMessage()));
    die;
}
示例#3
0
文件: packet.php 项目: qujian/ydwx
<?php

/**
 * 摇一摇抽红包js后端
 */
chdir(dirname(__FILE__));
//把工作目录切换到文件所在目录
include_once dirname(__FILE__) . '/__config__.php';
$lottery_id = $_POST['lottery_id'];
$key = $_POST['key'];
$noncestr = uniqid();
$openid = $_POST['openid'];
$array = array("lottery_id" => $lottery_id, "noncestr" => $noncestr, "openid" => $openid);
ksort($array);
$sign = strtoupper(md5(urldecode(http_build_query($array)) . "&key=" . $key));
echo json_encode(ydwx_success(array("noncestr" => $noncestr, "openid" => $openid, "sign" => $sign)));