Wechat pay SDK plugin for unity, support android platform only.
对微信SDK的支付部分进行Unity封装,让SDK的使用直接面向C#,简单易用。
- 下载wechatpay.unitypackage,导入到Unity即可;如果你的工程中已经存在External Dependency Manager根据你自己的情况选择是否导入该目录。
- 如果你在使用Unity 2019及以下版本,需要把WechatPay.androidlib目录剪切到
Plugins/Android下。 - 修改
WXPayEntryActivity.java中的package com.wechatpay.wxapi;为你自己项目的包名,否则无法支付,例如:package com.yourcompany.game.wxapi; - 接口都封装在
WXPay.cs中,先调用InitSDK传入appid进行初始化,然后就可以使用Pay接口进行支付了。
- Download the WeChatPay.unitypackage and import it into your project. If you already have the External Dependency Manager plugin in your project, choose whether or not to import this folder according to your needs.
- If you are using Unity 2019 or an earlier version, you need to move the WeChatPay.androidlib folder into the
Plugins/Androiddirectory. - Modify
package com.wechatpay.gm.wxapi;inWXPayEntryActivity.javato your project's package name, for examplepackage com.yourcompany.game.wxapi; - The
WXPay.csfile defines all the available APIs. Call theInitSDKfunction and pass in your app ID, then you can use thePayfunction to open the payment dialog.