This repository was archived by the owner on Apr 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy pathOpenIAB_Mock.cs
111 lines (88 loc) · 2.83 KB
/
OpenIAB_Mock.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
namespace OnePF
{
#if UNITY_EDITOR
using System;
using System.Collections.Generic;
using System.Linq;
using Object = UnityEngine.Object;
public class OpenIAB_Mock : IOpenIAB
{
#region Fields
private readonly Dictionary<string, string> skuToStoreSku = new Dictionary<string, string>();
private readonly Dictionary<string, string> storeSkuToSku = new Dictionary<string, string>();
private OpenIABEventManager eventManager;
#endregion
#region Public Methods and Operators
public bool areSubscriptionsSupported()
{
return true;
}
public void consumeProduct(Purchase purchase)
{
throw new NotImplementedException();
}
public void enableDebugLogging(bool enabled)
{
throw new NotImplementedException();
}
public void enableDebugLogging(bool enabled, string tag)
{
throw new NotImplementedException();
}
public void init(Options options)
{
this.eventManager = Object.FindObjectOfType<OpenIABEventManager>();
if (this.eventManager != null)
{
this.eventManager.SendMessage("OnBillingSupported");
}
}
public bool isDebugLog()
{
throw new NotImplementedException();
}
public void mapSku(string sku, string storeName, string storeSku)
{
this.skuToStoreSku[sku] = storeSku;
this.storeSkuToSku[storeSku] = sku;
}
public void purchaseProduct(string sku, string developerPayload = "")
{
if (this.eventManager != null)
{
this.eventManager.SendMessage("OnPurchaseSucceeded", sku);
}
}
public void purchaseSubscription(string sku, string developerPayload = "")
{
this.purchaseProduct(sku, developerPayload);
}
public void queryInventory()
{
this.queryInventory(this.skuToStoreSku.Keys.ToArray());
}
public void queryInventory(string[] inAppSkus)
{
// Build fake inventory for testing in editor.
var inventory = new Inventory();
foreach (var sku in inAppSkus)
{
inventory.AddSkuDetails(
new SkuDetails { Sku = sku, Price = "$9.99", PriceValue = "9.99", CurrencyCode = "$" });
}
if (this.eventManager != null)
{
this.eventManager.SendMessage("OnQueryInventorySucceeded", inventory);
}
}
public void restoreTransactions()
{
throw new NotImplementedException();
}
public void unbindService()
{
}
#endregion
}
#endif
}