How to use the Bank API

What are the Currency & Commerce Services?

Items and other products can be sold in games on the Mobage Open Platform. This feature is offered through the Mobage SDK as the Bank API. 
By implementing the API in games, partner developers can offer in-app purchase services for things such as items.

A list of items for in-app purchase can be kept on the partner’s game server or on the platform. 
If the list is being kept on the game server, the process is slightly complicated, but data can be managed in an integrated fashion. 
On the other hand, if the list is being kept on the platform, the process is streamlined, but it takes time to register and manage items. 
Registering items is either done by entering the information from the item management screen on the Developer’s Site or by using the RESTful API.

If a user is purchasing an item with virtual currency, they can use MobaCoin if running Android, or the unique virtual currencies in each game if running iOS. 
For the virtual currencies in the games, the names of the currencies and other such information can be registered on the Developer’s Site.

If items are specified for each transaction:

The RESTful API is compatible with the APIs of other devices.

Generating a transaction

1. Make a request from the game client to the game server for the creation of a transaction.
2. Use the RESTful API to make a request for the creation of a transaction from the game server to the APIServer.
3. A transaction is created on the APIServer.
4. Return the transaction information from the APIServer to the GameServer.
5. Return the transaction information from the GameServer to the game client.

Approving the transaction

6. Execute continueTransaction() method in each SDK.
7. An item purchase confirmation screen is displayed on the user’s device.
8. If the user confirms the purchase, the transaction is approved on the API Server.
9. The results are returned to the callback.

※ BankDebit Class of SDK

SDK

BankDebit Class name

Mobage Native SDK for Android

com.mobage.android.bank.Debit

Mobage Native SDK for iOS

MBGBankDebit

Settling the transaction

10. Make a request from the game client to the game server for the settlement of a transaction.
11. Use the RESTful API to make a request for the start of a transaction from the game server to the APIServer.
12. The transaction specified on the API Server is opened.
13. The results are returned from the APIServer to the GameServer.
14. Grant the items to the user on the game server.
15. Use the RESTful API to make a request for the completion of the transaction from the game server to the APIServer.
16. The transaction specified on the APIServer is closed.
17. The results are returned from the APIServer to the GameServer.
18. Use the RESTful API to make a request from the game server to the APIServer for the confirmation of the transaction.
19. The status of the transaction specified on theAPIServer is confirmed.
20. The results are returned from the APIServer to the GameServer.
21. Commit grant items.
22. The results are returned from GameServer to the game client.
23. You can make a request from the game client to the game server for the item granting status to be confirmed.
24. The results are returned from GameServer to the game client.

If items are to be registered on the platform:

You can use a smartphone (app-compatible) after registering items on the platform.

Approving the transaction

1. Execute createTransaction() method in each SDK.
2. An item purchase confirmation screen is displayed on the user’s device.
3. If the user confirms the purchase, the transaction is approved on the APIServer.
4. The results are returned to the callback.

Settling the transaction

5. Make a request from the game client to the game server for the settlement of a transaction .
6. Use the RESTful API to make a request for the start of a transaction from the game server to the APIServer.
7. The transaction specified on the APIServer is started.
8. The results are returned from the APIServer to the GameServer.
9. Grant the items on the game server.
10. Use the RESTful API to make a request for the completion of the transaction from the game server to the APIServer.
11. The transaction specified on the APIServer is completed.
12. The results are returned from the APIServer to the GameServer.
13. If the status of the transaction must be confirmed, such as when the process in 12. times out, use the RESTful API to make a request from the game server to the APIServer for the confirmation of the transaction.
14. The status of the transaction specified on the APIServer is confirmed.
15. The results are returned from the APIServer to the GameServer.
16. Commit grant items.
17. The results are returned from GameServer to the game client.
18. You can make a request from the game client to the game server for the item granting status to be confirmed.
19. The results are returned from GameServer to the game client.

If you are using only client API

When the game does not have own game server, you can also create and proceed bank transactions using by client API without RESTful API.
In this client-based flow, you must register items on the platform and you cannot specify item information for every transaction.

Approving the transaction

1. Execute createTransaction() method in each SDK.
2. An item purchase confirmation screen is displayed on the user’s device.
3. If the user confirms the purchase, the transaction is approved on the APIServer.
4. The results are returned to the callback.

Settling the transaction

5. Execute openTransaction() method in each SDK.
6. The transaction specified on the APIServer is started.
7. The results are returned to the callback.
8. Grant the items on the the user’s device.
9. Execute closeTransaction() method in each SDK.
10. The transaction specified on the APIServer is completed.
11. The results are returned to the callback.
12. Execute getTransaction() method in each SDK for confirming a transaction.
13. The status of the transaction specified on the APIServer is confirmed.
14. Check state of a transaction which is returned to the callback.

How to Register Items on the Mobage Open Platform

Go to Mobage Developers,
1. Select the appropriate application from Application Management.
2. Click “add item” from the left panel.
3. Register items. Please note that the item identifier will be the itemID.

Currency Differences between Andorid and iOS

The currency differences between Android and iOS are as follows.

  • For Android, purchase “MobaCoins” which can be used throughout Mobage to buy items etc. within applications. Implement Bank API to use “MobaCoins”.
  • For iOS, purchase “GamePoints” which can be used to buy items etc. within applications using In-App Purchase provided by Apple, Inc. You can register the name of the GamePoints on the DeNA developer’s site, and use “GamePoints” in the Bank API. Because “GamePoints” are an independent virtual currency unique to each application, they cannot be used in other applications.

Sample Code

Server side sample

 
PHP Version

  • request_temporary_credential.php is sample of "Request and returning of temporary credentials" in The OAuth Authorization Flow.
  • request_token.php is sample of "Request access token credentials" in The OAuth Authorization Flow.
  • create_transaction.php is sample of "Generating a transaction" on this page.
  • commit_transaction.php is sample of "Settling the transaction" on this page.

Revision history

  • 16/08/2013
    • Added Sample code section.
  • 10/06/2013
    • Remove Bank Inventory POST from "How to Register Items on the Mobage Open Platform"
  • 21/03/2013
    • Changed the sequence image.
    • Added "Commit grant items".
  • 12/18/2012
    • Added “If you are using only client API”.
  • 08/01/2012
    • Added “How to Register Items on the Mobage Open Platform”.
    • Added “Currency Differences between Android and iOS”.
  • 05/01/2011
    • Initial Release.

PREVIOUS

How to Use APIs

NEXT

How to add item in mobage platform