Skip to content

Commit a89ec41

Browse files
authored
Merge pull request #57 from VirtueSky/dev
Dev
2 parents a0f1a81 + 7aa8fea commit a89ec41

File tree

9 files changed

+45
-27
lines changed

9 files changed

+45
-27
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
### 1: Download the repository and drop it into folder `Assets`
2424
### 2: Add the line below to `Packages/manifest.json`
2525

26-
for version `3.3.4`
26+
for version `3.3.5`
2727
```csharp
28-
"com.virtuesky.sunflower":"https://github.com/VirtueSky/sunflower.git#3.3.4",
28+
"com.virtuesky.sunflower":"https://github.com/VirtueSky/sunflower.git#3.3.5",
2929
```
3030

3131
## Includes modules

VirtueSky/ControlPanel/ConstantPackage.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{
33
public class ConstantPackage
44
{
5-
public const string VersionSunflower = "3.3.4";
5+
public const string VersionSunflower = "3.3.5";
66
public const string PackageNameInAppPurchase = "com.unity.purchasing";
77
public const string MaxVersionInAppPurchase = "4.12.2";
88
public const string PackageNameNewtonsoftJson = "com.unity.nuget.newtonsoft-json";
@@ -20,7 +20,7 @@ public class ConstantPackage
2020
public const string PackageNameAdmob = "com.google.ads.mobile";
2121

2222
public const string VersionAdmob =
23-
"https://github.com/googleads/googleads-mobile-unity.git?path=packages/com.google.ads.mobile#v10.0.0";
23+
"https://github.com/googleads/googleads-mobile-unity.git?path=packages/com.google.ads.mobile#v10.1.0";
2424

2525
#region Google Unity
2626

@@ -94,12 +94,12 @@ public class ConstantPackage
9494
public const string PackageNameAppFlyer = "appsflyer-unity-plugin";
9595

9696
public const string MaxVersionAppFlyer =
97-
"https://github.com/AppsFlyerSDK/appsflyer-unity-plugin.git#v6.16.21";
97+
"https://github.com/AppsFlyerSDK/appsflyer-unity-plugin.git?path=Assets/AppsFlyer#v6.16.21";
9898

9999
public const string PackageNameCoffeeUIEffect = "com.coffee.ui-effect";
100100

101101
public const string MaxVersionCoffeeUIEffect =
102-
"https://github.com/mob-sakai/UIEffect.git?path=Packages/src#5.8.1";
102+
"https://github.com/mob-sakai/UIEffect.git?path=Packages/src#5.8.4";
103103

104104
public const string PackageNameCoffeeUIParticle = "com.coffee.ui-particle";
105105

VirtueSky/Iap/Editor/IapSettingEditor.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class IapSettingEditor : Editor
1414
private SerializedProperty _skusData;
1515
private SerializedProperty _products;
1616
private SerializedProperty _isValidatePurchase;
17+
private SerializedProperty _isCustomValidatePurchase;
1718
private SerializedProperty _googlePlayStoreKey;
1819

1920
void Initialize()
@@ -22,6 +23,7 @@ void Initialize()
2223
_skusData = serializedObject.FindProperty("skusData");
2324
_products = serializedObject.FindProperty("products");
2425
_isValidatePurchase = serializedObject.FindProperty("isValidatePurchase");
26+
_isCustomValidatePurchase = serializedObject.FindProperty("isCustomValidatePurchase");
2527
_googlePlayStoreKey = serializedObject.FindProperty("googlePlayStoreKey");
2628
}
2729

@@ -39,6 +41,7 @@ public override void OnInspectorGUI()
3941
EditorGUILayout.PropertyField(_isValidatePurchase);
4042
if (_isValidatePurchase.boolValue)
4143
{
44+
EditorGUILayout.PropertyField(_isCustomValidatePurchase);
4245
EditorGUILayout.PropertyField(_googlePlayStoreKey);
4346
if (GUILayout.Button("Obfuscator Key"))
4447
{
@@ -55,7 +58,9 @@ void GenerateProduct()
5558
for (int i = 0; i < _iapSetting.SkusData.Count; i++)
5659
{
5760
string itemName = _iapSetting.SkusData[i].id.Split('.').Last();
58-
var itemDataVariable = CreateAsset.CreateAndGetScriptableAssetByName<IapDataVariable>("/Iap/Products", $"iap_{itemName.ToLower()}");
61+
var itemDataVariable =
62+
CreateAsset.CreateAndGetScriptableAssetByName<IapDataVariable>("/Iap/Products",
63+
$"iap_{itemName.ToLower()}");
5964
itemDataVariable.id = _iapSetting.SkusData[i].id;
6065
itemDataVariable.productType = _iapSetting.SkusData[i].productType;
6166
_iapSetting.Products.Add(itemDataVariable);

VirtueSky/Iap/Runtime/IapManager.cs

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public class IapManager : BaseMono, IDetailedStoreListener
2727
private IStoreController _controller;
2828
private IExtensionProvider _extensionProvider;
2929
private static event Action RestoreEvent;
30+
public static event Func<bool> CustomValidatePurchaseEvent;
3031
public static bool IsInitialized { get; private set; }
3132
public static void Restore() => RestoreEvent?.Invoke();
3233

@@ -92,7 +93,8 @@ internal Product GetProduct(IapDataVariable product)
9293

9394
internal SubscriptionInfo GetSubscriptionInfo(IapDataVariable product)
9495
{
95-
if (_controller == null || product.productType != ProductType.Subscription || !_controller.products.WithID(product.id).hasReceipt) return null;
96+
if (_controller == null || product.productType != ProductType.Subscription ||
97+
!_controller.products.WithID(product.id).hasReceipt) return null;
9698
var subscriptionManager = new SubscriptionManager(GetProduct(product), null);
9799
var subscriptionInfo = subscriptionManager.getSubscriptionInfo();
98100
return subscriptionInfo;
@@ -106,26 +108,35 @@ public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs purchaseEvent)
106108
{
107109
if (iapSetting.IsValidatePurchase)
108110
{
109-
bool validatedPurchase = true;
111+
if (iapSetting.IsCustomValidatePurchase)
112+
{
113+
if ((bool)CustomValidatePurchaseEvent?.Invoke()) PurchaseVerified(purchaseEvent);
114+
}
115+
else
116+
{
117+
bool validatedPurchase = true;
110118
#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX) && !UNITY_EDITOR
111-
var validator =
112-
new UnityEngine.Purchasing.Security.CrossPlatformValidator(UnityEngine.Purchasing.Security.GooglePlayTangle.Data(),
113-
UnityEngine.Purchasing.Security.AppleTangle.Data(), Application.identifier);
119+
var validator =
120+
new UnityEngine.Purchasing.Security.CrossPlatformValidator(
121+
UnityEngine.Purchasing.Security.GooglePlayTangle.Data(),
122+
UnityEngine.Purchasing.Security.AppleTangle.Data(), Application.identifier);
123+
124+
try
125+
{
126+
// On Google Play, result has a single product ID.
127+
// On Apple stores, receipts contain multiple products.
128+
var result = validator.Validate(purchaseEvent.purchasedProduct.receipt);
129+
Debug.Log("Receipt is valid");
130+
}
131+
catch (UnityEngine.Purchasing.Security.IAPSecurityException)
132+
{
133+
Debug.Log("Invalid receipt, not unlocking content");
134+
validatedPurchase = false;
135+
}
114136

115-
try
116-
{
117-
// On Google Play, result has a single product ID.
118-
// On Apple stores, receipts contain multiple products.
119-
var result = validator.Validate(purchaseEvent.purchasedProduct.receipt);
120-
Debug.Log("Receipt is valid");
121-
}
122-
catch (UnityEngine.Purchasing.Security.IAPSecurityException)
123-
{
124-
Debug.Log("Invalid receipt, not unlocking content");
125-
validatedPurchase = false;
126-
}
127137
#endif
128-
if (validatedPurchase) PurchaseVerified(purchaseEvent);
138+
if (validatedPurchase) PurchaseVerified(purchaseEvent);
139+
}
129140
}
130141
else
131142
{

VirtueSky/Iap/Runtime/IapSetting.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class IapSetting : ScriptableObject
1414
[SerializeField] private List<IapDataVariable> products = new List<IapDataVariable>();
1515

1616
[Space, SerializeField] private bool isValidatePurchase;
17+
[SerializeField] private bool isCustomValidatePurchase;
1718
#if UNITY_EDITOR
1819
//[ShowIf(nameof(isValidatePurchase), true)]
1920
[SerializeField, TextArea] private string googlePlayStoreKey;
@@ -22,6 +23,7 @@ public class IapSetting : ScriptableObject
2223
public List<IapData> SkusData => skusData;
2324
public List<IapDataVariable> Products => products;
2425
public bool IsValidatePurchase => isValidatePurchase;
26+
public bool IsCustomValidatePurchase => isCustomValidatePurchase;
2527
}
2628

2729
[Serializable]
0 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
- Version Max Sdk: 8.2.0
1+
- Version Max Sdk: 8.2.2
22
- Version Google Game Play Service: v2.0.0
Binary file not shown.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "com.virtuesky.sunflower",
33
"displayName": "Sunflower",
44
"description": "Core ScriptableObject Architecture for building Unity games",
5-
"version": "3.3.4",
5+
"version": "3.3.5",
66
"unity": "2022.3",
77
"category": "virtuesky",
88
"license": "MIT",

0 commit comments

Comments
 (0)