forked from godotengine/godot-demo-projects
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPurchase.cs
74 lines (69 loc) · 2.54 KB
/
Purchase.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
using System;
using Godot;
using Godot.Collections;
namespace AndroidInAppPurchasesWithCSharp.GodotGooglePlayBilling
{
// https://developer.android.com/reference/com/android/billingclient/api/Purchase.PurchaseState
public enum PurchaseState
{
UnspecifiedState = 0,
Purchased = 1,
Pending = 2,
}
public partial class Purchase
{
public Purchase() { }
public Purchase(Dictionary purchase)
{
foreach (var key in purchase.Keys)
{
try
{
switch (key.AsString())
{
case "order_id":
OrderId = (string)purchase[key];
break;
case "package_name":
PackageName = (string)purchase[key];
break;
case "purchase_state":
PurchaseState = purchase[key].As<PurchaseState>();
break;
case "purchase_time":
PurchaseTime = Convert.ToInt64(purchase[key]);
break;
case "purchase_token":
PurchaseToken = (string)purchase[key];
break;
case "signature":
Signature = (string)purchase[key];
break;
case "sku":
Sku = (string)purchase[key];
break;
case "is_acknowledged":
IsAcknowledged = (bool)purchase[key];
break;
case "is_auto_renewing":
IsAutoRenewing = (bool)purchase[key];
break;
}
}
catch (System.Exception ex)
{
GD.Print("Error: ", purchase[key], " -> ", ex.ToString());
}
}
}
public string OrderId { get; set; }
public string PackageName { get; set; }
public PurchaseState PurchaseState { get; set; }
public long PurchaseTime { get; set; }
public string PurchaseToken { get; set; }
public string Signature { get; set; }
public string Sku { get; set; }
public bool IsAcknowledged { get; set; }
public bool IsAutoRenewing { get; set; }
}
}