Skip to main content

PayPal (via PlayFab)

This guide explains how to configure PayPal payments in combination with PlayFab, mostly viable on WebGL and Standalone platforms.

danger

Please note that PlayFab removed support for PlayFab-hosted PayPal payments in their Economy V2 integration. Support in SIS will be removed soon too.

info

Platforms having an own store do not allow PayPal payments for buying virtual goods as they want you to use their native billing system (e.g. Google Play or iTunes, so they can take their 30% cut).

If you would like to sell physical goods on these platforms (which is still allowed), please see the PayPal native guide instead.

Prerequisites

Make sure that you've read the PlayFab integration guide as well and understand all limitations implied by this dependency. Namely, your app needs an active internet connection at all times, in addition to providing a login system for restoring user purchases between sessions. This limitation could be lifted if you are only using PayPal for allowing donations and do not need to maintain a consistent user inventory for these type of in-app purchases.

Connecting PayPal with PlayFab

PayPal payments are a separate extension on your title's PlayFab page, which you can find in the Add-ons > Monetization tab. Click on the PayPal Add-on and enter the required details to enable it within PlayFab.

You can find your "PayPal Merchant ID" in your PayPal account, under Profile > Account settings > Merchant account ID, or just enter the email address you've registered with on PayPal. The "PayPal Return Link" is the page where users get redirected to after a complete or cancelled purchase. The order ID and token get attached to the url, so you could retrieve it for a custom action on your own server, for example. Otherwise, a simple public url would do, e.g. your game's support website, as the final transaction confirmation will happen in-game (more on this later).

PayPal-PlayFab010PayPal-PlayFab020

Adding PayPal account permissions

In the last chapter you've told PlayFab your PayPal credentials. But at this point, PlayFab still does not have the permission to execute anything on PayPal on your behalf. So in order to grant them access for handling your checkouts, you have to navigate to the following menu while logged in with your PayPal account: Tools > All Tools > API Access > Grant API permission, or click on this direct link for the third party permission page.

As the "Third Party Permission Username", enter billing_api1.playfab.com and press on "Lookup" to proceed to the permission administration page. The only permission you need to grant access to is the very first permission listed on the screenshot below - the permission for letting PlayFab do express checkouts for you. Check it and click on the "Add" button.

PayPal-PlayFab030

Shop setup in Unity

You are probably familiar with how the default shop scene in Simple IAP System is built: the IAPManager prefab usually gets carried over from a different (the first) scene, but the shop scene contains the UIShopFeedback prefab, and in its component inspector, references to a UI window for displaying success/error messages whenever users purchase a product.

Now with the PayPal integration, you might have noticed that there is an additional UI window, a confirmation window, in the scene that is also referenced on the UIShopFeedback prefab.

PayPal-PlayFab040

PayPal-PlayFab050

This confirmation window is necessary for completing any open PayPal transaction in-game. As the PayPal payment does not happen in-game, but in the user's browser (for security reasons), your app cannot know when the transaction has gone through successfully. Because of that, the transaction needs to be refreshed in-game after payment, so that it can be completed by PlayFab. In turn, the user is granted the appropriate product he purchased. This also means that without refreshing the transaction in-game, no reward will be given as the payment has not been authorized on PayPal's side (and no funds will be deducted on the user's PayPal account).

PayPal-PlayFab060

The confirmation window is being shown automatically at the time a PayPal payment gets initiated. It has two hidden buttons though, which are not shown right at the beginning: the actual refresh and close button. These buttons will only show up after a certain amount of time has passed (20 seconds by default). This is to ensure that the user cannot refresh the transaction right away (which would return a failed transaction state), but has actually to pay for the product in the browser first. If the refresh button is pressed in-game while the PayPal payment is not finished yet, the refresh button gets hidden for another 10 seconds, whereafter the user can retry again. A successful refresh disables the confirmation window.

Testing PayPal payments

Unfortunately, PlayFab does not support PayPal's sandbox environment. In order to test PayPal payments, you have to use a real PayPal account and pay real money. I would recommend setting up a product for $0.01 in Simple IAP System / PlayFab, so you are not losing that much money for testing per transaction. You also have to use two separate PayPal accounts for testing, as your PayPal (business) account cannot buy products from itself.

PayPal-PlayFab070

info

Please note that in case of issues with this process, I am not able to guess or remotely debug the exact cause for you. Since a major part of this guide is not written for Simple IAP System in particular, there is a high chance that your issue has been experienced by many, many other developers before and is covered somewhere already - debug your device, do a Google search for the error message and look out for popular PlayFab or PayPal developer threads!

tip

If you need help with the app setup, testing process or solving issues with your app's connection to PlayFab or PayPal, I am providing extended support for this via a PREMIUM support purchase.