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/Android
directory. - Modify
package com.wechatpay.gm.wxapi;
inWXPayEntryActivity.java
to your project's package name, for examplepackage com.yourcompany.game.wxapi;
- The
WXPay.cs
file defines all the available APIs. Call theInitSDK
function and pass in your app ID, then you can use thePay
function to open the payment dialog.