diff --git a/include/braincloud/BrainCloudAppStore.h b/include/braincloud/BrainCloudAppStore.h index 16f3e8f3..088478c4 100644 --- a/include/braincloud/BrainCloudAppStore.h +++ b/include/braincloud/BrainCloudAppStore.h @@ -158,6 +158,30 @@ namespace BrainCloud */ void cachePurchasePayloadContext(const std::string& storeId, const std::string& iapId, const std::string& payload, IServerCallback* callback = NULL); + /** + * Returns the store's client-side configuration for the given store. + * + * Service Name - appStore + * Service Operation - GET_STORE_INFO + * + * @param storeId The store to query. Currently only returns info for "xsolla", all other storeIds will return empty data. + * @param callback The method to be invoked when the server response is received + */ + void getStoreInfo(const std::string& storeId, IServerCallback* callback = NULL); + + /** + * Returns a store user token (JWT) for the current user, generated server-side. + * Currently only Xsolla is supported. The userToken is null if the required + * Xsolla integration settings are missing or the Xsolla call fails. + * + * Service Name - appStore + * Service Operation - GET_USER_TOKEN + * + * @param storeId The store to get the token. Currently only returns info for "xsolla", all other storeIds will return empty data. + * @param callback The method to be invoked when the server response is received + */ + void getUserToken(const std::string& storeId, IServerCallback* callback = NULL); + private: BrainCloudClient * m_client; }; diff --git a/include/braincloud/ServiceOperation.h b/include/braincloud/ServiceOperation.h index a70c787e..d18a188e 100644 --- a/include/braincloud/ServiceOperation.h +++ b/include/braincloud/ServiceOperation.h @@ -536,6 +536,8 @@ namespace BrainCloud static const ServiceOperation AppStoreStartPurchase; static const ServiceOperation AppStoreFinalizePurchase; static const ServiceOperation AppStoreRefreshPromotions; + static const ServiceOperation GetStoreInfo; + static const ServiceOperation GetUserToken; // Blockchain static const ServiceOperation GetBlockchainItems; diff --git a/src/BrainCloudAppStore.cpp b/src/BrainCloudAppStore.cpp index 75d7c72f..86928fef 100644 --- a/src/BrainCloudAppStore.cpp +++ b/src/BrainCloudAppStore.cpp @@ -100,4 +100,22 @@ namespace BrainCloud ServerCall* sc = new ServerCall(ServiceName::AppStore, ServiceOperation::AppStoreCachePurchaseContext, message, callback); m_client->sendRequest(sc); } + + void BrainCloudAppStore::getStoreInfo(const std::string& storeId, IServerCallback* callback) + { + Json::Value message; + message[OperationParam::AppStoreStoreId.getValue()] = storeId; + + ServerCall* sc = new ServerCall(ServiceName::AppStore, ServiceOperation::GetStoreInfo, message, callback); + m_client->sendRequest(sc); + } + + void BrainCloudAppStore::getUserToken(const std::string& storeId, IServerCallback* callback) + { + Json::Value message; + message[OperationParam::AppStoreStoreId.getValue()] = storeId; + + ServerCall* sc = new ServerCall(ServiceName::AppStore, ServiceOperation::GetUserToken, message, callback); + m_client->sendRequest(sc); + } } diff --git a/src/ServiceOperation.cpp b/src/ServiceOperation.cpp index d8a73c70..e74a98b7 100644 --- a/src/ServiceOperation.cpp +++ b/src/ServiceOperation.cpp @@ -156,6 +156,8 @@ namespace BrainCloud const ServiceOperation ServiceOperation::ConsumeVC = ServiceOperation("CONSUME_VC"); const ServiceOperation ServiceOperation::GetPlayerVC = ServiceOperation("GET_PLAYER_VC"); const ServiceOperation ServiceOperation::ResetPlayerVC = ServiceOperation("RESET_PLAYER_VC"); + const ServiceOperation ServiceOperation::GetStoreInfo = ServiceOperation("GET_STORE_INFO"); + const ServiceOperation ServiceOperation::GetUserToken = ServiceOperation("GET_USER_TOKEN"); const ServiceOperation ServiceOperation::AwardParentVC = ServiceOperation("AWARD_PARENT_VC"); const ServiceOperation ServiceOperation::ConsumeParentVC = ServiceOperation("CONSUME_PARENT_VC"); diff --git a/tests/src/TestBCAppStore.cpp b/tests/src/TestBCAppStore.cpp index 3ce9f36b..f134b42c 100644 --- a/tests/src/TestBCAppStore.cpp +++ b/tests/src/TestBCAppStore.cpp @@ -61,4 +61,32 @@ TEST_F(TestBCAppStore, cachePurchasePayloadContext) TestResult tr; m_bc->getAppStoreService()->cachePurchasePayloadContext("_invalid_store_id_", "_invalid_transaction_id_", "{}", &tr); tr.runExpectFail(m_bc, HTTP_BAD_REQUEST, INVALID_STORE_ID); -} \ No newline at end of file +} + +TEST_F(TestBCAppStore, GetStoreInfo) +{ + TestResult tr; + m_bc->getAppStoreService()->getStoreInfo("xsolla", &tr); + tr.run(m_bc); +} + +TEST_F(TestBCAppStore, GetStoreInfoFail) +{ + TestResult tr; + m_bc->getAppStoreService()->getStoreInfo("_invalid_store_id_", &tr); + tr.runExpectFail(m_bc, HTTP_BAD_REQUEST, INVALID_STORE_ID); +} + +TEST_F(TestBCAppStore, GetUserToken) +{ + TestResult tr; + m_bc->getAppStoreService()->getUserToken("xsolla", &tr); + tr.run(m_bc); +} + +TEST_F(TestBCAppStore, GetUserTokenFail) +{ + TestResult tr; + m_bc->getAppStoreService()->getUserToken("_invalid_store_id_", &tr); + tr.runExpectFail(m_bc, HTTP_BAD_REQUEST, INVALID_STORE_ID); +}