question

dev_beta avatar image
dev_beta asked

Can external server send http request to custom playfab cloud script?

Hi,

I'm working with some third-party mobile game platforms in China, and their IAP logic need to send a http post request to the game server after payment. I assume a custom playfab cloud script should handle the request. But how can someone from other server send http request to playfab?

Here is an example of their request:

URL: http://172.63.55.62:18888/moon/pay

POST Body:
{"type":"notify-game", "xgAppId":"2018", "channelId":"mi", "uid":"mi__3099245", "zoneId":"1", "serverId":"1", "roleId":"224455", "roleName":"USER123", "roleLevel":"42", "roleVipLevel":"8", "currencyName":"CNY", "productId":"com.mygame.diamond600", "productName":"600GEM", "productDesc":"6元购买600钻石", "productQuantity":"600", "totalAmount":"600", "paidAmount":"600", "customInfo":"foo", "gameTradeNo":"20160325000001", "tradeNo":"31602f1000000001", "paidTime":"20150723145928", "payStatus":"1", "ts":"20150723150028", "ext":"{\"cancellationDate\": \"20160901201417\",\"expiresDate\": \"20160901201417\",\"isSandbox\": true,\"originalTradeNo\": \"016q2f1000303885\"}","sign":"4873560491111c3f719dada104a0b055e2531d8f"}

CloudScript
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

brendan avatar image
brendan answered

You can include the Client API in a custom game server and so use it to make calls to ExecuteCloudScript, using the session ticket for a player on that server. But let me ask - you say you want to send a POST request to "the game server" when a payment occurs. What is the game server in that context? If it's a custom game server, it could be on any IP Address in EC2, so if that's the case, your best bet would be to have the player who made the purchase tell the game server to ping for the additional info it needs, and have it query that data from a secure store (possibly writing the info you need to User Internal or Read Only Data via Cloud Script).

3 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

dev_beta avatar image dev_beta commented ·

Hi Brendan, thanks for your reply. "The game server" here means Playfab. We use Playfab as gameserver, and the other platform is for communication with Chinese local android stores/channels.

That third-party platform doesn't have much custom functions like "include some other scripts". All it has is one input field, which could contain a single url address. The body of http request will be determined by that platform. So I wonder, can I put all information (like auth info, function name etc. ) in one url (like http://xxx.playfabapi.com.Server/ExecuteCloudScript?XXXXXXXXX).

0 Likes 0 ·
brendan avatar image brendan dev_beta commented ·

Sorry, but do you specifically mean that you are hosting custom game servers in PlayFab? I ask because PlayFab has a range of features for games, but I wouldn't describe the service itself as a "game server", per-se.

In order to make a call to Cloud Script, you need to have an active client signed in, and you must use that client's Session Ticket as the authorization component in the header of the POST message to our service. It sounds like the options you have in the third-party service are fairly limited, and may not be able to support this. Could you send the specific documentation for the other service to us at devrel@playfab.com, so that we can review this and provide feedback?

0 Likes 0 ·
Michael Flanagan avatar image Michael Flanagan commented ·

@Brendan

  1. Has your answer changed since the move to Azure?
  2. You say, "You can include the Client API in a custom game server." I'm looking at this doc here: https://docs.microsoft.com/en-us/gaming/playfab/features/multiplayer/servers/custom-game-servers
    Is this still valid? Or is there now a different way to create custom game servers?
  3. I'm looking for a way to have an external server (external to PF) send a GET to PF that will return information about a player in a game. For example, the number of (virtual) arrows that GamerMike has in the PF title "Bow Rookie." I will have received an ok from the player to allow PF to return that info to the external server. I'll have dozens of such titles, not all mine. (And for those not mine I'll also get permission from the title's author to get and return this information.) Can PF do this?

TIA

0 Likes 0 ·
Michael Flanagan avatar image
Michael Flanagan answered

Re. @Brendan's comments:

  1. Has your answer changed since the move to Azure?
  2. You say, "You can include the Client API in a custom game server." I'm looking at this doc here: https://docs.microsoft.com/en-us/gaming/playfab/features/multiplayer/servers/custom-game-servers
    Is this still valid? Or is there now a different way to create custom game servers?
  3. I'm looking for a way to have an external server (external to PF) send a GET to PF that will return information about a player in a game. For example, the number of (virtual) arrows that GamerMike has in the PF title "Bow Rookie." I will have received an ok from the player to allow PF to return that info to the external server. I'll have dozens of such titles, not all mine. (And for those not mine I'll also get permission from the title's author to get and return this information.) Can PF do this?
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Seth Du avatar image Seth Du ♦ commented ·

If it is an external secure server that is accessible only to administrators, you are able to implement any Server API to get player's information. In terms of different titles, you can define PlayFabServerInstanceAPI (for example, in C# SDK) to get data.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.