質問編集履歴

3

さらに詳細を追加

2018/03/30 12:20

投稿

OGR_toast
OGR_toast

スコア16

test CHANGED
File without changes
test CHANGED
@@ -20,7 +20,9 @@
20
20
 
21
21
  わからない点
22
22
 
23
- ・必要な名前空間
23
+ ・必要な名前空間(UnityEngine.Purchasingでしょうか?)
24
+
25
+ ・引数Eはクラス(構造体?)のように見えますがどのようにこの変数を取得(宣言?)するかわかりません。[参考](https://docs.unity3d.com/jp/540/ScriptReference/Purchasing.Product.html)
24
26
 
25
27
  ・[この例のスクリプト](https://docs.unity3d.com/ja/530/Manual/UnityIAPValidatingReceipts.html)をどこに書けばいいのかわからないです。
26
28
 

2

追記

2018/03/30 12:20

投稿

OGR_toast
OGR_toast

スコア16

test CHANGED
File without changes
test CHANGED
@@ -14,4 +14,138 @@
14
14
 
15
15
  [購入レシート-Unity マニュアル](https://docs.unity3d.com/ja/current/Manual/UnityIAPPurchaseReceipts.html)
16
16
 
17
+
18
+
19
+
20
+
21
+ わからない点
22
+
23
+ ・必要な名前空間
24
+
17
- [レシー検証-Unity マニュアル](https://docs.unity3d.com/ja/530/Manual/UnityIAPValidatingReceipts.html)
25
+ [この例のスクリプト](https://docs.unity3d.com/ja/530/Manual/UnityIAPValidatingReceipts.html)をどこに書けばいいのかわからないです。
26
+
27
+
28
+
29
+ public class スクリプト名 : MonoBehaviour{この中には書けない}
30
+
31
+ ので、どうすればいいのか困っています。
32
+
33
+ ```C#
34
+
35
+ public PurchaseProcessingResult ProcessPurchase (PurchaseEventArgs e)
36
+
37
+ {
38
+
39
+ bool validPurchase = true; // Presume valid for platforms with no R.V.
40
+
41
+
42
+
43
+ // Unity IAP's validation logic is only included on these platforms.
44
+
45
+ #if UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX
46
+
47
+ // Prepare the validator with the secrets we prepared in the Editor
48
+
49
+ // obfuscation window.
50
+
51
+ var validator = new CrossPlatformValidator(GooglePlayTangle.Data(),
52
+
53
+ AppleTangle.Data(), Application.bundleIdentifier);
54
+
55
+
56
+
57
+ try {
58
+
59
+ // On Google Play, result will have a single product Id.
60
+
61
+ // On Apple stores receipts contain multiple products.
62
+
63
+ var result = validator.Validate(e.purchasedProduct.receipt);
64
+
65
+ // For informational purposes, we list the receipt(s)
66
+
67
+ Debug.Log("Receipt is valid. Contents:");
68
+
69
+ foreach (IPurchaseReceipt productReceipt in result) {
70
+
71
+ Debug.Log(productReceipt.productID);
72
+
73
+ Debug.Log(productReceipt.purchaseDate);
74
+
75
+ Debug.Log(productReceipt.transactionID);
76
+
77
+ }
78
+
79
+ } catch (IAPSecurityException) {
80
+
81
+ Debug.Log("Invalid receipt, not unlocking content");
82
+
83
+ validPurchase = false;
84
+
85
+ }
86
+
87
+ #endif
88
+
89
+
90
+
91
+ if (validPurchase) {
92
+
93
+ // Unlock the appropriate content here.
94
+
95
+ }
96
+
97
+
98
+
99
+ return PurchaseProcessingResult.Complete;
100
+
101
+ }
102
+
103
+ ```
104
+
105
+
106
+
107
+ また、こちらはもどこの関数に入れればいいかわかりません。
108
+
109
+ ```C#
110
+
111
+ var result = validator.Validate(e.purchasedProduct.receipt);
112
+
113
+ Debug.Log("Receipt is valid. Contents:");
114
+
115
+ foreach (IPurchaseReceipt productReceipt in result) {
116
+
117
+ Debug.Log(productReceipt.productID);
118
+
119
+ Debug.Log(productReceipt.purchaseDate);
120
+
121
+ Debug.Log(productReceipt.transactionID);
122
+
123
+
124
+
125
+ GooglePlayReceipt google = productReceipt as GooglePlayReceipt;
126
+
127
+ if (null != google) {
128
+
129
+ Debug.Log(google.purchaseState);
130
+
131
+ Debug.Log(google.purchaseToken);
132
+
133
+ }
134
+
135
+
136
+
137
+ AppleInAppPurchaseReceipt apple = productReceipt as AppleInAppPurchaseReceipt;
138
+
139
+ if (null != apple) {
140
+
141
+ Debug.Log(apple.originalTransactionIdentifier);
142
+
143
+ Debug.Log(apple.cancellationDate);
144
+
145
+ Debug.Log(apple.quantity);
146
+
147
+ }
148
+
149
+ }
150
+
151
+ ```

1

追記

2018/03/30 12:09

投稿

OGR_toast
OGR_toast

スコア16

test CHANGED
File without changes
test CHANGED
@@ -1,6 +1,6 @@
1
1
  unityでAndoroid向けに作っているゲームにadmobの広告を実装しているのですが、広告消去機能を購入したかどうか確認するためのレシート検証処理の作り方がunity公式のドキュメントを見てもよくわかりません。
2
2
 
3
- 課金機能にはUnity IAPを使用しています。
3
+ 課金機能にはUnity IAPのIAPButtonを使用しています。
4
4
 
5
5
  また、レシート検証のためのサーバーは必須なのでしょうか?
6
6