Skip to main content

PayPal

This guide explains how to create and configure in-app purchases using PayPal payments.

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).

However, using PayPal on these platforms is still allowed for selling physical goods, such as t-shirts, stuffed animals and other merchandise, which the native stores do not support selling.

Prerequisites

danger

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 or subscriptions 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 and updating subscription states 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 implementation would be a better choice.

Register developer account

Create a PayPal merchant account or login using your existing merchant account on the developer dashboard: https://developer.paypal.com/

Create your app

Navigate to Apps & Credentials and either use the Default Application or create a new one. For this guide, I am using the system generated Default Application.

Copy your Sandbox Client ID and Secret values for this app. You will need them later.

PayPal-Native010

Switch to Production and use or create a Default Application there too. Copy your Production Client ID and Secret values for later.

PayPal-Native020

Test Accounts

Navigate to Testing Tools > Sandbox Accounts and create a Business Account and at least one Personal Account for testing. Their password can be displayed at any time, so there is no need to remember them.

PayPal-Native030

Subscriptions

Make sure that you meet the prerequisites mentioned above before adding subscriptions. Please note that subscription plans are not added in the Developer Dashboard, but on the Business Accounts directly.

Log into sandbox.paypal.com with your Sandbox Business Account and password created in the previous step. Then, navigate to Pay & Get Paid > Accept Payments > Subscriptions, Subscription plans tab. Create a plan with the same product identifier used in Simple IAP System. The plan ID will be generated by PayPal.

PayPal-Native040

info

Now, do the same with your live Business Account on paypal.com !

Setup in Unity

Copy-paste the Client ID and Secret credentials for both Sandbox and Production into the Simple IAP System Setup window. Unity IAP needs to be imported and enabled.

PayPal-Native050

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.

PayPal-Native060

tip

You can set all products to use PayPal billing within a category at once, by using the Overrides tab on a Category (instead of a product).

Since when using subscriptions PayPal generated a cryptic product ID for you, it makes also sense to add a product ID override, so that this generic product ID is not displayed to the user anywhere.

PayPal-Native070

danger

Simple IAP System does not support different product overrides for Sandbox and Production environments. If you are testing subscriptions on Sandbox, the product override ID needs to be your Sandbox plan ID (from sandbox.paypal.com)! When going live, do not forget to replace this with your Production plan ID (from paypal.com)!

Testing payments

If you've followed this guide until now, you have already created test accounts in a previous step, namely a Business Account and at least one Personal Account. A sandbox business account is a merchant account, where test payments are routed to. A sandbox personal account is a client account used to do a test purchase. Meaning, after logging in with the sandbox personal account for buying a product in your app, you will see the change in balance on the sandbox 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 sandbox.paypal.com. Navigate to Account Settings > Payment preferences > Block Payments. Make sure that the first or third option is selected - otherwise, payments will never complete automatically.

PayPal-Native080

info

Do the same with your live Business Account on paypal.com !

Finally, launch your app and buy the product you've enabled PayPal for. Notice that by clicking the purchase button, an in-game popup opens, as well as a new browser page.

Feature-Windows022

On the PayPal payment page, enter the sandbox personal account credentials and complete the payment process.

PayPal-Native090

Back in Unity, press the CONFIRM button to confirm your transaction.

Feature-Windows021

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.

By default, Simple IAP System always connects to the PayPal Sandbox environment in the Unity Editor, or if you have Development Build enabled under File > Build Settings. If you wish to deploy to Production, check your production PayPal credentials in the Project Settings and disable Development Build.

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 PayPal developer threads!

tip

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