• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java PayReq类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.tencent.mm.opensdk.modelpay.PayReq的典型用法代码示例。如果您正苦于以下问题:Java PayReq类的具体用法?Java PayReq怎么用?Java PayReq使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PayReq类属于com.tencent.mm.opensdk.modelpay包,在下文中一共展示了PayReq类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: pay

import com.tencent.mm.opensdk.modelpay.PayReq; //导入依赖的package包/类
public void pay(PayReq req) {
    if (isSupportPay()) {
        mWXApi.sendReq(req);
    }
    else {
        if (Wxpay.DEBUG) {
            Wxpay.log("您的微信版本太低或不支持支付");
        }
        if (payListener != null) {
            PayResp resp = new PayResp();
            resp.errCode = BaseResp.ErrCode.ERR_UNSUPPORT;
            payListener.onPayFailure(resp);
        }
    }
}
 
开发者ID:Jamling,项目名称:af-pay,代码行数:16,代码来源:Wxpay.java


示例2: signPayReq

import com.tencent.mm.opensdk.modelpay.PayReq; //导入依赖的package包/类
/**
 * 重新签名,当客户端下单的时候,统一订单接口并未返回timestamp,加上timestamp后,需要重新签名。
 * 如果是服务端下单,如果服务端已经重新生成了签名,那么无需客户端重新签名,直接拿PayReq对象去支付就可以了。
 *
 * @param req 将要调用微信客户端
 */
public static void signPayReq(PayReq req) {
    Map<String, String> sortedMap = new TreeMap<>();
    sortedMap.put("appid", req.appId);
    sortedMap.put("noncestr", req.nonceStr);
    sortedMap.put("partnerid", req.partnerId);
    sortedMap.put("prepayid", req.prepayId);
    sortedMap.put("timestamp", req.timeStamp);
    sortedMap.put("package", req.packageValue);
    String sign = OrderInfoUtil.genSign(sortedMap);
    if (Wxpay.DEBUG) {
        Wxpay.log("客户端支付重签名:" + sign);
    }
    req.sign = sign;
}
 
开发者ID:Jamling,项目名称:af-pay,代码行数:21,代码来源:OrderInfoUtil.java


示例3: wechartpay

import com.tencent.mm.opensdk.modelpay.PayReq; //导入依赖的package包/类
private void wechartpay(OrderWX mOrder) {
    PayReq req = new PayReq();
    //req.appId = "wxf8b4f85f3a794e77";  // 测试用appId
    req.appId = mOrder.getAppid();
    req.partnerId = mOrder.getPartnerid();
    req.prepayId = mOrder.getPrepayid();
    req.nonceStr = mOrder.getNoncestr();
    req.timeStamp = mOrder.getTimestamp();
    req.packageValue = "Sign=WXPay";
    req.sign = mOrder.getSign();
    req.extData = "app data"; // optional
    Toast.makeText(mWeApplication, "正常调起支付", Toast.LENGTH_SHORT).show();
    // 在支付之前,如果应用没有注册到微信,应该先调用IWXMsg.registerApp将应用注册到微信
    api.sendReq(req);
}
 
开发者ID:snowwolf10285,项目名称:PicShow-zhaipin,代码行数:16,代码来源:PayFragment.java


示例4: pay

import com.tencent.mm.opensdk.modelpay.PayReq; //导入依赖的package包/类
void pay(PayWXData payData) {
    PayReq req = new PayReq();
    req.appId = payData.appid;
    req.partnerId = payData.partnerid;
    req.prepayId = payData.prepayid;
    req.nonceStr = payData.noncestr;
    req.timeStamp = payData.timestamp;
    req.packageValue = payData.wxPackage;
    req.sign = payData.sign;
    req.extData = "app data";
    api.sendReq(req);
    Toast.makeText(context, "发起支付", Toast.LENGTH_SHORT).show();
    //支付结果回调写在WXPayEntryActivity
}
 
开发者ID:mangestudio,项目名称:GCSApp,代码行数:15,代码来源:PayWXStart.java


示例5: run

import com.tencent.mm.opensdk.modelpay.PayReq; //导入依赖的package包/类
@Override
public void run() {
    if (mAction.getPayType() == Pay.PayType.APIPAY) {
        PayTask payTask = new PayTask(mPay.getContext());
        String mapToParameters = Utils.getMapToParameters(mPayInfo.getOrderInfo(Map.class));
        Map<String, String> result = payTask.payV2(mapToParameters, false);
        PayResult payResult = new PayResult(result);
        if (TextUtils.equals(payResult.getResultStatus(), "9000")) {
            mDispatcher.dispatchResult(Dispatcher.SUCCESS, this);
        } else {
            mDispatcher.dispatchResult(Dispatcher.FAILED, this);
        }
    } else if (mAction.getPayType() == Pay.PayType.WECHAT) {
        PayReq payReq = mPayInfo.getOrderInfo(PayReq.class);
        IWXAPI msgApi = WXAPIFactory.createWXAPI(mPay.getContext(), null);
        msgApi.registerApp(payReq.appId);
        msgApi.handleIntent(mPay.getContext().getIntent(), new IWXAPIEventHandler() {
            @Override
            public void onReq(BaseReq baseReq) {

            }

            @Override
            public void onResp(BaseResp baseResp) {

            }
        });
    }
}
 
开发者ID:egzosn,项目名称:pay-java-android,代码行数:30,代码来源:PayHunter.java


示例6: WxPay

import com.tencent.mm.opensdk.modelpay.PayReq; //导入依赖的package包/类
public WxPay(Context context, PayReq payReq, PayResultCallBack callBack) {
    mWXApi = WXAPIFactory.createWXAPI(context, null);
    mWXApi.registerApp(sAppId);

    mPayReq = payReq;
    mCallbackProxy = new CallBackProxy(callBack);

    mUseStringParam = false;

    sWxPay = this;
}
 
开发者ID:beanu,项目名称:smart-farmer-android,代码行数:12,代码来源:WxPay.java


示例7: getPayReq

import com.tencent.mm.opensdk.modelpay.PayReq; //导入依赖的package包/类
public PayReq getPayReq() {
    return req;
}
 
开发者ID:Jamling,项目名称:af-pay,代码行数:4,代码来源:Wxpay.java


示例8: requestPay

import com.tencent.mm.opensdk.modelpay.PayReq; //导入依赖的package包/类
public Observable<WxPayResult> requestPay() {
    if (payBean == null) {
        payBean = new WXPayBean(appID, partnerid, noncestr, timestamp, prepayid, sign);
        appID = payBean.appid;
        partnerid = payBean.partnerid;
        noncestr = payBean.noncestr;
        timestamp = payBean.timestamp;
        prepayid = payBean.prepayid;
        sign = payBean.sign;
    }
   
    return
            Observable
                    .create(new ObservableOnSubscribe<WxPayResult>() {
                        @Override
                        public void subscribe(final ObservableEmitter<WxPayResult> emitter) throws Exception {
                            if (emitter.isDisposed()) {
                                return;
                            }

                            String checkResult = checkisEmpty();
                            
                            if (!isEmpty(checkResult)) {
                                emitter.onError(new PayFailedException(checkResult + " cannot be null"));
                                emitter.onComplete();
                                return;
                            }
                            
                            if (context == null) {
                                emitter.onError(new PayFailedException("you have not init the WxPay in your Application!"));
                                emitter.onComplete();
                                return;
                            }

                            final IWXAPI msgApi = WXAPIFactory.createWXAPI(context, null);
                            // 将该app注册到微信
                            msgApi.registerApp(payBean.getAppid());
                            
                            if (msgApi.getWXAppSupportAPI() < Build.PAY_SUPPORTED_SDK_INT) {
                                emitter.onNext(new WxPayResult(-7));
                                emitter.onComplete();
                                return;
                            }
                            PayReq request = new PayReq();
                            request.appId = payBean.appid;
                            request.partnerId = payBean.partnerid;
                            request.prepayId = payBean.prepayid;
                            request.packageValue = "Sign=WXPay";
                            request.nonceStr = payBean.noncestr;
                            request.timeStamp = payBean.timestamp;
                            request.sign = payBean.sign;
                            boolean isSend = msgApi.sendReq(request);
                            if (!isSend) {
                                emitter.onNext(new WxPayResult(-1));
                                emitter.onComplete();
                            } else {
                                BusUtil.getDefault()
                                        .doSubscribe(
                                                BaseResp.class, new Consumer<BaseResp>() {
                                                    @Override
                                                    public void accept(BaseResp baseResp) throws Exception {
                                                        emitter.onNext(new WxPayResult(baseResp.errCode));
                                                        emitter.onComplete();
                                                    }
                                                },
                                                new Consumer<Throwable>() {
                                                    @Override
                                                    public void accept(Throwable throwable) throws Exception {
                                                        Log.e("NewsMainPresenter", throwable.toString());
                                                    }
                                                });
                            }
                        }
                    })
                    .compose(RxPayUtils.<WxPayResult> checkWechatResult())
                    .compose(RxPayUtils.<WxPayResult> applySchedulers());
}
 
开发者ID:simplezhli,项目名称:RxPay,代码行数:78,代码来源:RxWxPay.java


示例9: pay

import com.tencent.mm.opensdk.modelpay.PayReq; //导入依赖的package包/类
public void pay(final JSONObject params, final ModuleResultListener listener) {

        final IWXAPI api = getWXAPI();

        PayReq req = new PayReq();

        try {
            req.appId = APP_ID;
            if (params.getString("mch_id") != null) {
                req.partnerId = params.getString("mch_id");
                req.prepayId = params.getString("prepay_id");
                req.nonceStr = params.getString("nonce");
            } else {
                req.partnerId = params.getString("partnerid");
                req.prepayId = params.getString("prepayid");
                req.nonceStr = params.getString("noncestr");
            }
            req.timeStamp = params.getString("timestamp");
            req.sign = params.getString("sign");
            req.packageValue = "Sign=WXPay";
        } catch (Exception e) {
            Log.e(TAG, e.getMessage());

            callbackError(301501, ERROR_INVALID_PARAMETERS, listener);
        }

        if (api.sendReq(req)) {
            Log.i(TAG, "Payment request has been sent successfully.");

            mAsyncListener = new AsyncListener() {
                @Override
                public void onSuccess(JSONObject result) {
                    listener.onResult(result);
                }

                @Override
                public void onError(int code, String msg) {
                    callbackError(code, msg, listener);
                }
            };
        } else {
            Log.i(TAG, "Payment request has been sent unsuccessfully.");

            // send error

            callbackError(301401, ERROR_SEND_REQUEST_FAILED, listener);
        }
    }
 
开发者ID:natjs,项目名称:nat-wechat,代码行数:49,代码来源:WechatModule.java


示例10: wxPay

import com.tencent.mm.opensdk.modelpay.PayReq; //导入依赖的package包/类
public static void wxPay(Activity activity, PayReq payReq, PayResultCallBack callBack){
    new WxPay(activity, payReq, callBack).doPay();
}
 
开发者ID:beanu,项目名称:smart-farmer-android,代码行数:4,代码来源:PayUtil.java


示例11: doPay

import com.tencent.mm.opensdk.modelpay.PayReq; //导入依赖的package包/类
/**
 * 发起微信支付
 */
public void doPay(String pay_param, WXPayResultCallBack callback) {
    mPayParam = pay_param;
    mCallback = callback;

    if (!check()) {
        if (mCallback != null) {
            mCallback.onError(NO_OR_LOW_WX);
        }
        return;
    }

    JSONObject param = null;
    try {
        param = new JSONObject(mPayParam);
    } catch (JSONException e) {
        e.printStackTrace();
        if (mCallback != null) {
            mCallback.onError(ERROR_PAY_PARAM);
        }
        return;
    }
    if (TextUtils.isEmpty(param.optString("appid")) || TextUtils.isEmpty(param.optString("partnerid"))
            || TextUtils.isEmpty(param.optString("prepayid")) || TextUtils.isEmpty(param.optString("packageValue")) ||
            TextUtils.isEmpty(param.optString("noncestr")) || TextUtils.isEmpty(param.optString("timestamp")) ||
            TextUtils.isEmpty(param.optString("sign"))) {
        if (mCallback != null) {
            mCallback.onError(ERROR_PAY_PARAM);
        }
        return;
    }

    PayReq req = new PayReq();
    req.appId = param.optString("appid");
    req.partnerId = param.optString("partnerid");
    req.prepayId = param.optString("prepayid");
    req.packageValue = param.optString("packageValue");
    req.nonceStr = param.optString("noncestr");
    req.timeStamp = param.optString("timestamp");
    req.sign = param.optString("sign");

    mWXApi.sendReq(req);
}
 
开发者ID:vondear,项目名称:RxTools,代码行数:46,代码来源:WechatPay.java


示例12: getPayReq

import com.tencent.mm.opensdk.modelpay.PayReq; //导入依赖的package包/类
/**
 * Get {@link com.tencent.mm.opensdk.modelpay.PayReq} from order xml result.
 *
 * @param xmlResultContent order result xml content
 *
 * @return PayReq
 */
public static PayReq getPayReq(String xmlResultContent) {
    Map<String, String> result = OrderInfoUtil.parseXmlResponse(xmlResultContent);
    return getPayReq(result);
}
 
开发者ID:Jamling,项目名称:af-pay,代码行数:12,代码来源:OrderInfoUtil.java



注:本文中的com.tencent.mm.opensdk.modelpay.PayReq类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ServerHandler类代码示例发布时间:2022-05-22
下一篇:
Java EurekaInstanceConfigBean类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap