BLRInAppPurchase  1.0.0
BLRInAppPurchase.h
Go to the documentation of this file.
1 #ifndef BLURRR_IN_APP_PURCHASE_H
2 #define BLURRR_IN_APP_PURCHASE_H
3 
4 
5 #if defined(__cplusplus)
6 extern "C" {
7 #endif
8 
9 
10 #ifndef DOXYGEN_SHOULD_IGNORE_THIS
11 
13  /* Note: For Doxygen to produce clean output, you should set the
14  * PREDEFINED option to remove DECLSPEC, CALLCONVENTION, and
15  * the DOXYGEN_SHOULD_IGNORE_THIS blocks.
16  * PREDEFINED = DOXYGEN_SHOULD_IGNORE_THIS=1 DECLSPEC= CALLCONVENTION=
17  */
18 
21  #ifdef BIAP_BUILD_LIBRARY
22  #ifdef WIN32
23  #define BIAP_EXPORT __declspec(dllexport)
24  #elif defined(__GNUC__) && __GNUC__ >= 4
25  #define BIAP_EXPORT __attribute__ ((visibility("default")))
26  #else
27  #define BIAP_EXPORT
28  #endif
29  #else
30  #define BIAP_EXPORT
31  #endif /* BIAP_BUILD_LIBRARY */
32 
33  /*
34  Nullability qualifiers: currently only supported by Clang.
35  */
36  #if defined(__clang__)
37  #if __has_feature(nullability)
38  #define BIAP_NONNULL _Nonnull
39  #define BIAP_NULLABLE _Nullable
40  #else
41  #define BIAP_NONNULL
42  #define BIAP_NULLABLE
43  #endif
44  #else
45  #define BIAP_NONNULL
46  #define BIAP_NULLABLE
47  #endif
48 
50 #endif /* DOXYGEN_SHOULD_IGNORE_THIS */
51 
52 
53 
54 
55 #include <stddef.h>
56 #include <stdint.h>
57 #include <stdbool.h>
58 
1063 struct BIAP_AppStore;
1066 
1071 
1072 struct BIAP_Product;
1075 
1080 
1083 {
1101 };
1103 
1105 
1106 
1107 
1108 
1109 
1115 
1121 {
1123 
1126 
1128 
1130 
1132 
1135 
1138 
1142 
1144 
1147 
1150 
1151 
1152 };
1154 
1159 {
1171 };
1173 
1175 
1180 
1191 typedef void (*BIAP_ProductResponse)(enum BIAP_EventType callback_type, struct BIAP_ProductResponseData* BIAP_NONNULL callback_data, void* BIAP_NULLABLE user_data);
1201 typedef void (*BIAP_TransactionResponse)(enum BIAP_EventType callback_type, struct BIAP_TransactionResponseData* BIAP_NONNULL callback_data, void* BIAP_NULLABLE user_data);
1202 
1208 BIAP_EXPORT void BIAP_FreeProductResponseData(struct BIAP_ProductResponseData* BIAP_NONNULL callback_data);
1214 BIAP_EXPORT void BIAP_FreeTransactionResponseData(struct BIAP_TransactionResponseData* BIAP_NONNULL callback_data);
1215 
1217 
1222 
1224 
1266 BIAP_EXPORT void BIAP_RegisterKey(enum BIAP_StoreName store_name, const char* BIAP_NONNULL the_key);
1267 
1268 
1275 BIAP_EXPORT void BIAP_Init(void);
1282 BIAP_EXPORT bool BIAP_IsInit(void);
1289 BIAP_EXPORT void BIAP_Quit(void);
1290 
1304 BIAP_EXPORT struct BIAP_AppStore* BIAP_NONNULL BIAP_CreateAppStore(enum BIAP_StoreName store_name, void* BIAP_NULLABLE native_platform_context, BIAP_ProductResponse BIAP_NONNULL product_response_callback, BIAP_TransactionResponse BIAP_NONNULL transaction_response_callback, void* BIAP_NULLABLE user_data);
1305 
1311 BIAP_EXPORT void BIAP_StartAppStore(struct BIAP_AppStore* BIAP_NONNULL app_store);
1312 
1318 BIAP_EXPORT void BIAP_FreeAppStore(struct BIAP_AppStore* BIAP_NONNULL app_store);
1319 
1321 
1322 
1327 
1329 
1336 BIAP_EXPORT enum BIAP_StoreName BIAP_GetAppStoreName(struct BIAP_AppStore* BIAP_NONNULL app_store);
1337 
1338 
1339 
1340 
1353 BIAP_EXPORT void BIAP_RequestProducts(struct BIAP_AppStore* BIAP_NONNULL app_store,
1354  const char* BIAP_NULLABLE nonconsumable_product_identifier_list[BIAP_NONNULL], size_t num_nonconsumables,
1355  const char* BIAP_NULLABLE consumable_product_identifier_list[BIAP_NONNULL], size_t num_consumables,
1356  const char* BIAP_NULLABLE subscription_product_identifier_list[BIAP_NONNULL], size_t num_subscriptions
1357 );
1358 
1368 BIAP_EXPORT void BIAP_PurchaseProduct(struct BIAP_ProductResponseData* BIAP_NONNULL callback_data, struct BIAP_Product* BIAP_NONNULL the_product);
1369 
1377 BIAP_EXPORT void BIAP_FinishTransaction(struct BIAP_TransactionResponseData* BIAP_NONNULL callback_data);
1378 
1388 BIAP_EXPORT void BIAP_ConsumePurchase(struct BIAP_TransactionResponseData* BIAP_NONNULL callback_data_of_purchase);
1389 
1390 
1397 BIAP_EXPORT void BIAP_RestorePurchases(struct BIAP_AppStore* BIAP_NONNULL app_store);
1398 
1400 
1401 
1402 
1403 
1409 
1411 
1417 BIAP_EXPORT struct BIAP_AppStore* BIAP_NONNULL BIAP_GetProductAppStore(struct BIAP_ProductResponseData* BIAP_NONNULL callback_data);
1418 
1419 
1426 BIAP_EXPORT enum BIAP_EventType BIAP_GetProductEventType(struct BIAP_ProductResponseData* BIAP_NONNULL callback_data);
1427 
1434 BIAP_EXPORT const char* BIAP_NONNULL BIAP_GetProductErrorString(struct BIAP_ProductResponseData* BIAP_NONNULL callback_data);
1435 
1443 BIAP_EXPORT size_t BIAP_GetProductsListCount(struct BIAP_ProductResponseData* BIAP_NONNULL callback_data);
1444 
1474 BIAP_EXPORT struct BIAP_Product* BIAP_NULLABLE BIAP_GetProductInList(struct BIAP_ProductResponseData* BIAP_NONNULL callback_data, size_t list_index);
1475 
1483 BIAP_EXPORT struct BIAP_Product* BIAP_NULLABLE BIAP_GetProductWithIdentifier(struct BIAP_ProductResponseData* BIAP_NONNULL callback_data, const char* BIAP_NONNULL product_identifer);
1484 
1492 BIAP_EXPORT const char* BIAP_NONNULL BIAP_GetProductTitle(struct BIAP_ProductResponseData* BIAP_NONNULL callback_data, struct BIAP_Product* BIAP_NONNULL product_object);
1500 BIAP_EXPORT const char* BIAP_NONNULL BIAP_GetProductDescription(struct BIAP_ProductResponseData* BIAP_NONNULL callback_data, struct BIAP_Product* BIAP_NONNULL product_object);
1508 BIAP_EXPORT const char* BIAP_NONNULL BIAP_GetProductIdentifier(struct BIAP_ProductResponseData* BIAP_NONNULL callback_data, struct BIAP_Product* BIAP_NONNULL product_object);
1516 BIAP_EXPORT const char* BIAP_NONNULL BIAP_GetProductLocalizedPrice(struct BIAP_ProductResponseData* BIAP_NONNULL callback_data, struct BIAP_Product* BIAP_NONNULL product_object);
1517 
1518 
1526 BIAP_EXPORT size_t BIAP_GetInvalidProductsListCount(struct BIAP_ProductResponseData* BIAP_NONNULL callback_data);
1527 
1544 BIAP_EXPORT const char* BIAP_NONNULL BIAP_GetInvalidProductIdentifier(struct BIAP_ProductResponseData* BIAP_NONNULL callback_data, size_t list_index);
1545 
1547 
1548 
1554 
1556 
1562 BIAP_EXPORT struct BIAP_AppStore* BIAP_NONNULL BIAP_GetTransactionAppStore(struct BIAP_TransactionResponseData* BIAP_NONNULL callback_data);
1563 
1570 BIAP_EXPORT enum BIAP_EventType BIAP_GetTransactionEventType(struct BIAP_TransactionResponseData* BIAP_NONNULL callback_data);
1571 
1578 BIAP_EXPORT const char* BIAP_NONNULL BIAP_GetTransactionErrorString(struct BIAP_TransactionResponseData* BIAP_NONNULL callback_data);
1579 
1586 BIAP_EXPORT enum BIAP_FailedTransactionType BIAP_GetTransactionErrorType(struct BIAP_TransactionResponseData* BIAP_NONNULL callback_data);
1587 
1594 BIAP_EXPORT const char* BIAP_NONNULL BIAP_GetTransactionProductIdentifier(struct BIAP_TransactionResponseData* BIAP_NONNULL callback_data);
1595 
1602 BIAP_EXPORT long long BIAP_GetTransactionPurchaseTime(struct BIAP_TransactionResponseData* BIAP_NONNULL callback_data);
1603 
1610 BIAP_EXPORT long long BIAP_GetTransactionOriginalPurchaseTime(struct BIAP_TransactionResponseData* BIAP_NONNULL callback_data);
1611 
1619 BIAP_EXPORT const char* BIAP_NONNULL BIAP_GetTransactionOriginalJson(struct BIAP_TransactionResponseData* BIAP_NONNULL callback_data);
1620 
1622 
1623 
1628 
1637 BIAP_EXPORT void BIAP_RequestReceiptRefresh(struct BIAP_AppStore* BIAP_NONNULL app_store);
1638 
1647 BIAP_EXPORT const char* BIAP_NONNULL BIAP_GetReceiptPath(struct BIAP_AppStore* BIAP_NONNULL app_store);
1648 
1650 
1651 
1656 
1664 BIAP_EXPORT void BIAP_SetDebugLogging(bool should_enable);
1671 BIAP_EXPORT bool BIAP_IsDebugLogging(void);
1672 
1674 
1679 
1681 #if defined(__ANDROID__)
1682 
1694 BIAP_EXPORT bool BIAP_Android_HandleOnActivityResult(void* BIAP_NONNULL jni_env, void* BIAP_NONNULL original_activity, int32_t request_code, int32_t result_code, void* BIAP_NONNULL intent_data);
1695 #endif
1696 
1698 
1699 
1700 #if defined(__cplusplus)
1701 }
1702 #endif
1703 
1704 #endif /* BLURRR_IN_APP_PURCHASE_H */
1705 
enum BIAP_EventType BIAP_GetTransactionEventType(struct BIAP_TransactionResponseData *callback_data)
Gets the BIAP_EventType associated with this callback data.
Android.
Definition: BLRInAppPurchase.h:1167
size_t BIAP_GetInvalidProductsListCount(struct BIAP_ProductResponseData *callback_data)
Gets the number of invalid products returned from your product request.
Definition: BLRInAppPurchase.h:1093
Definition: BLRInAppPurchase.h:1086
transaction
Definition: BLRInAppPurchase.h:1125
BIAP_EventType
These event types are given to you for every callback so you distingush the purpose of the event...
Definition: BLRInAppPurchase.h:1120
Definition: BLRInAppPurchase.h:1162
const char * BIAP_GetTransactionOriginalJson(struct BIAP_TransactionResponseData *callback_data)
(Android-only) Gets the JSON formatted receipt for a transaction.
Android.
Definition: BLRInAppPurchase.h:1168
const char * BIAP_GetInvalidProductIdentifier(struct BIAP_ProductResponseData *callback_data, size_t list_index)
Gets a invalid product from a list of invalid products returned from your product request...
transaction, Android-only
Definition: BLRInAppPurchase.h:1137
transaction
Definition: BLRInAppPurchase.h:1149
transaction
Definition: BLRInAppPurchase.h:1139
void BIAP_FreeAppStore(struct BIAP_AppStore *app_store)
Disconnects and frees your app store instance.
BIAP_StoreName
Definition: BLRInAppPurchase.h:1082
Apple.
Definition: BLRInAppPurchase.h:1165
Definition: BLRInAppPurchase.h:1100
void BIAP_Quit(void)
Shuts down the library.
transaction, Android-only
Definition: BLRInAppPurchase.h:1136
void BIAP_FinishTransaction(struct BIAP_TransactionResponseData *callback_data)
For those that require it, notifies the app store that the transaction is finished.
Definition: BLRInAppPurchase.h:1087
const char * BIAP_GetReceiptPath(struct BIAP_AppStore *app_store)
(Apple-only) Gets the path to the receipt on the file system.
enum BIAP_StoreName BIAP_GetAppStoreName(struct BIAP_AppStore *app_store)
Gets the name of the app store you are connected with.
const char * BIAP_GetProductLocalizedPrice(struct BIAP_ProductResponseData *callback_data, struct BIAP_Product *product_object)
Gets the product localized price string for the specified product.
void(* BIAP_TransactionResponse)(enum BIAP_EventType callback_type, struct BIAP_TransactionResponseData *callback_data, void *user_data)
This is the function signature for your Transaction callbacks.
Definition: BLRInAppPurchase.h:1201
const char * BIAP_GetProductDescription(struct BIAP_ProductResponseData *callback_data, struct BIAP_Product *product_object)
Gets the product description string for the specified product.
long long BIAP_GetTransactionPurchaseTime(struct BIAP_TransactionResponseData *callback_data)
Gets the transaction purchase time in milliseconds since Epoch (Unix 1970).
transaction
Definition: BLRInAppPurchase.h:1148
transaction
Definition: BLRInAppPurchase.h:1124
Apple.
Definition: BLRInAppPurchase.h:1163
products
Definition: BLRInAppPurchase.h:1129
Definition: BLRInAppPurchase.h:1089
struct BIAP_Product * BIAP_GetProductWithIdentifier(struct BIAP_ProductResponseData *callback_data, const char *product_identifer)
Searches and returns a valid product from a list of valid products returned from your product request...
void BIAP_FreeTransactionResponseData(struct BIAP_TransactionResponseData *callback_data)
Frees the memory for the BIAP_TransactionResponseData that was created for you in the Transaction cal...
Definition: BLRInAppPurchase.h:1090
transaction, Apple-only
Definition: BLRInAppPurchase.h:1133
Definition: BLRInAppPurchase.h:1094
bool BIAP_IsDebugLogging(void)
Returns whether debug logging is enabled.
const char * BIAP_GetTransactionErrorString(struct BIAP_TransactionResponseData *callback_data)
Gets the error string associated with this callback data.
const char * BIAP_GetProductTitle(struct BIAP_ProductResponseData *callback_data, struct BIAP_Product *product_object)
Gets the product title string for the specified product.
Android.
Definition: BLRInAppPurchase.h:1166
void BIAP_RequestReceiptRefresh(struct BIAP_AppStore *app_store)
(Apple-only) Refreshes the user&#39;s purchases receipt on the file system.
enum BIAP_FailedTransactionType BIAP_GetTransactionErrorType(struct BIAP_TransactionResponseData *callback_data)
Gets the BIAP_FailedTransactionType associated with this callback data.
const char * BIAP_GetProductIdentifier(struct BIAP_ProductResponseData *callback_data, struct BIAP_Product *product_object)
Gets the product identifier string associated with this product.
struct BIAP_Product * BIAP_GetProductInList(struct BIAP_ProductResponseData *callback_data, size_t list_index)
Gets a valid product from a list of valid products returned from your product request.
long long BIAP_GetTransactionOriginalPurchaseTime(struct BIAP_TransactionResponseData *callback_data)
(Android-only) Gets the original transaction purchase time in milliseconds since Epoch (Unix 1970)...
Definition: BLRInAppPurchase.h:1099
void BIAP_SetDebugLogging(bool should_enable)
Enables extra debug log messages in the library.
ex: calling RefreshReceipt on Android
Definition: BLRInAppPurchase.h:1170
const char * BIAP_GetTransactionProductIdentifier(struct BIAP_TransactionResponseData *callback_data)
Gets the product identifier string associated with this callback data.
void(* BIAP_ProductResponse)(enum BIAP_EventType callback_type, struct BIAP_ProductResponseData *callback_data, void *user_data)
This is the function signature for your Product callbacks.
Definition: BLRInAppPurchase.h:1191
BIAP_FailedTransactionType
For an error in a transaction event, this sub-type can help you determine the reason for the failure...
Definition: BLRInAppPurchase.h:1158
void BIAP_StartAppStore(struct BIAP_AppStore *app_store)
Starts the app store.
transaction
Definition: BLRInAppPurchase.h:1146
Definition: BLRInAppPurchase.h:1091
Definition: BLRInAppPurchase.h:1097
struct BIAP_ProductResponseData BIAP_ProductResponseData
Definition: BLRInAppPurchase.h:1069
Definition: BLRInAppPurchase.h:1098
struct BIAP_TransactionResponseData BIAP_TransactionResponseData
Definition: BLRInAppPurchase.h:1070
transaction
Definition: BLRInAppPurchase.h:1145
struct BIAP_AppStore BIAP_AppStore
Definition: BLRInAppPurchase.h:1065
void BIAP_Init(void)
Initializes the library.
const char * BIAP_GetProductErrorString(struct BIAP_ProductResponseData *callback_data)
Gets the error string associated with this callback data.
Definition: BLRInAppPurchase.h:1160
transaction
Definition: BLRInAppPurchase.h:1140
void BIAP_FreeProductResponseData(struct BIAP_ProductResponseData *callback_data)
Frees the memory for the BIAP_ProductResponseData that was created for you in the Product callback...
Android.
Definition: BLRInAppPurchase.h:1169
transaction, Apple-only
Definition: BLRInAppPurchase.h:1143
Definition: BLRInAppPurchase.h:1096
Definition: BLRInAppPurchase.h:1085
void BIAP_RegisterKey(enum BIAP_StoreName store_name, const char *the_key)
Allows you to register your public key for the app stores that require it.
Definition: BLRInAppPurchase.h:1092
Definition: BLRInAppPurchase.h:1095
transaction
Definition: BLRInAppPurchase.h:1131
products & transactions
Definition: BLRInAppPurchase.h:1122
bool BIAP_IsInit(void)
Has the library been initialized?
Definition: BLRInAppPurchase.h:1084
bool BIAP_Android_HandleOnActivityResult(void *jni_env, void *original_activity, int32_t request_code, int32_t result_code, void *intent_data)
(Android-only) Call this function in your Android Activity&#39;s onActivityResult method.
transaction
Definition: BLRInAppPurchase.h:1141
enum BIAP_EventType BIAP_GetProductEventType(struct BIAP_ProductResponseData *callback_data)
Gets the BIAP_EventType associated with this callback data.
void BIAP_RequestProducts(struct BIAP_AppStore *app_store, const char *nonconsumable_product_identifier_list[], size_t num_nonconsumables, const char *consumable_product_identifier_list[], size_t num_consumables, const char *subscription_product_identifier_list[], size_t num_subscriptions)
Requests product information from your connected app store.
Definition: BLRInAppPurchase.h:1088
size_t BIAP_GetProductsListCount(struct BIAP_ProductResponseData *callback_data)
Gets the number of valid products returned from your product request.
struct BIAP_AppStore * BIAP_GetTransactionAppStore(struct BIAP_TransactionResponseData *callback_data)
Gets the app store handle that this callback originated from.
void BIAP_RestorePurchases(struct BIAP_AppStore *app_store)
Requests all purchases a user has bought from the app store.
struct BIAP_AppStore * BIAP_CreateAppStore(enum BIAP_StoreName store_name, void *native_platform_context, BIAP_ProductResponse product_response_callback, BIAP_TransactionResponse transaction_response_callback, void *user_data)
Creates and starts a connection to the app store.
struct BIAP_Product BIAP_Product
Definition: BLRInAppPurchase.h:1073
void BIAP_PurchaseProduct(struct BIAP_ProductResponseData *callback_data, struct BIAP_Product *the_product)
Purchases the specified product from the app store.
Definition: BLRInAppPurchase.h:1161
transaction
Definition: BLRInAppPurchase.h:1134
products & transactions
Definition: BLRInAppPurchase.h:1127
Apple.
Definition: BLRInAppPurchase.h:1164
void BIAP_ConsumePurchase(struct BIAP_TransactionResponseData *callback_data_of_purchase)
Consumes a consumable purchased product.
struct BIAP_AppStore * BIAP_GetProductAppStore(struct BIAP_ProductResponseData *callback_data)
Gets the app store handle that this callback originated from.