Inside MySQL, There is a Users table with three columns like this:
id (int) | name (char) | wallet_balance (int) | hasMembership (tinyint) |
---|---|---|---|
1 | user1 | 125 | 0 |
2 | user2 | 23 | 0 |
3 | user3 | 986 | 0 |
Let's suppose the price of membership is 100.
Here is the current scenario:
- Inside the android app, The user clicked on the buy button.
- Send the user id to the server using Retrofit.
- In the server, Get the wallet balance from the database using the user id.
- If the wallet balance was 100 and more then remove 100 from his wallet and update the fourth column to 1.
- If the wallet balance was 99 and below then I'll execute this code
echo "8012";
- Inside the android, Inside the onResponse method, I'll check if the body contains the 8012 number, If yes I'll tell the user he does not has enough balance, Otherwise, I'll tell the user he bought it successfully.
Is there any way to send the 8012 number as an error instead of printing it because Retrofit handles it as a successful result?
I want when I send the 8012 number, Execute the onFailure method and check from the number inside the onFailure method instead of the onResponse method.
The main question: Is there any way to send the 8012 number as an error instead of printing it using PHP?
I hope everything is clear.