Microsoft Azure PlayFab logo
    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Add-ons
    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA
  • Runs on PlayFab
  • Pricing
    • Blog
    • Forums
    • Contact us
  • Sign up
  • Sign in
  • Ask a question
  • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges
  • Home /
  • API and SDK Questions /
avatar image
Question by Brendan · Oct 04, 2015 at 11:10 PM ·

rapidjson assert

studd
started a topic on Tue, 13 January 2015 at 12:29 PM

I'm just messing around with the C++ SDK, and I can't figure out why rapidjson triggers an assert when I'm trying to pay for my order.

Here are the Playfab related functions I call before the assert :

void PFNetwork::login(void* userData)
{
getCredentials();
if (canContactPlayfab())
{
LoginWithPlayFabRequest loginWithPlayFabRequest;
PlayFabSettings::titleId = id; //Title (game) ID
loginWithPlayFabRequest.Username = log; //Playfab login
loginWithPlayFabRequest.Password = pass; //PlayFab password
playFabClientAPI.LoginWithPlayFab(loginWithPlayFabRequest, loginWithPlayFabCallback, errorCallback, userData);
}
}

/**
Callback called when login is done.
/
void loginWithPlayFabCallback(LoginResult& result, void
userData)
{
static_cast<MultiplayerGameState*>(userData)->buyMissiles();
PFNetwork::setCallbackCalled(true);
}

void PFNetwork::buy(string name, int amount, void* userData)
{
StartPurchaseRequest purchaseRequest;
std::listClientModels::ItemPuchaseRequest items;
ClientModels::ItemPuchaseRequest item;
item.ItemId = name;
item.Quantity = amount;
items.push_back(item);
purchaseRequest.Items = items;

playFabClientAPI.StartPurchase(purchaseRequest, multiplePurchaseItemCallback, errorCallback, userData);

}

void multiplePurchaseItemCallback(StartPurchaseResult& result, void* userData)
{
string providerName;
for (auto& p : result.PaymentOptions)
if (p.Currency == "MS")
providerName = p.ProviderName;

PFNetwork::Instance().payForPurchase(providerName, result.OrderId, "MS", userData);

}

void PFNetwork::payForPurchase(string provider, string orderId, string currency, void* userData)
{
PayForPurchaseRequest payRequest;
payRequest.Currency = currency;
payRequest.ProviderName = provider;
payRequest.OrderId = orderId;
playFabClientAPI.PayForPurchase(payRequest, payPurchaseItemCallback, errorCallback, userData);
}

Before the payPurchaseItemCallback is called, I have this assert :

Comment

People who like this

0 Show 0
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by Brendan · Oct 04, 2015 at 11:10 PM

Best Answer
Brendan Vanous said on Thu, 15 January 2015 at 12:19 PM

Aha - very interesting! There are two problems which affected your test:

The main issue is that your catalog item has no "RM" (Real Money - specified as USD pennies, so 199 would be $1.99 USD, for instance) price. The three-stage purchase system (StartPurchase, PayForPurchase, ConfirmPurchase) is specifically for buying items with real-world money. If the intent is to only have this item purchasable with virtual currencies, the PurchaseItem call is the only one you need.

The other is a logical gotcha you've discovered in the catalog system. The CatalogVersion is optional on all the calls, as the system uses your most recent catalog as the default. However, if you've never defined a catalog (such as when you first create a title), there is no default, and setting up a catalog item without specifying the CatalogVersion results in a catalog without a CatalogVersion. I didn't see this because I was using the new Game Manager we'll be releasing shortly (in Beta right now, and I'm a firm believer in the "eat your own dogfood" philosophy), and it lists the catalogs by the CatalogVersion. We'll get that fixed, so that this doesn't trip up anyone else, but in the meantime, I've updated your catalog to have CatalogVersion of "Test".


5 Comments
Brendan Vanous said on Thu, 15 January 2015 at 11:27 AM

Hi Vincent,

Sorry for the delay getting back to you. I don't see a Catalog defined for your game. In order to use any of the purchasing API calls, you will need to set that up first, so that the service has the information needed.

Thanks,

Brendan


studd said on Thu, 15 January 2015 at 12:03 PM

Hi,

Thank you for the reply.

As I can't sign in on the portal with this account (it does not have a studio name), I created another account that I'm using to manage the game.

The game I'm testing things on does have a catalog with the item I'm trying to buy. In case you'd like to check, its titleID is D98D.

I had no problem with buying this item using the PurchaseItem function of the SDK, but for some reason I can't using StartPurchage and PayForPurchase.


Brendan Vanous said on Thu, 15 January 2015 at 12:19 PM

Aha - very interesting! There are two problems which affected your test:

The main issue is that your catalog item has no "RM" (Real Money - specified as USD pennies, so 199 would be $1.99 USD, for instance) price. The three-stage purchase system (StartPurchase, PayForPurchase, ConfirmPurchase) is specifically for buying items with real-world money. If the intent is to only have this item purchasable with virtual currencies, the PurchaseItem call is the only one you need.

The other is a logical gotcha you've discovered in the catalog system. The CatalogVersion is optional on all the calls, as the system uses your most recent catalog as the default. However, if you've never defined a catalog (such as when you first create a title), there is no default, and setting up a catalog item without specifying the CatalogVersion results in a catalog without a CatalogVersion. I didn't see this because I was using the new Game Manager we'll be releasing shortly (in Beta right now, and I'm a firm believer in the "eat your own dogfood" philosophy), and it lists the catalogs by the CatalogVersion. We'll get that fixed, so that this doesn't trip up anyone else, but in the meantime, I've updated your catalog to have CatalogVersion of "Test".


studd said on Thu, 15 January 2015 at 12:39 PM

It's very nice of you !

I didn't even think that no RM could cause that. The virtual currency I added appears in the response properties' payement options. Do you mean that I should avoid this choice, or is it just that I have to add an RM in the catalog before trying to use this ?

I think the SDK's documentation isn't very clear about this (or maybe it's just me, English isn't my first language after all).

Thanks !


Brendan Vanous said on Thu, 15 January 2015 at 5:49 PM

Oh, no - sorry. If all you want to do is make the purchase with a virtual currency, that API flow works fine, but you do need to make sure the provider is set correctly to the Title's ProviderName in the response. I just tested this out using the Web API calls directly to verify. Normally, titles just use PurchaseItem for making virtual-only purchases, which is why I wasn't on the same page with you.

I'd like to test our your repro, to see what the issue you're running into is. Rather than make any assumptions about the specifics of your test with the C++ SDK, could you send your repro to devrel@playfab.com?

And thanks - we're aware that we need to put some more explanation into some of our docs. I'll prioritize adding more details to the purchase flow.

Brendan

Comment

People who like this

0 Show 0 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Navigation

Spaces
  • General Discussion
  • API and SDK Questions
  • Feature Requests
  • PlayStream
  • Bugs
  • Add-on Marketplace
  • LiveOps
  • Follow this Question

    Answers Answers and Comments

    No one has followed this question yet.

    PlayFab

    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Runs on PlayFab
    • Pricing

    Solutions

    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA

    Engineers

    • Documentation
    • Quickstarts
    • API Reference
    • SDKs
    • Usage Limits

    Resources

    • Forums
    • Contact us
    • Blog
    • Service Health
    • Terms of Service
    • Attribution

    Follow us

    • Facebook
    • Twitter
    • LinkedIn
    • YouTube
    • Sitemap
    • Contact Microsoft
    • Privacy & cookies
    • Terms of use
    • Trademarks
    • Safety & eco
    • About our ads
    • © Microsoft 2020
    • Anonymous
    • Sign in
    • Create
    • Ask a question
    • Create an article
    • Post an idea
    • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Explore
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges