iFun Engine API  1.0.0-b6053
Great Technology for Great Games
billing.h
Go to the documentation of this file.
1 // Copyright (C) 2013-2020 iFunFactory Inc. All Rights Reserved.
2 //
3 // This work is confidential and proprietary to iFunFactory Inc. and
4 // must not be used, disclosed, copied, or distributed without the prior
5 // consent of iFunFactory Inc.
6 
9 #ifndef INCLUDE_FUNAPI_SERVICE_BILLING_H_
10 #define INCLUDE_FUNAPI_SERVICE_BILLING_H_
11 
12 #include <funapi/player_account.h>
13 #include <funapi/types.h>
14 
15 #include <vector>
16 
17 
18 namespace fun {
19 
20 typedef string Receipt;
21 
22 FUNAPI_DLL_VISIBILITY
23 Receipt MakeGooglePlayReceipt(const string &package_name,
24  const string &product_id,
25  const string &purchase_token);
26 
27 FUNAPI_DLL_VISIBILITY
28 Receipt MakeAppleAppStoreReceipt(const string &receipt_data,
29  const string &product_id,
30  int64_t quantity);
31 
32 FUNAPI_DLL_VISIBILITY
33 Receipt MakeOneStoreReceipt(const string &txid,
34  const string &appid,
35  const string &signdata,
36  const std::vector<string> &products,
37  bool use_one_store_test_server);
38 FUNAPI_DLL_VISIBILITY
39 Receipt MakeOneStoreReceiptV5(const string &purchase_id,
40  const string &package_name,
41  const string &product_id);
42 
43 FUNAPI_DLL_VISIBILITY
44 DEPRECATED(Receipt MakeTStoreReceipt(const string &txid,
45  const string &appid,
46  const string &signdata,
47  const std::vector<string> &products,
48  bool use_tstore_test_server));
49 
50 /* 'service_provider' must be one of the following values:
51  * 'GooglePlay', 'AppleAppStore', 'TStore', 'Nemg' */
52 struct FUNAPI_DLL_VISIBILITY ReceiptValidationRequest {
54  const string &service_provider,
55  const string &id,
56  const Receipt &receipt);
57 
58  PlayerAccount player_account;
59  Receipt receipt;
60 };
61 
62 
63 enum ReceiptValidationResponse {
64  kSuccess = 0,
65  kFailAlreadyProvisioned = 1000,
66  kFailWrongReceipt = 1001,
67  kFailWrongServiceProvider = 1002,
68  kFailNotAuthenticatedServiceProvider = 1003,
69  kFailCancelledReceipt = 1004,
70  kFailAuthenticationRequired = 1005,
71  kFailProductInformationNotFound = 1006,
72  kFailPendingReceipt = 1007,
73  kBillingSystemError = 2000
74 };
75 
76 
77 typedef function<void(const ReceiptValidationRequest &request,
78  const ReceiptValidationResponse &response,
79  const bool &error)> BillingResponseHandler;
80 
81 typedef function<void(const ReceiptValidationRequest &request,
82  const ReceiptValidationResponse &response,
83  const std::vector<string> &transaction_ids,
84  const bool &error)> BillingResponseHandler2;
85 
86 FUNAPI_DLL_VISIBILITY
87 void ValidateReceipt(const ReceiptValidationRequest &request,
88  const BillingResponseHandler &handler);
89 
90 FUNAPI_DLL_VISIBILITY
91 void ValidateReceipt2(const ReceiptValidationRequest &request,
92  const BillingResponseHandler2 &handler);
93 
94 FUNAPI_DLL_VISIBILITY
95 bool ValidateReceiptSync(const ReceiptValidationRequest &request,
96  ReceiptValidationResponse *response);
97 
98 FUNAPI_DLL_VISIBILITY
99 bool ValidateReceiptSync2(const ReceiptValidationRequest &request,
100  ReceiptValidationResponse *response,
101  std::vector<string> *transaction_ids);
102 
103 } // namespace fun
104 
105 #endif // INCLUDE_FUNAPI_SERVICE_BILLING_H_
Definition: billing.h:52
Account Id.
Definition: player_account.h:20
Definition: json.h:18