Page 1 of 1

Does API allow negative chip balances?

Posted: Thu Sep 03, 2015 5:43 am
by social
Does PM allow negative chip balances?

I am trying to anticipate potential problems with a script I am developing which will
deduct chips from balances in order to pay for certain things on my site...

So, let's say that my store tries to deduct 10 Chips as payment, but there are only
5 Chips in Player's account...

What would happen?

Would the account go to -5 chips?

Would there be an error notification of some sort generated somehow?

Re: Does API allow negative chip balances?

Posted: Thu Sep 03, 2015 9:16 am
by Kent Briggs
social wrote:Does PM allow negative chip balances?
That all depends on the "Allow negative balance" setting in the Account Settings group on the System tab.

Re: Does API allow negative chip balances?

Posted: Thu Sep 03, 2015 12:06 pm
by social
So, what happens if you set it to "NO" do not allow negative balances?
Is there any sort of Notification automatically generated to alert the player or admin that a Negative Balance would occur if the process were to continue?

Re: Does API allow negative chip balances?

Posted: Thu Sep 03, 2015 12:37 pm
by Kent Briggs
social wrote:So, what happens if you set it to "NO" do not allow negative balances?
Is there any sort of Notification automatically generated to alert the player or admin that a Negative Balance would occur if the process were to continue?
It depends on the particular API command. The documentation tells you. For example, from the help file:

TournamentsRegister - registers a player specified by the Player parameter for the tournament specified by the Name parameter and automatically deducts the applicable buy-in from their account. The player does not have to be logged in. Use the optional Negative parameter to bypass the system "Allow negative balance" setting. Set to "Allow" to allow the player's balance to go to a negative balance if they do not have enough chips to meet the buy-in price or to "Skip" to deny the registration in that case. Leave this parameter blank to obey the system setting.

AccountsDecBalance - decrements the account balance of a player. This command does not check to see if you have "Allow negative balance" turned on or not in the account settings. An "Amount" parameter is included in the response that specifies the number of chips that were actually subtracted. A "Balance" parameter is returned with the player's new chip balance. This command is safe to use even while the player is logged in and playing.

Player - account name
Amount - number of chips to subtract from account
Negative - optional parameter set to "Allow", "Zero", or "Skip". Use Allow (the default) to let the player's balance go below 0. Use Zero to reset the account to 0 if the command results in a negative balance. Use Skip to not subtract any chips if the result would be a negative balance.

Re: Does API allow negative chip balances?

Posted: Thu Sep 03, 2015 1:25 pm
by social
Kent Briggs wrote:
social wrote:So, what happens if you set it to "NO" do not allow negative balances?
Is there any sort of Notification automatically generated to alert the player or admin that a Negative Balance would occur if the process were to continue?

AccountsDecBalance - decrements the account balance of a player. This command does not check to see if you have "Allow negative balance" turned on or not in the account settings. An "Amount" parameter is included in the response that specifies the number of chips that were actually subtracted. A "Balance" parameter is returned with the player's new chip balance. This command is safe to use even while the player is logged in and playing.

.
That is the one I was talking about, given that I stated I wanted to deduct chips to pay for items bought in my store.

So, I still do not have a clear explanation of what will happen.
If I understand, you said this API command will take place even if I have "Allow Negative" to be set to NO.

So, is the consequence that Player will be able to build up a negative balance and purchase stuff they cannot pay for UNLESS I create some more code which
parses the Returned Balance Parameter and sees that the balance is now negative?

This seems like shutting the barn door after the horses have escaped.
The customer will already have acquired the virtual goods from the store.

so, I guess I would need an additional step of code which waits for the Balance to be returned before validating the sale...and releasing the product...

am I missing some other aspect of the API that would help me in this situation, or is the above analysis accurate?

Re: Does API allow negative chip balances?

Posted: Thu Sep 03, 2015 2:03 pm
by Kent Briggs
You missed the most relevant part of the my last post. See the "Negative" parameter in the last line of my previous message. Set it "Skip" and no chips will be deducted if they player doesn't have enough chips. The "Amount" parameter returned will be 0 so you will know it failed.

Re: Does API allow negative chip balances?

Posted: Thu Sep 03, 2015 3:35 pm
by social
Kent Briggs wrote: This command does not check to see if you have "Allow negative balance" turned on or not in the account settings. An "Amount" parameter is included in the response that specifies the number of chips that were actually subtracted. A "Balance" parameter is returned with the player's new chip balance.

<snip>
Player - account name
Amount - number of chips to subtract from account
Negative - optional parameter set to "Allow", "Zero", or "Skip". Use Allow (the default) to let the player's balance go below 0. Use Zero to reset the account to 0 if the command results in a negative balance. Use Skip to not subtract any chips if the result would be a negative balance.
Somebody with my level of ignorance is not going to easily see that the command would not bother to check if "Allow negative balance" is turned on, yet it WOULD bother to check of "Skip" had been selected.

Thanks for clarifying.