Important: PayPal Mobile SDKs are Deprecated. The APIs powering them will remain operational long enough for merchants to migrate, but the SDKs themselves will no longer be updated. Please use Braintree Direct in supported countries. In other countries, use Express Checkout and choose the Braintree SDK integration option.
PayPal iOS SDK
The PayPal iOS SDK makes it easy to add PayPal payments to mobile apps.
This documentation is available in Japanese: ๆฅๆฌ่ชใฎใใญใฅใกใณใ.
Note
There are 4 static libraries that you should link when building your application.
libPayPalMobile.a
,libCardIO.a
,libopencv_core.a', and
libopencv_imgproc.a` are required for all of the SDK functionality.The current version of the PayPal iOS SDK was built using Xcode 8.3.2.
Contents
- Use Cases
- Requirements
- Add the SDK to Your Project
- Credentials
- International Support
- Testing
- Documentation
- Usability
- Next Steps
Use Cases
The SDK supports two use cases for making payments - Single Payment and Future Payments - and a third use case for obtaining information about the customer - Profile Sharing.
Single Payment
Receive a one-time payment from a customer's PayPal account. This can be either (1) an immediate payment which your servers should subsequently verify, or (2) an authorization for a payment which your servers must subsequently capture, or (3) a payment for an order which your servers must subsequently authorize and capture:
- Accept a Single Payment and receive back a proof of payment.
- On your server, Verify the Payment, Capture the Payment, or Process the Order (PayPal Developer site) using PayPal's API.
Note: Direct Credit Card (DCC) payments are now deprecated in this SDK. Please use Braintree Payments, a PayPal Company, which is the easiest way to accept PayPal, credit cards, and many other payment methods.
Future Payments
Your customer logs in to PayPal just one time and consents to future payments:
- Obtain Customer Consent to receive an authorization code.
- On your server, use this authorization code to Obtain OAuth2 Tokens.
Later, when that customer initiates a payment:
- Obtain a Client Metadata ID that you'll pass to your server.
- On your server, Create a Payment using your OAuth2 tokens, the Client Metadata ID, and PayPal's API.
Profile Sharing
Your customer logs in to PayPal and consents to PayPal sharing information with you:
- Obtain Customer Consent to receive an authorization code.
- On your server, use this authorization code to Obtain OAuth2 Tokens.
- On your server, Retrieve Customer Information using your OAuth2 tokens and PayPal's API.
Requirements
- Xcode 8 and iOS SDK 10
- iOS 7.0+ target deployment
- armv7, armv7s, and arm64 devices, and the simulator (not armv6)
- iPhone and iPad of all sizes and resolutions
Add the SDK to Your Project
CocoaPods, then add these lines to your podfile:
If you useplatform :ios, '7.0'
pod 'PayPal-iOS-SDK'
If you don't use CocoaPods, then:
- Clone or download the SDK, which consists of header files, license acknowledgements, release notes, and a static library. It also includes a sample app.
- As of version 2.17.0, the SDK requires Xcode 8 and iOS 10 SDK.
- Add the
PayPalMobile
directory (containing several .h files and libPayPalMobile.a) to your Xcode project. We recommend checking "Copy items..." and selecting "Create groups...". - In your project's Build Settings (in the
TARGETS
section, not thePROJECTS
section):
- add
-lc++ -ObjC
toOther Linker Flags
- enable
Enable Modules (C and Objective-C)
- enable
Link Frameworks Automatically
- In your project's Build Phases, link your project with these libraries. Weak linking for iOS versions back to 6.0 is supported.
Accelerate.framework
AudioToolbox.framework
AVFoundation.framework
CoreLocation.framework
CoreMedia.framework
MessageUI.framework
MobileCoreServices.framework
SystemConfiguration.framework
SafariServices.framework
With or without CocoaPods:
- Add the open source license acknowledgments from acknowledgments.md to your app's acknowledgments.
- In your app's Info.plist, add the following URL schemes to
LSApplicationQueriesSchemes
:
com.paypal.ppclient.touch.v1
com.paypal.ppclient.touch.v2
org-appextension-feature-password-management
Credentials
Your mobile integration requires different client_id
values for each environment: Live and Test (Sandbox).
Your server integrations for verifying or creating payments will also require the corresponding client_secret
for each client_id
.
You can obtain these PayPal API credentials by visiting the Applications page on the PayPal Developer site and logging in with your PayPal account.
Sandbox
Once logged in on this Applications page, you will be assigned test credentials, including Client ID, which will let you test your iOS integration against the PayPal Sandbox.
While testing your app, when logging in to PayPal in the SDK's UI you should use a personal Sandbox account email and password. I.e., not your Sandbox business credentials.
You can create both business and personal Sandbox accounts on the Sandbox accounts page.
Live
To obtain your live credentials, you will need to have a business account. If you don't yet have a business account, there is a link at the bottom of that same Applications page that will get you started.
International Support
Localizations
The SDK has built-in translations for many languages and locales. See the header files for a complete list.
Currencies
The SDK supports multiple currencies. See the REST API country and currency documentation for a complete, up-to-date list.
If your app initiates a transaction with a currency that turns out to be unsupported for the user's selected payment type, then the SDK will display an error to the user and write a message to the console log.
Testing
During development and testing, set the environment to Sandbox or NoNetwork/Mock mode, to avoid moving real money around. See the header files for more information.
Documentation
- These docs in the SDK, which include an overview of usage, step-by-step integration instructions, and sample code.
- The sample app included in this SDK.
- Header files are thoroughly documented; refer to them as needed for extra details about any given property or parameter.
- The PayPal Developer Docs, which cover error codes and server-side integration instructions.
Support
When opening an issue, please include the environment (live or sandbox), SDK version, and a PayPal-Debug-ID
. The console log may have something like:
PayPal SDK: Request has failed with error: INTERNAL_SERVICE_ERROR - System error. Please try again later. (500) | PayPal Debug-ID: 463acd5lba23c [live, PayPal iOS SDK 2.14.1]
Additionally, information about the types of devices (iPhone 6s Plus, iPhone 5), iOS version, and any non-standard settings would be helpful to provide.
For merchant-specific issues, you should use the PayPal Merchant Technical Support site to open an issue.
Please do not post your client ID or secret in an issue.
Usability
User interface appearance and behavior is set within the library itself. For the sake of usability and user experience consistency, apps should not adjust appearance properties or attempt to modify the SDK's behavior beyond the documented methods in the provided headers.
Specifically, if you are using UIAppearance
to modify the appearance of any UI elements in your app, you should reverse those changes prior to presenting our viewcontroller, and set them again after dismissing the viewcontroller.
Next Steps
Depending on your use case, you can now:
- Accept a single payment
- Obtain user consent to create future payments.
- Obtain user consent to retrieve customer information.
Contributing
Please read our contributing guidelines prior to submitting a Pull Request.
License
Please refer to this repo's license file.