85 lines
2.3 KiB
C#
85 lines
2.3 KiB
C#
using UnityEngine;
|
|
|
|
namespace GameWrapper.Pay
|
|
{
|
|
public class WXPayHandle : MonoBehaviour
|
|
{
|
|
private static WXPayHandle _instance;
|
|
|
|
public static WXPayHandle Instance
|
|
{
|
|
get
|
|
{
|
|
if (_instance == null)
|
|
{
|
|
var go = new GameObject("WXPayHandle");
|
|
_instance = go.AddComponent<WXPayHandle>();
|
|
DontDestroyOnLoad(go);
|
|
}
|
|
|
|
return _instance;
|
|
}
|
|
}
|
|
|
|
private void Awake()
|
|
{
|
|
if (_instance == null)
|
|
{
|
|
_instance = this;
|
|
Initialize();
|
|
DontDestroyOnLoad(gameObject);
|
|
}
|
|
else
|
|
{
|
|
Destroy(gameObject);
|
|
}
|
|
}
|
|
|
|
void OnApplicationPause(bool pauseStatus)
|
|
{
|
|
PaymentServiceLocator.WxPaymentService.OnApplicationPause(pauseStatus);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 初始化支付服务
|
|
/// </summary>
|
|
public void Initialize()
|
|
{
|
|
PaymentServiceLocator.WxPaymentService.Initialize();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 检查微信是否已初始化
|
|
/// </summary>
|
|
public bool IsWxInitialized()
|
|
{
|
|
return PaymentServiceLocator.WxPaymentService.IsAppInitialized();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 开始支付
|
|
/// </summary>
|
|
public void BuyGoods(string currencyID, int count, int itemID, int param = 0, int shopID = 0, int goodsID = 0, int index = 0)
|
|
{
|
|
PaymentServiceLocator.WxPaymentService.BuyGoods(currencyID, count, itemID, param, shopID, goodsID, index);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 支付回调 由java层调用
|
|
/// </summary>
|
|
public void OnPaymentCallback(string result)
|
|
{
|
|
DebugUtil.Log("WXPayHandle.OnPaymentCallback result: {0}", result);
|
|
PaymentServiceLocator.WxPaymentService.OnPaymentCallback(result);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 是否在支付流程中
|
|
/// </summary>
|
|
public bool IsPaying()
|
|
{
|
|
return PaymentServiceLocator.WxPaymentService.IsPaying();
|
|
}
|
|
}
|
|
} |