restoreFailedEvent;
78 |
79 | /**
80 | * Fired when transaction restoration process succeeded
81 | */
82 | public static event Action restoreSucceededEvent;
83 | #pragma warning restore 0067
84 |
85 | private void Awake()
86 | {
87 | // Set the GameObject name to the class name for easy access from native plugin
88 | gameObject.name = GetType().ToString();
89 | DontDestroyOnLoad(this);
90 | }
91 |
92 | #if UNITY_ANDROID
93 | private void OnMapSkuFailed(string exception)
94 | {
95 | Debug.LogError("SKU mapping failed: " + exception);
96 | }
97 |
98 | private void OnBillingSupported(string empty)
99 | {
100 | if (billingSupportedEvent != null)
101 | billingSupportedEvent();
102 | }
103 |
104 | private void OnBillingNotSupported(string error)
105 | {
106 | if (billingNotSupportedEvent != null)
107 | billingNotSupportedEvent(error);
108 | }
109 |
110 | private void OnQueryInventorySucceeded(string json)
111 | {
112 | if (queryInventorySucceededEvent != null)
113 | {
114 | Inventory inventory = new Inventory(json);
115 | queryInventorySucceededEvent(inventory);
116 | }
117 | }
118 |
119 | private void OnQueryInventoryFailed(string error)
120 | {
121 | if (queryInventoryFailedEvent != null)
122 | queryInventoryFailedEvent(error);
123 | }
124 |
125 | private void OnPurchaseSucceeded(string json)
126 | {
127 | if (purchaseSucceededEvent != null)
128 | purchaseSucceededEvent(new Purchase(json));
129 | }
130 |
131 | private void OnPurchaseFailed(string message)
132 | {
133 | int errorCode = -1;
134 | string errorMessage = "Unknown error";
135 |
136 | if (!string.IsNullOrEmpty(message)) {
137 | string[] tokens = message.Split('|');
138 |
139 | if (tokens.Length >= 2) {
140 | Int32.TryParse(tokens[0], out errorCode);
141 | errorMessage = tokens[1];
142 | } else {
143 | errorMessage = message;
144 | }
145 | }
146 | if (purchaseFailedEvent != null)
147 | purchaseFailedEvent(errorCode, errorMessage);
148 | }
149 |
150 | private void OnConsumePurchaseSucceeded(string json)
151 | {
152 | if (consumePurchaseSucceededEvent != null)
153 | consumePurchaseSucceededEvent(new Purchase(json));
154 | }
155 |
156 | private void OnConsumePurchaseFailed(string error)
157 | {
158 | if (consumePurchaseFailedEvent != null)
159 | consumePurchaseFailedEvent(error);
160 | }
161 |
162 | public void OnTransactionRestored(string json)
163 | {
164 | if (transactionRestoredEvent != null)
165 | {
166 | transactionRestoredEvent(new Purchase(json));
167 | }
168 | }
169 |
170 | public void OnRestoreTransactionFailed(string error)
171 | {
172 | if (restoreFailedEvent != null)
173 | {
174 | restoreFailedEvent(error);
175 | }
176 | }
177 |
178 | public void OnRestoreTransactionSucceeded(string message)
179 | {
180 | if (restoreSucceededEvent != null)
181 | {
182 | restoreSucceededEvent();
183 | }
184 | }
185 | #endif
186 |
187 | #if UNITY_IOS
188 | private void OnBillingSupported(string empty)
189 | {
190 | if (billingSupportedEvent != null)
191 | {
192 | billingSupportedEvent();
193 | }
194 | }
195 |
196 | private void OnBillingNotSupported(string error)
197 | {
198 | if (billingNotSupportedEvent != null)
199 | billingNotSupportedEvent(error);
200 | }
201 |
202 | private void OnQueryInventorySucceeded(string json)
203 | {
204 | if (queryInventorySucceededEvent != null)
205 | {
206 | Inventory inventory = new Inventory(json);
207 | queryInventorySucceededEvent(inventory);
208 | }
209 | }
210 |
211 | private void OnQueryInventoryFailed(string error)
212 | {
213 | if (queryInventoryFailedEvent != null)
214 | queryInventoryFailedEvent(error);
215 | }
216 |
217 | private void OnPurchaseSucceeded(string json)
218 | {
219 | if (purchaseSucceededEvent != null)
220 | {
221 | purchaseSucceededEvent(new Purchase(json));
222 | }
223 | }
224 |
225 | private void OnPurchaseFailed(string error)
226 | {
227 | if (purchaseFailedEvent != null)
228 | {
229 | // -1005 is similar to android "cancelled" code
230 | purchaseFailedEvent(string.Equals(error, "Transaction cancelled")? -1005 : -1, error);
231 | }
232 | }
233 |
234 | private void OnConsumePurchaseSucceeded(string json)
235 | {
236 | if (consumePurchaseSucceededEvent != null)
237 | consumePurchaseSucceededEvent(new Purchase(json));
238 | }
239 |
240 | private void OnConsumePurchaseFailed(string error)
241 | {
242 | if (consumePurchaseFailedEvent != null)
243 | consumePurchaseFailedEvent(error);
244 | }
245 |
246 | public void OnPurchaseRestored(string json)
247 | {
248 | if (transactionRestoredEvent != null)
249 | {
250 | transactionRestoredEvent(new Purchase(json));
251 | }
252 | }
253 |
254 | public void OnRestoreFailed(string error)
255 | {
256 | if (restoreFailedEvent != null)
257 | {
258 | restoreFailedEvent(error);
259 | }
260 | }
261 |
262 | public void OnRestoreFinished(string message)
263 | {
264 | if (restoreSucceededEvent != null)
265 | {
266 | restoreSucceededEvent();
267 | }
268 | }
269 | #endif
270 |
271 | #if UNITY_WP8
272 | public void OnBillingSupported()
273 | {
274 | if (billingSupportedEvent != null)
275 | billingSupportedEvent();
276 | }
277 |
278 | public void OnBillingNotSupported(string error)
279 | {
280 | if (billingNotSupportedEvent != null)
281 | billingNotSupportedEvent(error);
282 | }
283 |
284 | private void OnQueryInventorySucceeded(Inventory inventory)
285 | {
286 | if (queryInventorySucceededEvent != null)
287 | queryInventorySucceededEvent(inventory);
288 | }
289 |
290 | private void OnQueryInventoryFailed(string error)
291 | {
292 | if (queryInventoryFailedEvent != null)
293 | queryInventoryFailedEvent(error);
294 | }
295 |
296 | private void OnPurchaseSucceeded(Purchase purchase)
297 | {
298 | if (purchaseSucceededEvent != null)
299 | purchaseSucceededEvent(purchase);
300 | }
301 |
302 | private void OnPurchaseFailed(string error)
303 | {
304 | if (purchaseFailedEvent != null)
305 | purchaseFailedEvent(-1, error);
306 | }
307 |
308 | private void OnConsumePurchaseSucceeded(Purchase purchase)
309 | {
310 | if (consumePurchaseSucceededEvent != null)
311 | consumePurchaseSucceededEvent(purchase);
312 | }
313 |
314 | private void OnConsumePurchaseFailed(string error)
315 | {
316 | if (consumePurchaseFailedEvent != null)
317 | consumePurchaseFailedEvent(error);
318 | }
319 | #endif
320 | }
321 |
--------------------------------------------------------------------------------
/unity_plugin/unity_src/Assets/Plugins/OpenIAB/OpenIABEventManager.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 63d9ab6456c839448bd269e6b3c831ae
3 | labels:
4 | - inapp
5 | - in-app
6 | - amazon
7 | - google
8 | - samsung
9 | - iap
10 | - Amazon
11 | - Google
12 | - Iap
13 | - In-app
14 | - Inapp
15 | - Samsung
16 | - billing
17 | - appstore
18 | - app-store
19 | - in
20 | - app
21 | - store
22 | - storekit
23 | - android
24 | - ios
25 | - purchase
26 | - onepf
27 | - open
28 | - opensource
29 | - source
30 | MonoImporter:
31 | serializedVersion: 2
32 | defaultReferences: []
33 | executionOrder: 0
34 | icon: {instanceID: 0}
35 | userData:
36 |
--------------------------------------------------------------------------------
/unity_plugin/unity_src/Assets/Plugins/OpenIAB/Options.cs:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright 2012-2014 One Platform Foundation
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | ******************************************************************************/
16 |
17 | using System.Collections.Generic;
18 |
19 | namespace OnePF
20 | {
21 | /**
22 | * All options of OpenIAB can be found here
23 | */
24 | public class Options
25 | {
26 | /**
27 | * Default timeout (in milliseconds) for discover all OpenStores on device.
28 | */
29 | public const int DISCOVER_TIMEOUT_MS = 5000;
30 |
31 | /**
32 | * For generic stores it takes 1.5 - 3sec
33 | * SamsungApps initialization is very time consuming (from 4 to 12 seconds).
34 | */
35 | public const int INVENTORY_CHECK_TIMEOUT_MS = 10000;
36 |
37 | /**
38 | * Wait specified amount of ms to find all OpenStores on device
39 | */
40 | public int discoveryTimeoutMs = DISCOVER_TIMEOUT_MS;
41 |
42 | /**
43 | * Check user inventory in every store to select proper store
44 | *
45 | * Will try to connect to each billingService and extract user's purchases.
46 | * If purchases have been found in the only store that store will be used for further purchases.
47 | * If purchases have been found in multiple stores only such stores will be used for further elections
48 | */
49 | public bool checkInventory = true;
50 |
51 | /**
52 | * Wait specified amount of ms to check inventory in all stores
53 | */
54 | public int checkInventoryTimeoutMs = INVENTORY_CHECK_TIMEOUT_MS;
55 |
56 | /**
57 | * OpenIAB could skip receipt verification by publicKey for GooglePlay and OpenStores
58 | *
59 | * Receipt could be verified in {@link OnIabPurchaseFinishedListener#onIabPurchaseFinished()}
60 | * using {@link Purchase#getOriginalJson()} and {@link Purchase#getSignature()}
61 | */
62 | public OptionsVerifyMode verifyMode = OptionsVerifyMode.VERIFY_EVERYTHING;
63 |
64 | public SearchStrategy storeSearchStrategy = SearchStrategy.INSTALLER;
65 |
66 | /**
67 | * storeKeys is map of [ appstore name -> publicKeyBase64 ]
68 | * Put keys for all stores you support in this Map and pass it to instantiate {@link OpenIabHelper}
69 | *
70 | * publicKey key is used to verify receipt is created by genuine Appstore using
71 | * provided signature. It can be found in Developer Console of particular store
72 | *
73 | * name of particular store can be provided by local_store tool if you run it on device.
74 | * For Google Play OpenIAB uses {@link OpenIabHelper#NAME_GOOGLE}.
75 | *
76 | *
Note:
77 | * AmazonApps and SamsungApps doesn't use RSA keys for receipt verification, so you don't need
78 | * to specify it
79 | */
80 | public Dictionary storeKeys = new Dictionary();
81 |
82 | /**
83 | * Used as priority list if store that installed app is not found and there are
84 | * multiple stores installed on device that supports billing.
85 | */
86 | public string[] prefferedStoreNames = new string[] { };
87 |
88 | public string[] availableStoreNames = new string[] { };
89 |
90 | public int samsungCertificationRequestCode;
91 | }
92 | }
--------------------------------------------------------------------------------
/unity_plugin/unity_src/Assets/Plugins/OpenIAB/Options.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: bd9b556a698ef084ba1038e5ba2a572f
3 | labels:
4 | - inapp
5 | - in-app
6 | - amazon
7 | - google
8 | - samsung
9 | - iap
10 | - Amazon
11 | - Google
12 | - Iap
13 | - In-app
14 | - Inapp
15 | - Samsung
16 | - billing
17 | - appstore
18 | - app-store
19 | - in
20 | - app
21 | - store
22 | - storekit
23 | - android
24 | - ios
25 | - purchase
26 | - onepf
27 | - open
28 | - opensource
29 | - source
30 | MonoImporter:
31 | serializedVersion: 2
32 | defaultReferences: []
33 | executionOrder: 0
34 | icon: {instanceID: 0}
35 | userData:
36 |
--------------------------------------------------------------------------------
/unity_plugin/unity_src/Assets/Plugins/OpenIAB/OptionsVerifyMode.cs:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright 2012-2014 One Platform Foundation
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | ******************************************************************************/
16 |
17 | using System;
18 | using System.Collections.Generic;
19 | using System.Linq;
20 | using System.Text;
21 |
22 | namespace OnePF
23 | {
24 | public enum OptionsVerifyMode
25 | {
26 | /**
27 | * Verify signatures in any store.
28 | *
29 | * By default in Google's IabHelper. Throws exception if key is not available or invalid.
30 | * To prevent crashes OpenIAB wouldn't connect to OpenStore if no publicKey provided
31 | */
32 | VERIFY_EVERYTHING = 0,
33 |
34 | /**
35 | * Don't verify signatires. To perform verification on server-side
36 | */
37 | VERIFY_SKIP = 1,
38 |
39 | /**
40 | * Verify signatures only if publicKey is available. Otherwise skip verification.
41 | *
42 | * Developer is responsible for verify
43 | */
44 | VERIFY_ONLY_KNOWN = 2
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/unity_plugin/unity_src/Assets/Plugins/OpenIAB/OptionsVerifyMode.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: d923727ef887bf6458bd92253a836304
3 | labels:
4 | - inapp
5 | - in-app
6 | - amazon
7 | - google
8 | - samsung
9 | - iap
10 | - Amazon
11 | - Google
12 | - Iap
13 | - In-app
14 | - Inapp
15 | - Samsung
16 | - billing
17 | - appstore
18 | - app-store
19 | - in
20 | - app
21 | - store
22 | - storekit
23 | - android
24 | - ios
25 | - purchase
26 | - onepf
27 | - open
28 | - opensource
29 | - source
30 | MonoImporter:
31 | serializedVersion: 2
32 | defaultReferences: []
33 | executionOrder: 0
34 | icon: {instanceID: 0}
35 | userData:
36 |
--------------------------------------------------------------------------------
/unity_plugin/unity_src/Assets/Plugins/OpenIAB/Prefabs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 4d9baf6f6e75c774fbb2853817688168
3 | DefaultImporter:
4 | userData:
5 |
--------------------------------------------------------------------------------
/unity_plugin/unity_src/Assets/Plugins/OpenIAB/Prefabs/OpenIABEventManager.prefab:
--------------------------------------------------------------------------------
1 | %YAML 1.1
2 | %TAG !u! tag:unity3d.com,2011:
3 | --- !u!1 &100000
4 | GameObject:
5 | m_ObjectHideFlags: 0
6 | m_PrefabParentObject: {fileID: 0}
7 | m_PrefabInternal: {fileID: 100100000}
8 | serializedVersion: 4
9 | m_Component:
10 | - 4: {fileID: 400000}
11 | - 114: {fileID: 11400000}
12 | m_Layer: 0
13 | m_Name: OpenIABEventManager
14 | m_TagString: Untagged
15 | m_Icon: {fileID: 0}
16 | m_NavMeshLayer: 0
17 | m_StaticEditorFlags: 0
18 | m_IsActive: 1
19 | --- !u!4 &400000
20 | Transform:
21 | m_ObjectHideFlags: 1
22 | m_PrefabParentObject: {fileID: 0}
23 | m_PrefabInternal: {fileID: 100100000}
24 | m_GameObject: {fileID: 100000}
25 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
26 | m_LocalPosition: {x: 0, y: 0, z: 0}
27 | m_LocalScale: {x: 1, y: 1, z: 1}
28 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
29 | m_Children: []
30 | m_Father: {fileID: 0}
31 | m_RootOrder: 0
32 | --- !u!114 &11400000
33 | MonoBehaviour:
34 | m_ObjectHideFlags: 1
35 | m_PrefabParentObject: {fileID: 0}
36 | m_PrefabInternal: {fileID: 100100000}
37 | m_GameObject: {fileID: 100000}
38 | m_Enabled: 1
39 | m_EditorHideFlags: 0
40 | m_Script: {fileID: 11500000, guid: 63d9ab6456c839448bd269e6b3c831ae, type: 3}
41 | m_Name:
42 | m_EditorClassIdentifier:
43 | --- !u!1001 &100100000
44 | Prefab:
45 | m_ObjectHideFlags: 1
46 | serializedVersion: 2
47 | m_Modification:
48 | m_TransformParent: {fileID: 0}
49 | m_Modifications: []
50 | m_RemovedComponents: []
51 | m_ParentPrefab: {fileID: 0}
52 | m_RootGameObject: {fileID: 100000}
53 | m_IsPrefabParent: 1
54 |
--------------------------------------------------------------------------------
/unity_plugin/unity_src/Assets/Plugins/OpenIAB/Prefabs/OpenIABEventManager.prefab.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 90e394b0ec6b04c40a2ae2ae5977cd91
3 | NativeFormatImporter:
4 | userData:
5 |
--------------------------------------------------------------------------------
/unity_plugin/unity_src/Assets/Plugins/OpenIAB/Purchase.cs:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright 2012-2014 One Platform Foundation
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | ******************************************************************************/
16 |
17 | namespace OnePF
18 | {
19 | /**
20 | * Represents an in-app billing purchase.
21 | */
22 | public class Purchase
23 | {
24 | ///
25 | /// ITEM_TYPE_INAPP or ITEM_TYPE_SUBS
26 | ///
27 | public string ItemType { get; private set; }
28 | ///
29 | /// A unique order identifier for the transaction. This corresponds to the Google Wallet Order ID.
30 | ///
31 | public string OrderId { get; private set; }
32 | ///
33 | /// The application package from which the purchase originated.
34 | ///
35 | public string PackageName { get; private set; }
36 | ///
37 | /// The item's product identifier. Every item has a product ID, which you must specify in the application's product list on the Google Play Developer Console.
38 | ///
39 | public string Sku { get; private set; }
40 | ///
41 | /// The time the product was purchased, in milliseconds since the epoch (Jan 1, 1970).
42 | ///
43 | public long PurchaseTime { get; private set; }
44 | ///
45 | /// The purchase state of the order. Possible values are 0 (purchased), 1 (canceled), or 2 (refunded).
46 | ///
47 | public int PurchaseState { get; private set; }
48 | ///
49 | /// A developer-specified string that contains supplemental information about an order. You can specify a value for this field when you make a getBuyIntent request.
50 | ///
51 | public string DeveloperPayload { get; private set; }
52 | ///
53 | /// A token that uniquely identifies a purchase for a given item and user pair.
54 | ///
55 | public string Token { get; private set; }
56 | ///
57 | /// JSON sent by the current store
58 | ///
59 | public string OriginalJson { get; private set; }
60 | ///
61 | /// Signature of the JSON string
62 | ///
63 | public string Signature { get; private set; }
64 | ///
65 | /// Current store name
66 | ///
67 | public string AppstoreName { get; private set; }
68 | ///
69 | /// Purchase Receipt of the order (iOS only)
70 | ///
71 | public string Receipt { get; private set;}
72 |
73 | private Purchase()
74 | {
75 | }
76 |
77 | /**
78 | * Create purchase from json string
79 | * @param jsonString data serialized to json
80 | */
81 | public Purchase(string jsonString)
82 | {
83 | var json = new JSON(jsonString);
84 | ItemType = json.ToString("itemType");
85 | OrderId = json.ToString("orderId");
86 | PackageName = json.ToString("packageName");
87 | Sku = json.ToString("sku");
88 | PurchaseTime = json.ToLong("purchaseTime");
89 | PurchaseState = json.ToInt("purchaseState");
90 | DeveloperPayload = json.ToString("developerPayload");
91 | Token = json.ToString("token");
92 | OriginalJson = json.ToString("originalJson");
93 | Signature = json.ToString("signature");
94 | AppstoreName = json.ToString("appstoreName");
95 | Receipt = json.ToString("receipt");
96 | }
97 |
98 | #if UNITY_IOS
99 | public Purchase(JSON json) {
100 | ItemType = json.ToString("itemType");
101 | OrderId = json.ToString("orderId");
102 | Receipt = json.ToString("receipt");
103 | PackageName = json.ToString("packageName");
104 | Sku = json.ToString("sku");
105 | PurchaseTime = json.ToLong("purchaseTime");
106 | PurchaseState = json.ToInt("purchaseState");
107 | DeveloperPayload = json.ToString("developerPayload");
108 | Token = json.ToString("token");
109 | OriginalJson = json.ToString("originalJson");
110 | Signature = json.ToString("signature");
111 | AppstoreName = json.ToString("appstoreName");
112 |
113 | Sku = OpenIAB_iOS.StoreSku2Sku(Sku);
114 | }
115 | #endif
116 |
117 | /**
118 | * For debug purposes and editor mode
119 | * @param sku product ID
120 | */
121 | public static Purchase CreateFromSku(string sku)
122 | {
123 | return CreateFromSku(sku, "");
124 | }
125 |
126 | public static Purchase CreateFromSku(string sku, string developerPayload)
127 | {
128 | var p = new Purchase();
129 | p.Sku = sku;
130 | p.DeveloperPayload = developerPayload;
131 | #if UNITY_IOS
132 | AddIOSHack(p);
133 | #endif
134 | return p;
135 | }
136 |
137 | /**
138 | * ToString
139 | * @return original json
140 | */
141 | public override string ToString()
142 | {
143 | return "SKU:" + Sku + ";" + OriginalJson;
144 | }
145 |
146 | #if UNITY_IOS
147 | private static void AddIOSHack(Purchase p) {
148 | if(string.IsNullOrEmpty(p.AppstoreName)) {
149 | p.AppstoreName = "com.apple.appstore";
150 | }
151 | if(string.IsNullOrEmpty(p.ItemType)) {
152 | p.ItemType = "InApp";
153 | }
154 | if(string.IsNullOrEmpty(p.OrderId)) {
155 | p.OrderId = System.Guid.NewGuid().ToString();
156 | }
157 | }
158 | #endif
159 |
160 | /**
161 | * Serilize to json
162 | * @return json string
163 | */
164 | public string Serialize()
165 | {
166 | var j = new JSON();
167 | j["itemType"] = ItemType;
168 | j["orderId"] = OrderId;
169 | j["packageName"] = PackageName;
170 | j["sku"] = Sku;
171 | j["purchaseTime"] = PurchaseTime;
172 | j["purchaseState"] = PurchaseState;
173 | j["developerPayload"] = DeveloperPayload;
174 | j["token"] = Token;
175 | j["originalJson"] = OriginalJson;
176 | j["signature"] = Signature;
177 | j["appstoreName"] = AppstoreName;
178 | j["receipt"] = Receipt;
179 | return j.serialized;
180 | }
181 | }
182 | }
--------------------------------------------------------------------------------
/unity_plugin/unity_src/Assets/Plugins/OpenIAB/Purchase.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: c3ae1c8b9811acb43bfa20906203afb2
3 | labels:
4 | - inapp
5 | - in-app
6 | - amazon
7 | - google
8 | - samsung
9 | - iap
10 | - Amazon
11 | - Google
12 | - Iap
13 | - In-app
14 | - Inapp
15 | - Samsung
16 | - billing
17 | - appstore
18 | - app-store
19 | - in
20 | - app
21 | - store
22 | - storekit
23 | - android
24 | - ios
25 | - purchase
26 | - onepf
27 | - open
28 | - opensource
29 | - source
30 | MonoImporter:
31 | serializedVersion: 2
32 | defaultReferences: []
33 | executionOrder: 0
34 | icon: {instanceID: 0}
35 | userData:
36 |
--------------------------------------------------------------------------------
/unity_plugin/unity_src/Assets/Plugins/OpenIAB/SearchStrategy.cs:
--------------------------------------------------------------------------------
1 | using UnityEngine;
2 | using System.Collections;
3 |
4 | namespace OnePF
5 | {
6 | public enum SearchStrategy
7 | {
8 | INSTALLER = 0,
9 | BEST_FIT = 1,
10 | INSTALLER_THEN_BEST_FIT = 2
11 | }
12 | }
--------------------------------------------------------------------------------
/unity_plugin/unity_src/Assets/Plugins/OpenIAB/SkuDetails.cs:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright 2012-2014 One Platform Foundation
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | ******************************************************************************/
16 |
17 | using UnityEngine;
18 |
19 | namespace OnePF
20 | {
21 | /**
22 | * Represents an in-app product's listing details.
23 | */
24 | public class SkuDetails
25 | {
26 | public string ItemType { get; private set; }
27 | public string Sku { get; private set; }
28 | public string Type { get; private set; }
29 | public string Price { get; private set; }
30 | public string Title { get; private set; }
31 | public string Description { get; private set; }
32 | public string Json { get; private set; }
33 | public string CurrencyCode { get; private set; }
34 | public string PriceValue { get; private set; }
35 |
36 | // Used for Android
37 | public SkuDetails(string jsonString)
38 | {
39 | var json = new JSON(jsonString);
40 | ItemType = json.ToString("itemType");
41 | Sku = json.ToString("sku");
42 | Type = json.ToString("type");
43 | Price = json.ToString("price");
44 | Title = json.ToString("title");
45 | Description = json.ToString("description");
46 | Json = json.ToString("json");
47 | CurrencyCode = json.ToString("currencyCode");
48 | PriceValue = json.ToString("priceValue");
49 | ParseFromJson();
50 | }
51 |
52 | #if UNITY_IOS
53 | public SkuDetails(JSON json) {
54 | ItemType = json.ToString("itemType");
55 | Sku = json.ToString("sku");
56 | Type = json.ToString("type");
57 | Price = json.ToString("price");
58 | Title = json.ToString("title");
59 | Description = json.ToString("description");
60 | Json = json.ToString("json");
61 | CurrencyCode = json.ToString("currencyCode");
62 | PriceValue = json.ToString("priceValue");
63 |
64 | Sku = OpenIAB_iOS.StoreSku2Sku(Sku);
65 | }
66 | #endif
67 |
68 | #if UNITY_WP8
69 | public SkuDetails(OnePF.WP8.ProductListing listing)
70 | {
71 | Sku = OpenIAB_WP8.GetSku(listing.ProductId);
72 | Title = listing.Name;
73 | Description = listing.Description;
74 | Price = listing.FormattedPrice;
75 | }
76 | #endif
77 |
78 | private void ParseFromJson()
79 | {
80 | if (string.IsNullOrEmpty(Json)) return;
81 | var json = new JSON(Json);
82 | if (string.IsNullOrEmpty(PriceValue))
83 | {
84 | float val = json.ToFloat("price_amount_micros");
85 | val /= 1000000;
86 | PriceValue = val.ToString();
87 | }
88 | if (string.IsNullOrEmpty(CurrencyCode))
89 | CurrencyCode = json.ToString("price_currency_code");
90 | }
91 |
92 | /**
93 | * ToString
94 | * @return formatted string
95 | */
96 | public override string ToString()
97 | {
98 | return string.Format("[SkuDetails: type = {0}, SKU = {1}, title = {2}, price = {3}, description = {4}, priceValue={5}, currency={6}]",
99 | ItemType, Sku, Title, Price, Description, PriceValue, CurrencyCode);
100 | }
101 | }
102 | }
--------------------------------------------------------------------------------
/unity_plugin/unity_src/Assets/Plugins/OpenIAB/SkuDetails.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 05cc5ac966d741f409a884f35f62fa3a
3 | labels:
4 | - inapp
5 | - in-app
6 | - amazon
7 | - google
8 | - samsung
9 | - iap
10 | - Amazon
11 | - Google
12 | - Iap
13 | - In-app
14 | - Inapp
15 | - Samsung
16 | - billing
17 | - appstore
18 | - app-store
19 | - in
20 | - app
21 | - store
22 | - storekit
23 | - android
24 | - ios
25 | - purchase
26 | - onepf
27 | - open
28 | - opensource
29 | - source
30 | MonoImporter:
31 | serializedVersion: 2
32 | defaultReferences: []
33 | executionOrder: 0
34 | icon: {instanceID: 0}
35 | userData:
36 |
--------------------------------------------------------------------------------
/unity_plugin/unity_src/Assets/Plugins/OpenIAB/WP8.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 52ccd8dd81cbd7d4aa0efca50bee9972
3 | folderAsset: yes
4 | DefaultImporter:
5 | userData:
6 |
--------------------------------------------------------------------------------
/unity_plugin/unity_src/Assets/Plugins/OpenIAB/WP8/OpenIAB_WP8.cs:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright 2012-2014 One Platform Foundation
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | ******************************************************************************/
16 |
17 | using UnityEngine;
18 | using System.Collections;
19 | using System.Collections.Generic;
20 | using System;
21 | #if UNITY_WP8
22 | using OnePF.WP8;
23 | #endif
24 |
25 | namespace OnePF
26 | {
27 | /**
28 | * Windows Phone 8 billing implementation
29 | */
30 | public class OpenIAB_WP8
31 | #if UNITY_WP8
32 | : IOpenIAB
33 | #endif
34 | {
35 | public static readonly string STORE = "wp8_store"; /**< Windows Phone store constant */
36 |
37 | #if UNITY_WP8
38 |
39 | static Dictionary _sku2storeSkuMappings = new Dictionary();
40 | static Dictionary _storeSku2skuMappings = new Dictionary();
41 |
42 | public static string GetSku(string storeSku)
43 | {
44 | return _storeSku2skuMappings.ContainsKey(storeSku) ? _storeSku2skuMappings[storeSku] : storeSku;
45 | }
46 |
47 | public static string GetStoreSku(string sku)
48 | {
49 | return _sku2storeSkuMappings.ContainsKey(sku) ? _sku2storeSkuMappings[sku] : sku;
50 | }
51 |
52 | static OpenIAB_WP8()
53 | {
54 | Store.PurchaseSucceeded += (storeSku, payload) =>
55 | {
56 | string sku = GetSku(storeSku);
57 | Purchase purchase = Purchase.CreateFromSku(sku, payload);
58 | OpenIAB.EventManager.SendMessage("OnPurchaseSucceeded", purchase);
59 | };
60 | Store.PurchaseFailed += (error) => { OpenIAB.EventManager.SendMessage("OnPurchaseFailed", error); };
61 |
62 | Store.ConsumeSucceeded += (storeSku) =>
63 | {
64 | string sku = GetSku(storeSku);
65 | Purchase purchase = Purchase.CreateFromSku(sku);
66 | OpenIAB.EventManager.SendMessage("OnConsumePurchaseSucceeded", purchase);
67 | };
68 | Store.ConsumeFailed += (error) => { OpenIAB.EventManager.SendMessage("OnConsumePurchaseFailed", error); };
69 |
70 | Store.LoadListingsSucceeded += (listings) =>
71 | {
72 | Inventory inventory = GetInventory();
73 | foreach (KeyValuePair pair in listings)
74 | {
75 | SkuDetails skuDetails = new SkuDetails(pair.Value);
76 | inventory.AddSkuDetails(skuDetails);
77 | }
78 | OpenIAB.EventManager.SendMessage("OnQueryInventorySucceeded", inventory);
79 | };
80 | Store.LoadListingsFailed += (error) =>
81 | {
82 | OpenIAB.EventManager.SendMessage("OnQueryInventoryFailed", error);
83 | };
84 | }
85 |
86 | private static Inventory GetInventory()
87 | {
88 | var inventory = new Inventory();
89 | var purchasesList = Store.Inventory;
90 | foreach (string storeSku in purchasesList)
91 | {
92 | Purchase purchase = Purchase.CreateFromSku(GetSku(storeSku));
93 | inventory.AddPurchase(purchase);
94 | }
95 | return inventory;
96 | }
97 |
98 | public void init(Options options)
99 | {
100 | OpenIAB.EventManager.SendMessage("OnBillingSupported");
101 | }
102 |
103 | public void mapSku(string sku, string storeName, string storeSku)
104 | {
105 | if (storeName == STORE)
106 | {
107 | _sku2storeSkuMappings[sku] = storeSku;
108 | _storeSku2skuMappings[storeSku] = sku;
109 | }
110 | }
111 |
112 | public void unbindService()
113 | {
114 | }
115 |
116 | public bool areSubscriptionsSupported()
117 | {
118 | return true;
119 | }
120 |
121 | public void queryInventory()
122 | {
123 | OpenIAB.EventManager.SendMessage("OnQueryInventorySucceeded", GetInventory());
124 | }
125 |
126 | public void queryInventory(string[] skus)
127 | {
128 | string[] storeSkus = new string[skus.Length];
129 | for (int i = 0; i < skus.Length; ++i)
130 | storeSkus[i] = GetStoreSku(skus[i]);
131 | Store.LoadListings(storeSkus);
132 | }
133 |
134 | public void purchaseProduct(string sku, string developerPayload = "")
135 | {
136 | string storeSku = GetStoreSku(sku);
137 | Store.PurchaseProduct(storeSku, developerPayload);
138 | }
139 |
140 | public void purchaseSubscription(string sku, string developerPayload = "")
141 | {
142 | purchaseProduct(sku, developerPayload);
143 | }
144 |
145 | public void consumeProduct(Purchase purchase)
146 | {
147 | string storeSku = GetStoreSku(purchase.Sku);
148 | Store.ConsumeProduct(storeSku);
149 | }
150 |
151 | ///
152 | /// Not needed on WP8
153 | ///
154 | public void restoreTransactions()
155 | {
156 | }
157 |
158 | public bool isDebugLog()
159 | {
160 | // TODO: implement in DLL
161 | return false;
162 | }
163 |
164 | public void enableDebugLogging(bool enabled)
165 | {
166 | // TODO: implement in DLL
167 | }
168 |
169 | public void enableDebugLogging(bool enabled, string tag)
170 | {
171 | // TODO: implement in DLL
172 | }
173 | #endif
174 | }
175 | }
--------------------------------------------------------------------------------
/unity_plugin/unity_src/Assets/Plugins/OpenIAB/WP8/OpenIAB_WP8.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 24bee2735a13ca849a24d44b517234d0
3 | MonoImporter:
4 | serializedVersion: 2
5 | defaultReferences: []
6 | executionOrder: 0
7 | icon: {instanceID: 0}
8 | userData:
9 |
--------------------------------------------------------------------------------
/unity_plugin/unity_src/Assets/Plugins/OpenIAB/iOS.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 3273e231fb302e74393238c9c876f853
3 | folderAsset: yes
4 | DefaultImporter:
5 | userData:
6 |
--------------------------------------------------------------------------------
/unity_plugin/unity_src/Assets/Plugins/OpenIAB/iOS/OpenIAB_iOS.cs:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright 2012-2014 One Platform Foundation
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | ******************************************************************************/
16 |
17 | using UnityEngine;
18 | using System.Collections;
19 | using System.Collections.Generic;
20 | using System.Runtime.InteropServices;
21 | using System.Linq;
22 |
23 | namespace OnePF
24 | {
25 | /**
26 | * iOS AppStore billing implentation
27 | */
28 | public class OpenIAB_iOS
29 | #if UNITY_IOS
30 | : IOpenIAB
31 | #endif
32 | {
33 | public static readonly string STORE = "appstore"; /**< AppStore name constant */
34 |
35 | #if UNITY_IOS
36 | #region NativeMethods
37 | [DllImport("__Internal")]
38 | private static extern void AppStore_requestProducts(string[] skus, int skusNumber);
39 |
40 | [DllImport("__Internal")]
41 | private static extern void AppStore_startPurchase(string sku);
42 |
43 | [DllImport("__Internal")]
44 | private static extern void AppStore_restorePurchases();
45 |
46 | [DllImport("__Internal")]
47 | private static extern bool Inventory_hasPurchase(string sku);
48 |
49 | [DllImport("__Internal")]
50 | private static extern void Inventory_query();
51 |
52 | [DllImport("__Internal")]
53 | private static extern void Inventory_removePurchase(string sku);
54 | #endregion
55 |
56 | static Dictionary _sku2storeSkuMappings = new Dictionary();
57 | static Dictionary _storeSku2skuMappings = new Dictionary();
58 |
59 | private bool IsDevice()
60 | {
61 | if (Application.platform != RuntimePlatform.IPhonePlayer)
62 | {
63 | return false;
64 | }
65 | return true;
66 | }
67 |
68 | public void init(Options options)
69 | {
70 | if (!IsDevice()) return;
71 | init(options.storeKeys);
72 | }
73 |
74 | public void init(Dictionary storeKeys = null)
75 | {
76 | if (!IsDevice()) return;
77 |
78 | // Pass identifiers to the StoreKit
79 | string[] identifiers = new string[_sku2storeSkuMappings.Count];
80 | for (int i = 0; i < _sku2storeSkuMappings.Count; ++i)
81 | {
82 | identifiers[i] = _sku2storeSkuMappings.ElementAt(i).Value;
83 | }
84 |
85 | AppStore_requestProducts(identifiers, identifiers.Length);
86 | }
87 |
88 | public void mapSku(string sku, string storeName, string storeSku)
89 | {
90 | if (storeName == STORE)
91 | {
92 | _sku2storeSkuMappings[sku] = storeSku;
93 | _storeSku2skuMappings[storeSku] = sku;
94 | }
95 | }
96 |
97 | public void unbindService()
98 | {
99 | }
100 |
101 | public bool areSubscriptionsSupported()
102 | {
103 | return true;
104 | }
105 |
106 | public void queryInventory()
107 | {
108 | if (!IsDevice())
109 | {
110 | return;
111 | }
112 | Inventory_query();
113 | }
114 |
115 | public void queryInventory(string[] skus)
116 | {
117 | queryInventory();
118 | }
119 |
120 | public void purchaseProduct(string sku, string developerPayload = "")
121 | {
122 | string storeSku = _sku2storeSkuMappings[sku];
123 | if (!IsDevice())
124 | {
125 | // Fake purchase in editor mode
126 | OpenIAB.EventManager.SendMessage("OnPurchaseSucceeded", storeSku);
127 | return;
128 | }
129 |
130 | AppStore_startPurchase(storeSku);
131 | }
132 |
133 | public void purchaseSubscription(string sku, string developerPayload = "")
134 | {
135 | purchaseProduct(sku, developerPayload);
136 | }
137 |
138 |
139 | public void consumeProduct(Purchase purchase)
140 | {
141 | if (!IsDevice())
142 | {
143 | // Fake consume in editor mode
144 | OpenIAB.EventManager.SendMessage("OnConsumePurchaseSucceeded", purchase.Serialize());
145 | return;
146 | }
147 |
148 | var storeSku = OpenIAB_iOS.Sku2StoreSku(purchase.Sku);
149 | if (Inventory_hasPurchase(storeSku))
150 | {
151 | OpenIAB.EventManager.SendMessage("OnConsumePurchaseSucceeded", purchase.Serialize());
152 | Inventory_removePurchase(storeSku);
153 | }
154 | else
155 | {
156 | OpenIAB.EventManager.SendMessage("OnConsumePurchaseFailed", "Purchase not found");
157 | }
158 | }
159 |
160 | public void restoreTransactions()
161 | {
162 | AppStore_restorePurchases();
163 | }
164 |
165 | public bool isDebugLog()
166 | {
167 | return false;
168 | }
169 |
170 | public void enableDebugLogging(bool enabled)
171 | {
172 | }
173 |
174 | public void enableDebugLogging(bool enabled, string tag)
175 | {
176 | }
177 |
178 | public static string StoreSku2Sku(string storeSku)
179 | {
180 | return _storeSku2skuMappings[storeSku];
181 | }
182 |
183 | public static string Sku2StoreSku(string sku)
184 | {
185 | return _sku2storeSkuMappings[sku];
186 | }
187 | #endif
188 | }
189 | }
190 |
--------------------------------------------------------------------------------
/unity_plugin/unity_src/Assets/Plugins/OpenIAB/iOS/OpenIAB_iOS.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e0fdad166734e3840a72593c39a67638
3 | MonoImporter:
4 | serializedVersion: 2
5 | defaultReferences: []
6 | executionOrder: 0
7 | icon: {instanceID: 0}
8 | userData:
9 |
--------------------------------------------------------------------------------
/unity_plugin/unity_src/Assets/Plugins/OpenIAB_W8Plugin.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onepf/OpenIAB-Unity-Plugin/19b1719190dbac24c9240db7e83be820b40a93e5/unity_plugin/unity_src/Assets/Plugins/OpenIAB_W8Plugin.dll
--------------------------------------------------------------------------------
/unity_plugin/unity_src/Assets/Plugins/OpenIAB_W8Plugin.dll.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 19208cfdcc9245f48ad0e374142fdcc7
3 | timeCreated: 1427368186
4 | licenseType: Free
5 | PluginImporter:
6 | serializedVersion: 1
7 | iconMap: {}
8 | executionOrder: {}
9 | isPreloaded: 0
10 | platformData:
11 | Android:
12 | enabled: 0
13 | settings:
14 | CPU: AnyCPU
15 | Any:
16 | enabled: 0
17 | settings: {}
18 | Editor:
19 | enabled: 1
20 | settings:
21 | CPU: AnyCPU
22 | DefaultValueInitialized: true
23 | OS: AnyOS
24 | Linux:
25 | enabled: 0
26 | settings:
27 | CPU: x86
28 | Linux64:
29 | enabled: 0
30 | settings:
31 | CPU: x86_64
32 | OSXIntel:
33 | enabled: 0
34 | settings:
35 | CPU: AnyCPU
36 | OSXIntel64:
37 | enabled: 0
38 | settings:
39 | CPU: AnyCPU
40 | WP8:
41 | enabled: 0
42 | settings:
43 | CPU: AnyCPU
44 | DontProcess: False
45 | PlaceholderPath:
46 | Win:
47 | enabled: 0
48 | settings:
49 | CPU: AnyCPU
50 | Win64:
51 | enabled: 0
52 | settings:
53 | CPU: AnyCPU
54 | WindowsStoreApps:
55 | enabled: 0
56 | settings:
57 | CPU: AnyCPU
58 | DontProcess: False
59 | PlaceholderPath:
60 | SDK: AnySDK
61 | iOS:
62 | enabled: 0
63 | settings:
64 | CompileFlags:
65 | FrameworkDependencies:
66 | userData:
67 | assetBundleName:
68 | assetBundleVariant:
69 |
--------------------------------------------------------------------------------
/unity_plugin/unity_src/Assets/Plugins/OpenIAB_W8Plugin.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onepf/OpenIAB-Unity-Plugin/19b1719190dbac24c9240db7e83be820b40a93e5/unity_plugin/unity_src/Assets/Plugins/OpenIAB_W8Plugin.pdb
--------------------------------------------------------------------------------
/unity_plugin/unity_src/Assets/Plugins/OpenIAB_W8Plugin.pdb.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 5289aa8a84ceb2042b8dffef999af3b3
3 | DefaultImporter:
4 | userData:
5 |
--------------------------------------------------------------------------------
/unity_plugin/unity_src/Assets/Plugins/OpenIAB_manual.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onepf/OpenIAB-Unity-Plugin/19b1719190dbac24c9240db7e83be820b40a93e5/unity_plugin/unity_src/Assets/Plugins/OpenIAB_manual.pdf
--------------------------------------------------------------------------------
/unity_plugin/unity_src/Assets/Plugins/WP8.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 8ad0e7b80ac340d4d8b7c538ab468c73
3 | DefaultImporter:
4 | userData:
5 |
--------------------------------------------------------------------------------
/unity_plugin/unity_src/Assets/Plugins/WP8/OpenIAB_W8Plugin.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onepf/OpenIAB-Unity-Plugin/19b1719190dbac24c9240db7e83be820b40a93e5/unity_plugin/unity_src/Assets/Plugins/WP8/OpenIAB_W8Plugin.dll
--------------------------------------------------------------------------------
/unity_plugin/unity_src/Assets/Plugins/WP8/OpenIAB_W8Plugin.dll.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 45d85ee3d64e8ef4ea1e6163010d8f9f
3 | timeCreated: 1427368189
4 | licenseType: Free
5 | PluginImporter:
6 | serializedVersion: 1
7 | iconMap: {}
8 | executionOrder: {}
9 | isPreloaded: 0
10 | platformData:
11 | Android:
12 | enabled: 0
13 | settings:
14 | CPU: AnyCPU
15 | Any:
16 | enabled: 0
17 | settings: {}
18 | Editor:
19 | enabled: 0
20 | settings:
21 | CPU: AnyCPU
22 | DefaultValueInitialized: true
23 | OS: AnyOS
24 | Linux:
25 | enabled: 0
26 | settings:
27 | CPU: x86
28 | Linux64:
29 | enabled: 0
30 | settings:
31 | CPU: x86_64
32 | OSXIntel:
33 | enabled: 0
34 | settings:
35 | CPU: AnyCPU
36 | OSXIntel64:
37 | enabled: 0
38 | settings:
39 | CPU: AnyCPU
40 | WP8:
41 | enabled: 1
42 | settings:
43 | CPU: AnyCPU
44 | DontProcess: False
45 | PlaceholderPath: Assets/Plugins/OpenIAB_W8Plugin.dll
46 | Win:
47 | enabled: 0
48 | settings:
49 | CPU: AnyCPU
50 | Win64:
51 | enabled: 0
52 | settings:
53 | CPU: AnyCPU
54 | WindowsStoreApps:
55 | enabled: 0
56 | settings:
57 | CPU: AnyCPU
58 | DontProcess: False
59 | PlaceholderPath:
60 | SDK: AnySDK
61 | iOS:
62 | enabled: 0
63 | settings:
64 | CompileFlags:
65 | FrameworkDependencies:
66 | userData:
67 | assetBundleName:
68 | assetBundleVariant:
69 |
--------------------------------------------------------------------------------
/unity_plugin/unity_src/Assets/Plugins/WP8/OpenIAB_W8Plugin.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/onepf/OpenIAB-Unity-Plugin/19b1719190dbac24c9240db7e83be820b40a93e5/unity_plugin/unity_src/Assets/Plugins/WP8/OpenIAB_W8Plugin.pdb
--------------------------------------------------------------------------------
/unity_plugin/unity_src/Assets/Plugins/WP8/OpenIAB_W8Plugin.pdb.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 6a913e4607797054d87da031eb3f7216
3 | DefaultImporter:
4 | userData:
5 |
--------------------------------------------------------------------------------
/unity_plugin/unity_src/Assets/Plugins/iOS.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 00580a8394cbe88489dc735dabae3b61
3 | DefaultImporter:
4 | userData:
5 |
--------------------------------------------------------------------------------
/unity_plugin/unity_src/Assets/Plugins/iOS/AppStoreBridge.mm:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright 2012-2014 One Platform Foundation
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | ******************************************************************************/
16 |
17 | #import "AppStoreDelegate.h"
18 |
19 | /**
20 | * Unity to NS String conversion
21 | * @param c_string original C string
22 | */
23 | NSString* ToString(const char* c_string)
24 | {
25 | return c_string == NULL ? [NSString stringWithUTF8String:""] : [NSString stringWithUTF8String:c_string];
26 | }
27 |
28 | extern "C"
29 | {
30 | /**
31 | * Native 'requestProducts' wrapper
32 | * @param skus product IDs
33 | * @param skuNumber lenght of the 'skus' array
34 | */
35 | void AppStore_requestProducts(const char* skus[], int skuNumber)
36 | {
37 | NSMutableSet *skuSet = [NSMutableSet set];
38 | for (int i = 0; i < skuNumber; ++i)
39 | [skuSet addObject: ToString(skus[i])];
40 | [[AppStoreDelegate instance] requestSKUs:skuSet];
41 | }
42 |
43 | /**
44 | * Native 'startPurchase' wrapper
45 | * @param sku product ID
46 | */
47 | void AppStore_startPurchase(const char* sku)
48 | {
49 | [[AppStoreDelegate instance] startPurchase:ToString(sku)];
50 | }
51 |
52 | /**
53 | * Native 'restorePurchases' wrapper
54 | */
55 | void AppStore_restorePurchases()
56 | {
57 | [[AppStoreDelegate instance] restorePurchases];
58 | }
59 |
60 | /**
61 | * Query inventory
62 | * Restore purchased items
63 | */
64 | void Inventory_query()
65 | {
66 | [[AppStoreDelegate instance] queryInventory];
67 | }
68 |
69 | /**
70 | * Checks if product is purchased
71 | * @param sku product ID
72 | * @return true if product was purchased
73 | */
74 | bool Inventory_hasPurchase(const char* sku)
75 | {
76 | NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults];
77 | if (standardUserDefaults)
78 | {
79 | return [[[standardUserDefaults dictionaryRepresentation] allKeys] containsObject:ToString(sku)];
80 | }
81 | else
82 | {
83 | NSLog(@"Couldn't access purchase storage.");
84 | return false;
85 | }
86 | }
87 |
88 | /**
89 | * Delete purchase information
90 | * @param sku product ID
91 | */
92 | void Inventory_removePurchase(const char* sku)
93 | {
94 | NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults];
95 | if (standardUserDefaults)
96 | {
97 | [standardUserDefaults removeObjectForKey:ToString(sku)];
98 | [standardUserDefaults synchronize];
99 | }
100 | else
101 | {
102 | NSLog(@"Couldn't access standardUserDefaults. Purchase wasn't removed.");
103 | }
104 | }
105 | }
--------------------------------------------------------------------------------
/unity_plugin/unity_src/Assets/Plugins/iOS/AppStoreBridge.mm.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 648bd03bf6f1b4b81b502a1555ba7f81
3 | PluginImporter:
4 | serializedVersion: 1
5 | iconMap: {}
6 | executionOrder: {}
7 | isPreloaded: 0
8 | platformData:
9 | Any:
10 | enabled: 0
11 | settings: {}
12 | Editor:
13 | enabled: 0
14 | settings:
15 | DefaultValueInitialized: true
16 | iOS:
17 | enabled: 1
18 | settings: {}
19 | userData:
20 | assetBundleName:
21 | assetBundleVariant:
22 |
--------------------------------------------------------------------------------
/unity_plugin/unity_src/Assets/Plugins/iOS/AppStoreDelegate.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 |
4 | @interface AppStoreDelegate : NSObject
5 |
6 | /**
7 | * Get instance of the StoreKit delegate
8 | * @return instance of the StoreKit delegate
9 | */
10 | + (AppStoreDelegate*)instance;
11 |
12 | /**
13 | * Request sku listing from the AppStore
14 | * @param skus product IDs
15 | */
16 | - (void)requestSKUs:(NSSet*)skus;
17 |
18 | /**
19 | * Start async purchase process
20 | * @param product ID
21 | */
22 | - (void)startPurchase:(NSString*)sku;
23 |
24 | /**
25 | * Request purchase history
26 | */
27 | - (void)queryInventory;
28 |
29 | /**
30 | * This is required by AppStore.
31 | * Separate button for restoration should be added somewhere in the application
32 | */
33 | - (void)restorePurchases;
34 |
35 | @end
36 |
--------------------------------------------------------------------------------
/unity_plugin/unity_src/Assets/Plugins/iOS/AppStoreDelegate.h.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 07bcd18476ebd478fbcf92354a77684c
3 | PluginImporter:
4 | serializedVersion: 1
5 | iconMap: {}
6 | executionOrder: {}
7 | isPreloaded: 0
8 | platformData:
9 | Any:
10 | enabled: 0
11 | settings: {}
12 | Editor:
13 | enabled: 0
14 | settings:
15 | DefaultValueInitialized: true
16 | iOS:
17 | enabled: 1
18 | settings: {}
19 | userData:
20 | assetBundleName:
21 | assetBundleVariant:
22 |
--------------------------------------------------------------------------------
/unity_plugin/unity_src/Assets/Plugins/iOS/AppStoreDelegate.mm:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright 2012-2014 One Platform Foundation
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | ******************************************************************************/
16 |
17 | #import "AppStoreDelegate.h"
18 | #import
19 |
20 | /**
21 | * Helper method to create C string copy
22 | * By default mono string marshaler creates .Net string for returned UTF-8 C string
23 | * and calls free for returned value, thus returned strings should be allocated on heap
24 | * @param string original C string
25 | */
26 | char* MakeStringCopy(const char* string)
27 | {
28 | if (string == NULL)
29 | return NULL;
30 |
31 | char* res = (char*)malloc(strlen(string) + 1);
32 | strcpy(res, string);
33 | return res;
34 | }
35 |
36 | /**
37 | * It is used to send callbacks to the Unity event handler
38 | * @param objectName name of the target GameObject
39 | * @param methodName name of the handler method
40 | * @param param message string
41 | */
42 | extern void UnitySendMessage(const char* objectName, const char* methodName, const char* param);
43 |
44 | /**
45 | * Name of the event handler object in Unity
46 | */
47 | const char* EventHandler = "OpenIABEventManager";
48 |
49 | @implementation AppStoreDelegate
50 |
51 | // Internal
52 |
53 | /**
54 | * Collection of product identifiers
55 | */
56 | NSSet* m_skus;
57 |
58 | /**
59 | * Map of product listings
60 | * Information is requested from the store
61 | */
62 | NSMutableArray* m_skuMap;
63 |
64 | /**
65 | * Dictionary {sku: product}
66 | */
67 | NSMutableDictionary* m_productMap;
68 |
69 |
70 | - (void)storePurchase:(NSString*)transaction forSku:(NSString*)sku
71 | {
72 | NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults];
73 | if (standardUserDefaults)
74 | {
75 | [standardUserDefaults setObject:transaction forKey:sku];
76 | [standardUserDefaults synchronize];
77 | }
78 | else
79 | NSLog(@"Couldn't access standardUserDefaults. Purchase wasn't stored.");
80 | }
81 |
82 |
83 | // Init
84 |
85 | + (AppStoreDelegate*)instance
86 | {
87 | static AppStoreDelegate* instance = nil;
88 | if (!instance)
89 | instance = [[AppStoreDelegate alloc] init];
90 |
91 | return instance;
92 | }
93 |
94 | - (id)init
95 | {
96 | self = [super init];
97 | [[SKPaymentQueue defaultQueue] addTransactionObserver:self];
98 | return self;
99 | }
100 |
101 | - (void)dealloc
102 | {
103 | [[SKPaymentQueue defaultQueue] removeTransactionObserver:self];
104 | m_skus = nil;
105 | m_skuMap = nil;
106 | m_productMap = nil;
107 | }
108 |
109 |
110 | // Setup
111 |
112 | - (void)requestSKUs:(NSSet*)skus
113 | {
114 | m_skus = skus;
115 | SKProductsRequest *request = [[SKProductsRequest alloc] initWithProductIdentifiers:skus];
116 | request.delegate = self;
117 | [request start];
118 | }
119 |
120 | // Setup handler
121 |
122 | - (void)productsRequest:(SKProductsRequest*)request didReceiveResponse:(SKProductsResponse*)response
123 | {
124 | m_skuMap = [[NSMutableArray alloc] init];
125 | m_productMap = [[NSMutableDictionary alloc] init];
126 |
127 | NSArray* skProducts = response.products;
128 | for (SKProduct * skProduct in skProducts)
129 | {
130 | // Format the price
131 | NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
132 | [numberFormatter setFormatterBehavior:NSNumberFormatterBehavior10_4];
133 | [numberFormatter setNumberStyle:NSNumberFormatterCurrencyStyle];
134 | [numberFormatter setLocale:skProduct.priceLocale];
135 | NSString *formattedPrice = [numberFormatter stringFromNumber:skProduct.price];
136 |
137 | NSLocale *priceLocale = skProduct.priceLocale;
138 | NSString *currencyCode = [priceLocale objectForKey:NSLocaleCurrencyCode];
139 | NSNumber *productPrice = skProduct.price;
140 |
141 | // Setup sku details
142 | NSDictionary* skuDetails = [NSDictionary dictionaryWithObjectsAndKeys:
143 | @"product", @"itemType",
144 | skProduct.productIdentifier, @"sku",
145 | @"product", @"type",
146 | formattedPrice, @"price",
147 | currencyCode, @"currencyCode",
148 | productPrice, @"priceValue",
149 | ([skProduct.localizedTitle length] == 0) ? @"" : skProduct.localizedTitle, @"title",
150 | ([skProduct.localizedDescription length] == 0) ? @"" : skProduct.localizedDescription, @"description",
151 | @"", @"json",
152 | nil];
153 |
154 | NSArray* entry = [NSArray arrayWithObjects:skProduct.productIdentifier, skuDetails, nil];
155 | [m_skuMap addObject:entry];
156 | [m_productMap setObject:skProduct forKey:skProduct.productIdentifier];
157 | }
158 |
159 | UnitySendMessage(EventHandler, "OnBillingSupported", MakeStringCopy(""));
160 | }
161 |
162 | - (void)request:(SKRequest*)request didFailWithError:(NSError*)error
163 | {
164 | UnitySendMessage(EventHandler, "OnBillingNotSupported", MakeStringCopy([[error localizedDescription] UTF8String]));
165 | }
166 |
167 |
168 | // Transactions
169 |
170 | - (void)startPurchase:(NSString*)sku
171 | {
172 | SKProduct* product = m_productMap[sku];
173 | SKMutablePayment *payment = [SKMutablePayment paymentWithProduct:product];
174 | [[SKPaymentQueue defaultQueue] addPayment:payment];
175 | }
176 |
177 | - (void)queryInventory
178 | {
179 | NSMutableDictionary* inventory = [[NSMutableDictionary alloc] init];
180 | NSMutableArray* purchaseMap = [[NSMutableArray alloc] init];
181 | NSUserDefaults* standardUserDefaults = [NSUserDefaults standardUserDefaults];
182 | if (!standardUserDefaults)
183 | NSLog(@"Couldn't access purchase storage. Purchase map won't be available.");
184 | else
185 | for (NSString* sku in m_skus)
186 | if ([[[standardUserDefaults dictionaryRepresentation] allKeys] containsObject:sku])
187 | {
188 | NSString* encodedPurchase = [standardUserDefaults objectForKey:sku];
189 | NSError *e = nil;
190 | NSDictionary* storedPurchase = [NSJSONSerialization JSONObjectWithData:
191 | [encodedPurchase dataUsingEncoding:NSUTF8StringEncoding]
192 | options: NSJSONReadingMutableContainers error: &e];
193 | if (!storedPurchase) {
194 | NSLog(@"Got an error while creating the JSON object: %@", e);
195 | continue;
196 | }
197 |
198 | // TODO: Probably store all purchase information. Not only sku
199 | // Setup purchase
200 | NSDictionary* purchase = [NSDictionary dictionaryWithObjectsAndKeys:
201 | @"product", @"itemType",
202 | [storedPurchase objectForKey:@"orderId"], @"orderId",
203 | [storedPurchase objectForKey:@"receipt"], @"receipt",
204 | @"", @"packageName",
205 | sku, @"sku",
206 | [NSNumber numberWithLong:0], @"purchaseTime",
207 | // TODO: copy constants from Android if ever needed
208 | [NSNumber numberWithInt:0], @"purchaseState",
209 | @"", @"developerPayload",
210 | @"", @"token",
211 | @"", @"originalJson",
212 | @"", @"signature",
213 | @"", @"appstoreName",
214 | nil];
215 |
216 | NSArray* entry = [NSArray arrayWithObjects:sku, purchase, nil];
217 | [purchaseMap addObject:entry];
218 | }
219 |
220 | [inventory setObject:purchaseMap forKey:@"purchaseMap"];
221 | [inventory setObject:m_skuMap forKey:@"skuMap"];
222 |
223 | NSError* error = nil;
224 | NSData* jsonData = [NSJSONSerialization dataWithJSONObject:inventory options:kNilOptions error:&error];
225 | NSString* message = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
226 | UnitySendMessage(EventHandler, "OnQueryInventorySucceeded", MakeStringCopy([message UTF8String]));
227 | }
228 |
229 | - (void)restorePurchases
230 | {
231 | [[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
232 | }
233 |
234 |
235 | // Transactions handler
236 |
237 | - (void)paymentQueue:(SKPaymentQueue *)queue updatedDownloads:(NSArray *)downloads
238 | {
239 | // Required by store protocol
240 | }
241 |
242 | - (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
243 | {
244 | NSString* jsonTransaction;
245 |
246 | for (SKPaymentTransaction *transaction in transactions)
247 | {
248 | switch (transaction.transactionState)
249 | {
250 | case SKPaymentTransactionStatePurchasing:
251 | case SKPaymentTransactionStateDeferred:
252 | break;
253 |
254 | case SKPaymentTransactionStateFailed:
255 | if (transaction.error == nil)
256 | UnitySendMessage(EventHandler, "OnPurchaseFailed", MakeStringCopy("Transaction failed"));
257 | else if (transaction.error.code == SKErrorPaymentCancelled)
258 | UnitySendMessage(EventHandler, "OnPurchaseFailed", MakeStringCopy("Transaction cancelled"));
259 | else
260 | UnitySendMessage(EventHandler, "OnPurchaseFailed", MakeStringCopy([[transaction.error localizedDescription] UTF8String]));
261 | [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
262 | break;
263 |
264 | case SKPaymentTransactionStateRestored:
265 | jsonTransaction = [self convertTransactionToJson:transaction.originalTransaction storeToUserDefaults:true];
266 | if ([jsonTransaction isEqual: @"error"])
267 | {
268 | return;
269 | }
270 |
271 | UnitySendMessage(EventHandler, "OnPurchaseRestored", MakeStringCopy([jsonTransaction UTF8String]));
272 | [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
273 | break;
274 |
275 | case SKPaymentTransactionStatePurchased:
276 | jsonTransaction = [self convertTransactionToJson:transaction storeToUserDefaults:true];
277 | if ([jsonTransaction isEqual: @"error"])
278 | {
279 | return;
280 | }
281 |
282 | UnitySendMessage(EventHandler, "OnPurchaseSucceeded", MakeStringCopy([jsonTransaction UTF8String]));
283 | [[SKPaymentQueue defaultQueue] finishTransaction:transaction];
284 | break;
285 | }
286 | }
287 | }
288 |
289 | - (NSString*)convertTransactionToJson: (SKPaymentTransaction*) transaction storeToUserDefaults:(bool)store
290 | {
291 | //NSURL *receiptURL = [[NSBundle mainBundle] appStoreReceiptURL];
292 | //NSData *receipt = [NSData dataWithContentsOfURL:receiptURL];
293 | //NSString *receiptBase64 = [receipt base64EncodedStringWithOptions:0];
294 |
295 | NSString *receiptBase64 = [transaction.transactionReceipt base64EncodedStringWithOptions:0];
296 |
297 | NSDictionary *requestContents = [NSDictionary dictionaryWithObjectsAndKeys:
298 | transaction.payment.productIdentifier, @"sku",
299 | transaction.transactionIdentifier, @"orderId",
300 | receiptBase64, @"receipt",
301 | nil];
302 |
303 | NSError *error;
304 | NSData *requestData = [NSJSONSerialization dataWithJSONObject:requestContents
305 | options:0
306 | error:&error];
307 | if (!requestData) {
308 | NSLog(@"Got an error while creating the JSON object: %@", error);
309 | return @"error";
310 | }
311 |
312 | NSString * jsonString = [[NSString alloc] initWithData:requestData encoding:NSUTF8StringEncoding];
313 |
314 | if (store){
315 | [self storePurchase:jsonString
316 | forSku:transaction.payment.productIdentifier
317 | ];
318 | }
319 |
320 | return jsonString;
321 | }
322 |
323 | - (void)paymentQueue:(SKPaymentQueue*)queue restoreCompletedTransactionsFailedWithError:(NSError*)error
324 | {
325 | UnitySendMessage(EventHandler, "OnRestoreFailed", MakeStringCopy([[error localizedDescription] UTF8String]));
326 | }
327 |
328 | - (void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue*)queue
329 | {
330 | UnitySendMessage(EventHandler, "OnRestoreFinished", MakeStringCopy(""));
331 | }
332 |
333 | @end
334 |
--------------------------------------------------------------------------------
/unity_plugin/unity_src/Assets/Plugins/iOS/AppStoreDelegate.mm.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 3a4dadbd5b5d1431a8a972257a83d498
3 | PluginImporter:
4 | serializedVersion: 1
5 | iconMap: {}
6 | executionOrder: {}
7 | isPreloaded: 0
8 | platformData:
9 | Any:
10 | enabled: 0
11 | settings: {}
12 | Editor:
13 | enabled: 0
14 | settings:
15 | DefaultValueInitialized: true
16 | iOS:
17 | enabled: 1
18 | settings: {}
19 | userData:
20 | assetBundleName:
21 | assetBundleVariant:
22 |
--------------------------------------------------------------------------------
/unity_plugin/unity_src/unity_src.userprefs:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/unity_plugin/wp8_dll_src/EditorDLL/EditorDLL.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {97A377FA-5E62-4995-814B-F32EB417434A}
8 | Library
9 | Properties
10 | OpenIAB_W8Plugin
11 | OpenIAB_W8Plugin
12 | v3.5
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | ..\..\unity_src\Assets\Plugins\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 |
24 |
25 | pdbonly
26 | true
27 | ..\..\unity_src\Assets\Plugins\
28 | TRACE
29 | prompt
30 | 4
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
45 |
--------------------------------------------------------------------------------
/unity_plugin/wp8_dll_src/EditorDLL/ProductListing.cs:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright 2012-2014 One Platform Foundation
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | ******************************************************************************/
16 |
17 | namespace OnePF.WP8
18 | {
19 | // Summary:
20 | // Provides localized info about an in-app offer in your app.
21 | public sealed class ProductListing
22 | {
23 | public ProductListing(
24 | string productId,
25 | string name,
26 | string description,
27 | string formattedPrice)
28 | {
29 | ProductId = productId;
30 | Name = name;
31 | Description = description;
32 | FormattedPrice = formattedPrice;
33 | }
34 |
35 | // Summary:
36 | // Gets the description for the product.
37 | //
38 | // Returns:
39 | // The description for the product.
40 | public string Description { get; private set; }
41 | //
42 | // Summary:
43 | // Gets the app's purchase price with the appropriate formatting for the current
44 | // market.
45 | //
46 | // Returns:
47 | // The app's purchase price with the appropriate formatting for the current
48 | // market.
49 | public string FormattedPrice { get; private set; }
50 | //
51 | // Summary:
52 | // Gets the descriptive name of the product or feature that can be shown to
53 | // customers in the current market.
54 | //
55 | // Returns:
56 | // The feature's descriptive name as it is seen by customers in the current
57 | // market.
58 | public string Name { get; private set; }
59 | //
60 | // Summary:
61 | // Gets the ID of an app's feature or product.
62 | //
63 | // Returns:
64 | // The ID of an app's feature.
65 | public string ProductId { get; private set; }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/unity_plugin/wp8_dll_src/EditorDLL/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 | using System.Resources;
5 |
6 | // General Information about an assembly is controlled through the following
7 | // set of attributes. Change these attribute values to modify the information
8 | // associated with an assembly.
9 | [assembly: AssemblyTitle("OpenIAB_W8Plugin")]
10 | [assembly: AssemblyDescription("")]
11 | [assembly: AssemblyConfiguration("")]
12 | [assembly: AssemblyCompany("OnePF")]
13 | [assembly: AssemblyProduct("OpenIAB_W8Plugin")]
14 | [assembly: AssemblyCopyright("Copyright © 2014")]
15 | [assembly: AssemblyTrademark("")]
16 | [assembly: AssemblyCulture("")]
17 |
18 | // Setting ComVisible to false makes the types in this assembly not visible
19 | // to COM components. If you need to access a type in this assembly from
20 | // COM, set the ComVisible attribute to true on that type.
21 | [assembly: ComVisible(false)]
22 |
23 | // The following GUID is for the ID of the typelib if this project is exposed to COM
24 | [assembly: Guid("e119f8a2-9eca-4fa7-a6a8-17579045c727")]
25 |
26 | // Version information for an assembly consists of the following four values:
27 | //
28 | // Major Version
29 | // Minor Version
30 | // Build Number
31 | // Revision
32 | //
33 | // You can specify all the values or you can default the Build and Revision Numbers
34 | // by using the '*' as shown below:
35 | // [assembly: AssemblyVersion("1.0.*")]
36 | [assembly: AssemblyVersion("1.0.0.0")]
37 | [assembly: AssemblyFileVersion("1.0.0.0")]
38 | [assembly: NeutralResourcesLanguageAttribute("")]
39 |
--------------------------------------------------------------------------------
/unity_plugin/wp8_dll_src/EditorDLL/Store.cs:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright 2012-2014 One Platform Foundation
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | ******************************************************************************/
16 |
17 | using System.Collections.Generic;
18 | using System;
19 |
20 | namespace OnePF.WP8
21 | {
22 | public class Store
23 | {
24 | public static event Action> LoadListingsSucceeded;
25 | public static event Action LoadListingsFailed;
26 | public static event Action PurchaseSucceeded;
27 | public static event Action PurchaseFailed;
28 | public static event Action ConsumeSucceeded;
29 | public static event Action ConsumeFailed;
30 |
31 | public static IEnumerable Inventory { get { return new List(); } }
32 |
33 | public static void LoadListings(string[] productIds)
34 | {
35 | if (LoadListingsSucceeded != null)
36 | LoadListingsSucceeded(new Dictionary());
37 | }
38 |
39 | public static void PurchaseProduct(string productId, string developerPayload)
40 | {
41 | if (PurchaseSucceeded != null)
42 | PurchaseSucceeded(productId, developerPayload);
43 | }
44 |
45 | public static void ConsumeProduct(string productId)
46 | {
47 | if (ConsumeSucceeded != null)
48 | ConsumeSucceeded(productId);
49 | }
50 | }
51 | }
52 |
53 |
--------------------------------------------------------------------------------
/unity_plugin/wp8_dll_src/RealDLL/HResult.cs:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright 2012-2014 One Platform Foundation
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | ******************************************************************************/
16 |
17 | namespace OnePF.WP8
18 | {
19 | public enum HResult : uint
20 | {
21 | S_OK = 0x00000000,
22 | E_FAIL = 0x80004005,
23 | E_UNEXPECTED = 0x8000FFFF,
24 | E_404 = 0x805A0194
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/unity_plugin/wp8_dll_src/RealDLL/ProductListing.cs:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright 2012-2014 One Platform Foundation
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | ******************************************************************************/
16 |
17 | namespace OnePF.WP8
18 | {
19 | // Summary:
20 | // Provides localized info about an in-app offer in your app.
21 | public sealed class ProductListing
22 | {
23 | public ProductListing(
24 | string productId,
25 | string name,
26 | string description,
27 | string formattedPrice)
28 | {
29 | ProductId = productId;
30 | Name = name;
31 | Description = description;
32 | FormattedPrice = formattedPrice;
33 | }
34 |
35 | // Summary:
36 | // Gets the description for the product.
37 | //
38 | // Returns:
39 | // The description for the product.
40 | public string Description { get; private set; }
41 | //
42 | // Summary:
43 | // Gets the app's purchase price with the appropriate formatting for the current
44 | // market.
45 | //
46 | // Returns:
47 | // The app's purchase price with the appropriate formatting for the current
48 | // market.
49 | public string FormattedPrice { get; private set; }
50 | //
51 | // Summary:
52 | // Gets the descriptive name of the product or feature that can be shown to
53 | // customers in the current market.
54 | //
55 | // Returns:
56 | // The feature's descriptive name as it is seen by customers in the current
57 | // market.
58 | public string Name { get; private set; }
59 | //
60 | // Summary:
61 | // Gets the ID of an app's feature or product.
62 | //
63 | // Returns:
64 | // The ID of an app's feature.
65 | public string ProductId { get; private set; }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/unity_plugin/wp8_dll_src/RealDLL/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 | using System.Resources;
5 |
6 | // General Information about an assembly is controlled through the following
7 | // set of attributes. Change these attribute values to modify the information
8 | // associated with an assembly.
9 | [assembly: AssemblyTitle("OpenIAB_W8Plugin")]
10 | [assembly: AssemblyDescription("")]
11 | [assembly: AssemblyConfiguration("")]
12 | [assembly: AssemblyCompany("OnePF")]
13 | [assembly: AssemblyProduct("OpenIAB_W8Plugin")]
14 | [assembly: AssemblyCopyright("Copyright © 2014")]
15 | [assembly: AssemblyTrademark("")]
16 | [assembly: AssemblyCulture("")]
17 |
18 | // Setting ComVisible to false makes the types in this assembly not visible
19 | // to COM components. If you need to access a type in this assembly from
20 | // COM, set the ComVisible attribute to true on that type.
21 | [assembly: ComVisible(false)]
22 |
23 | // The following GUID is for the ID of the typelib if this project is exposed to COM
24 | [assembly: Guid("b1ea264e-c60a-4e58-af77-cc7c20c0678e")]
25 |
26 | // Version information for an assembly consists of the following four values:
27 | //
28 | // Major Version
29 | // Minor Version
30 | // Build Number
31 | // Revision
32 | //
33 | // You can specify all the values or you can default the Revision and Build Numbers
34 | // by using the '*' as shown below:
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 | [assembly: NeutralResourcesLanguageAttribute("en-US")]
38 |
--------------------------------------------------------------------------------
/unity_plugin/wp8_dll_src/RealDLL/RealDLL.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 10.0.20506
7 | 2.0
8 | {B1EA264E-C60A-4E58-AF77-CC7C20C0678E}
9 | {C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}
10 | Library
11 | Properties
12 | OpenIAB_W8Plugin
13 | OpenIAB_W8Plugin
14 | WindowsPhone
15 | v8.0
16 | $(TargetFrameworkVersion)
17 | false
18 | true
19 | 11.0
20 | true
21 |
22 |
23 | true
24 | full
25 | false
26 | ..\..\unity_src\Assets\Plugins\WP8\
27 | DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE
28 | true
29 | true
30 | prompt
31 | 4
32 |
33 |
34 |
35 |
36 | pdbonly
37 | true
38 | ..\..\unity_src\Assets\Plugins\WP8\
39 | TRACE;SILVERLIGHT;WINDOWS_PHONE
40 | true
41 | true
42 | prompt
43 | 4
44 |
45 |
46 | true
47 | full
48 | false
49 | Bin\x86\Debug
50 | DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE
51 | true
52 | true
53 | prompt
54 | 4
55 |
56 |
57 | pdbonly
58 | true
59 | Bin\x86\Release
60 | TRACE;SILVERLIGHT;WINDOWS_PHONE
61 | true
62 | true
63 | prompt
64 | 4
65 |
66 |
67 | true
68 | full
69 | false
70 | Bin\ARM\Debug
71 | DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE
72 | true
73 | true
74 | prompt
75 | 4
76 |
77 |
78 | pdbonly
79 | true
80 | Bin\ARM\Release
81 | TRACE;SILVERLIGHT;WINDOWS_PHONE
82 | true
83 | true
84 | prompt
85 | 4
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
103 |
--------------------------------------------------------------------------------
/unity_plugin/wp8_dll_src/RealDLL/Store.cs:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright 2012-2014 One Platform Foundation
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | ******************************************************************************/
16 |
17 | using System;
18 | using Windows.ApplicationModel.Store;
19 | using System.Collections.Generic;
20 | using System.Linq;
21 | using System.Threading.Tasks;
22 | using Windows.Foundation;
23 | using System.Windows.Threading;
24 | using System.Windows;
25 |
26 | namespace OnePF.WP8
27 | {
28 | public class Store
29 | {
30 | public static event Action> LoadListingsSucceeded;
31 | public static event Action LoadListingsFailed;
32 | public static event Action PurchaseSucceeded;
33 | public static event Action PurchaseFailed;
34 | public static event Action ConsumeSucceeded;
35 | public static event Action ConsumeFailed;
36 |
37 | static string GetErrorDescription(Exception exception)
38 | {
39 | string errorMessage;
40 | switch ((HResult) exception.HResult)
41 | {
42 | case HResult.E_FAIL:
43 | errorMessage = "Purchase cancelled";
44 | break;
45 | case HResult.E_404:
46 | errorMessage = "Not found";
47 | break;
48 | default:
49 | errorMessage = exception.Message;
50 | break;
51 | }
52 | return errorMessage;
53 | }
54 |
55 | public static IEnumerable Inventory
56 | {
57 | get
58 | {
59 | List productLicensesList = new List();
60 | IReadOnlyDictionary productLicenses = CurrentApp.LicenseInformation.ProductLicenses;
61 | if (productLicenses != null)
62 | foreach (var pl in productLicenses.Values)
63 | if (pl.IsActive)
64 | productLicensesList.Add(pl.ProductId);
65 | return productLicensesList;
66 | }
67 | }
68 |
69 | public static void LoadListings(string[] productIds)
70 | {
71 | Deployment.Current.Dispatcher.BeginInvoke(() =>
72 | {
73 | Dictionary resultListings = new Dictionary();
74 | IAsyncOperation asyncOp;
75 | try
76 | {
77 | asyncOp = CurrentApp.LoadListingInformationByProductIdsAsync(productIds);
78 | }
79 | catch(Exception e)
80 | {
81 | if (LoadListingsFailed != null)
82 | LoadListingsFailed(GetErrorDescription(e));
83 | return;
84 | }
85 |
86 | asyncOp.Completed = (op, status) =>
87 | {
88 | if (op.Status == AsyncStatus.Error)
89 | {
90 | if (LoadListingsFailed != null)
91 | LoadListingsFailed(GetErrorDescription(op.ErrorCode));
92 | return;
93 | }
94 |
95 | if (op.Status == AsyncStatus.Canceled)
96 | {
97 | if (LoadListingsFailed != null)
98 | LoadListingsFailed("QueryInventory was cancelled");
99 | return;
100 | }
101 |
102 | var listings = op.GetResults();
103 | foreach (var l in listings.ProductListings)
104 | {
105 | var listing = l.Value;
106 | var resultListing = new ProductListing(
107 | listing.ProductId,
108 | listing.Name,
109 | listing.Description,
110 | listing.FormattedPrice);
111 | resultListings[l.Key] = resultListing;
112 | }
113 | if (LoadListingsSucceeded != null)
114 | LoadListingsSucceeded(resultListings);
115 | };
116 | });
117 | }
118 |
119 | public static void PurchaseProduct(string productId, string developerPayload)
120 | {
121 | Deployment.Current.Dispatcher.BeginInvoke(() =>
122 | {
123 | // Kick off purchase; don't ask for a receipt when it returns
124 | IAsyncOperation asyncOp;
125 | try
126 | {
127 | asyncOp = CurrentApp.RequestProductPurchaseAsync(productId, false);
128 | }
129 | catch (Exception e)
130 | {
131 | if (PurchaseFailed != null)
132 | PurchaseFailed(GetErrorDescription(e));
133 | return;
134 | }
135 |
136 | asyncOp.Completed = (op, status) =>
137 | {
138 | if (op.Status == AsyncStatus.Error)
139 | {
140 | if (PurchaseFailed != null)
141 | PurchaseFailed(GetErrorDescription(op.ErrorCode));
142 | return;
143 | }
144 |
145 | if (op.Status == AsyncStatus.Canceled)
146 | {
147 | if (PurchaseFailed != null)
148 | PurchaseFailed("Purchase was cancelled");
149 | return;
150 | }
151 |
152 | string errorMessage;
153 | ProductLicense productLicense = null;
154 | if (CurrentApp.LicenseInformation.ProductLicenses.TryGetValue(productId, out productLicense))
155 | {
156 | if (productLicense.IsActive)
157 | {
158 | if (PurchaseSucceeded != null)
159 | PurchaseSucceeded(productId, developerPayload);
160 | return;
161 | }
162 | else
163 | {
164 | errorMessage = op.ErrorCode.Message;
165 | }
166 | }
167 | else
168 | {
169 | errorMessage = op.ErrorCode.Message;
170 | }
171 |
172 | if (PurchaseFailed != null)
173 | PurchaseFailed(errorMessage);
174 | };
175 | });
176 | }
177 |
178 | public static void ConsumeProduct(string productId)
179 | {
180 | Deployment.Current.Dispatcher.BeginInvoke(() =>
181 | {
182 | try
183 | {
184 | CurrentApp.ReportProductFulfillment(productId);
185 | }
186 | catch (Exception e)
187 | {
188 | if (ConsumeFailed != null)
189 | ConsumeFailed(e.Message);
190 | return;
191 | }
192 | if (ConsumeSucceeded != null)
193 | ConsumeSucceeded(productId);
194 | });
195 | }
196 | }
197 | }
198 |
--------------------------------------------------------------------------------
/unity_plugin/wp8_dll_src/UnityW8Plugin.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2013
4 | VisualStudioVersion = 12.0.21005.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RealDLL", "RealDLL\RealDLL.csproj", "{B1EA264E-C60A-4E58-AF77-CC7C20C0678E}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EditorDLL", "EditorDLL\EditorDLL.csproj", "{97A377FA-5E62-4995-814B-F32EB417434A}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Debug|ARM = Debug|ARM
14 | Debug|x86 = Debug|x86
15 | Release|Any CPU = Release|Any CPU
16 | Release|ARM = Release|ARM
17 | Release|x86 = Release|x86
18 | EndGlobalSection
19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
20 | {B1EA264E-C60A-4E58-AF77-CC7C20C0678E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {B1EA264E-C60A-4E58-AF77-CC7C20C0678E}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {B1EA264E-C60A-4E58-AF77-CC7C20C0678E}.Debug|ARM.ActiveCfg = Debug|ARM
23 | {B1EA264E-C60A-4E58-AF77-CC7C20C0678E}.Debug|ARM.Build.0 = Debug|ARM
24 | {B1EA264E-C60A-4E58-AF77-CC7C20C0678E}.Debug|x86.ActiveCfg = Debug|x86
25 | {B1EA264E-C60A-4E58-AF77-CC7C20C0678E}.Debug|x86.Build.0 = Debug|x86
26 | {B1EA264E-C60A-4E58-AF77-CC7C20C0678E}.Release|Any CPU.ActiveCfg = Release|Any CPU
27 | {B1EA264E-C60A-4E58-AF77-CC7C20C0678E}.Release|Any CPU.Build.0 = Release|Any CPU
28 | {B1EA264E-C60A-4E58-AF77-CC7C20C0678E}.Release|ARM.ActiveCfg = Release|ARM
29 | {B1EA264E-C60A-4E58-AF77-CC7C20C0678E}.Release|ARM.Build.0 = Release|ARM
30 | {B1EA264E-C60A-4E58-AF77-CC7C20C0678E}.Release|x86.ActiveCfg = Release|x86
31 | {B1EA264E-C60A-4E58-AF77-CC7C20C0678E}.Release|x86.Build.0 = Release|x86
32 | {97A377FA-5E62-4995-814B-F32EB417434A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
33 | {97A377FA-5E62-4995-814B-F32EB417434A}.Debug|Any CPU.Build.0 = Debug|Any CPU
34 | {97A377FA-5E62-4995-814B-F32EB417434A}.Debug|ARM.ActiveCfg = Debug|Any CPU
35 | {97A377FA-5E62-4995-814B-F32EB417434A}.Debug|x86.ActiveCfg = Debug|Any CPU
36 | {97A377FA-5E62-4995-814B-F32EB417434A}.Release|Any CPU.ActiveCfg = Release|Any CPU
37 | {97A377FA-5E62-4995-814B-F32EB417434A}.Release|Any CPU.Build.0 = Release|Any CPU
38 | {97A377FA-5E62-4995-814B-F32EB417434A}.Release|ARM.ActiveCfg = Release|Any CPU
39 | {97A377FA-5E62-4995-814B-F32EB417434A}.Release|x86.ActiveCfg = Release|Any CPU
40 | EndGlobalSection
41 | GlobalSection(SolutionProperties) = preSolution
42 | HideSolutionNode = FALSE
43 | EndGlobalSection
44 | EndGlobal
45 |
--------------------------------------------------------------------------------