update:逻辑更新
This commit is contained in:
@@ -1,14 +1,82 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace tysdk
|
||||
{
|
||||
public enum EAccoutType
|
||||
{
|
||||
hwGoogle,
|
||||
hwFacebook,
|
||||
hwGuest,
|
||||
hwVkid,
|
||||
Apple,
|
||||
none
|
||||
}
|
||||
|
||||
public enum PaymentReceiptProvider
|
||||
{
|
||||
None,
|
||||
Flexion
|
||||
}
|
||||
|
||||
public class PaymentReceipt
|
||||
{
|
||||
public PaymentReceiptProvider Provider;
|
||||
public string PurchaseJson;
|
||||
public string Signature;
|
||||
public string PurchaseToken;
|
||||
|
||||
public bool HasPayload => !string.IsNullOrEmpty(PurchaseJson);
|
||||
public bool CanConsume => !string.IsNullOrEmpty(PurchaseToken);
|
||||
}
|
||||
|
||||
public class PaymentReceiptVerification
|
||||
{
|
||||
public bool Verified;
|
||||
public string ServerOrderId;
|
||||
public int ProviderCode;
|
||||
public string ProviderMessage;
|
||||
}
|
||||
|
||||
public class LoginInfo
|
||||
{
|
||||
public bool isSuccess;
|
||||
public int userId;
|
||||
public string StrUserId => userId.ToString();
|
||||
public string msg;
|
||||
public int code;
|
||||
}
|
||||
|
||||
public class LinkResult
|
||||
{
|
||||
// 0: success, 1: fail, -1 exists
|
||||
public int code;
|
||||
// when success and fail userId is current user
|
||||
// when exists userId is 0
|
||||
public int userId;
|
||||
// not none when exists
|
||||
public Dictionary<string, string> bindInfo;
|
||||
}
|
||||
|
||||
public class ChangeLinkResult
|
||||
{
|
||||
public int code;
|
||||
public int userId;
|
||||
public string msg;
|
||||
}
|
||||
|
||||
public class LinkCheckInfo
|
||||
{
|
||||
public int code;
|
||||
}
|
||||
|
||||
public class PaymentInfo
|
||||
{
|
||||
public bool isSuccessFromSdk => code == "0";
|
||||
public bool isSuccess => isSuccessFromSdk && confirmed;
|
||||
private bool confirmed { get; set; } = false;
|
||||
private bool confirmed {get; set;} = false;
|
||||
public int count;
|
||||
public string orderId;
|
||||
public string productId;
|
||||
@@ -17,6 +85,8 @@ namespace tysdk
|
||||
public string code;
|
||||
public string msg;
|
||||
|
||||
// Compatibility fields for legacy server payload and existing call sites.
|
||||
// New payment flow should read receipt data from Receipt.
|
||||
// Flexion: purchase.getOriginalJson(), used by server for RSA signature verification
|
||||
public string purchaseJson;
|
||||
// Flexion: purchase.getSignature(), used by server for RSA signature verification
|
||||
@@ -24,6 +94,21 @@ namespace tysdk
|
||||
// Flexion: purchase token, used to consume after server verification
|
||||
public string purchaseToken;
|
||||
|
||||
[JsonIgnore]
|
||||
public PaymentReceipt Receipt;
|
||||
|
||||
[JsonIgnore]
|
||||
public PaymentReceiptVerification ReceiptVerification;
|
||||
|
||||
[JsonIgnore]
|
||||
public bool HasReceipt => Receipt != null && Receipt.HasPayload;
|
||||
|
||||
[JsonIgnore]
|
||||
public bool CanConsumeReceipt => Receipt != null && Receipt.CanConsume;
|
||||
|
||||
// Store order ID from Flexion SDK (e.g. GPA.xxx)
|
||||
public string storeOrderId;
|
||||
|
||||
public bool verified;
|
||||
|
||||
// Server-side order ID returned from verification
|
||||
@@ -36,17 +121,17 @@ namespace tysdk
|
||||
{
|
||||
confirmed = orderId == this.orderId && productId == this.productId;
|
||||
|
||||
if (!confirmed)
|
||||
if(!confirmed)
|
||||
UnityEngine.Debug.LogWarning("[TYSdk Pay] order not confirmed");
|
||||
return confirmed;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
return Newtonsoft.Json.JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class ProductListInfo
|
||||
{
|
||||
public int code = 1;
|
||||
@@ -70,6 +155,7 @@ namespace tysdk
|
||||
products = prodList;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#if UNITY_IOS
|
||||
@@ -90,7 +176,7 @@ namespace tysdk
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
return Newtonsoft.Json.JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
#else
|
||||
@@ -98,24 +184,37 @@ namespace tysdk
|
||||
{
|
||||
public string description;
|
||||
public string ourProductId;
|
||||
public string productId;
|
||||
public string price;
|
||||
public string price_amount_micros;
|
||||
public string price_currency_code;
|
||||
public string productId;
|
||||
public string title;
|
||||
public string type;
|
||||
public string currency;
|
||||
public string price_amount;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Newtonsoft.Json.JsonConvert.SerializeObject(this);
|
||||
}
|
||||
|
||||
public string ProdPriceStr => price;
|
||||
public float ProdPrice => float.Parse(price_amount_micros) / 1000000;
|
||||
public string ProdID => ourProductId;
|
||||
public string ProdKey => productId;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
public class ATTInfo
|
||||
{
|
||||
public bool isAccepted;
|
||||
}
|
||||
|
||||
public class FlexionOrderResult
|
||||
{
|
||||
public int code { get; set; }
|
||||
public string info { get; set; }
|
||||
public string orderId { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user