Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions include/braincloud/BrainCloudAppStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
2 changes: 2 additions & 0 deletions include/braincloud/ServiceOperation.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 18 additions & 0 deletions src/BrainCloudAppStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
2 changes: 2 additions & 0 deletions src/ServiceOperation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
30 changes: 29 additions & 1 deletion tests/src/TestBCAppStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

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);
}