Guide: PayPal (native)
This guide explains how to create and configure in-app purchases using PayPal payments. Note that 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). However, using PayPal on these platforms is allowed for selling physical goods, such as t-shirts, stuffed animals and other merchandise, which the native stores do not support selling.
Table of Contents:
- Register developer account
- Create your app
- Setup in Unity
- Testing payments
If you decide on accepting PayPal payments within your app, there are a few limitations and restrictions you need to be aware of:
- You can only implement a third-party payment provider (like PayPal) when distributing your app by other means or on an App Store that do not have their own payment service. For example, Google Play and Apple have their own native billing service and by accepting their terms, you are forced into using that for in-app purchases.
- PayPal can still be used on platforms such as Google Play, but only for selling goods outside the app (physical goods). For products that exist in the app, you have to use their native billing (see previous point).
- PayPal does not offer its own user login and inventory service. This means: if users purchase products within your app using PayPal, they would lose access to them after switching devices or uninstalling the app. You are responsible for either providing a login and inventory system and storing purchases on your server, or only offering one-time payments that do not need to be saved anywhere (e.g. consumables, donations or physical goods).
- If you are looking for a payment solution including cloud save (user login and inventory) without the need of managing your own server, maybe the PlayFab or Xsolla implementations would be a better choice.
2. Register developer account
Create a PayPal merchant account or login using your existing merchant account on the developer dashboard:
3. Create your app
You can either use the "Default Application" that was created automatically for you, or create a new app in order to receive your app key & secret. For this guide, I am using the system generated Default Application.
Notice the Sandbox & Live toggle at the top - when switching to Live, you definitely have to create a separate app, as there is no system generated one. You can find your credentials when opening the application page.
4. Setup in Unity
Copy-paste the credentials created previously into the Simple IAP System Setup window. Unity IAP needs to be imported and enabled, since this implementation uses the Unity IAP store interfaces.
You might wonder what the currency code and return URL is for. The currency code is a 3-character code for defining your receiving currency, e.g. USD or EUR. For other supported currency codes please refer to the official documentation.
The Return URL is the URL users get redirected to after payment. This could be a custom "Thank you" website, or a server page processing purchase information. Typically this is just a page on your website or domain.
With the billing setup as seen in the screenshot above, Simple IAP System would still use Unity IAP for all products on all platforms, not PayPal. In the next step, we have to explicitly tell Simple IAP System for which products we would like to use PayPal.
Navigate to the desired product. In its Overrides section, enable PayPal as the target billing provider.
5. Testing payments
Back in the PayPal developer dashboard, navigate to the Accounts section. You will find two pre-existing accounts, one with type Business and Personal respectively. You can see their default password by opening the "Manage accounts" popup.
The Business account is a sandbox merchant account, where test payments are routed to. A Personal account is a client account used to do a test purchase. So, after using the Personal account for buying a product in your app, you will see the change in balance on the Business account.
Before doing a test purchase, there is one additional step you definitely want to look into - in case you've read the PayPal documentation page above about currency codes, it is mentioned that by default, PayPal declines all payments in a different currency than specified on your PayPal account. You can change this behavior into accepting but converting all currencies, which I would recommend.
Log into your sandbox Business account on the sandbox.paypal.com page (the live page will not work for sandbox users). Navigate to Account Settings > Payment preferences > Block Payments. Make sure that the first or third option is selected - otherwise, payments will never complete automatically.
Finally, launch your app and buy the product you've enabled PayPal for. In my case, it was the "bundle" product. Notice that by clicking the purchase button, a transaction popup in-game, as well as a new browser page opens.
On the PayPal payment page, enter the sandbox Personal account credentials and complete the payment process.
Back in Unity, press the "REFRESH" button to confirm your transaction. In case of a non-consumable item, the product will be rewarded and set to purchased locally.
You've made it! If you wish to, you can also double check the completed transaction and shipping details by logging into the sandbox Business account again.