PayPal iOS SDK

Related tags

Official SDK iOS-SDK
Overview

PayPal iOS SDK

Welcome to PayPal's iOS SDK. This library will help you accept card, PayPal, Venmo, and alternative payment methods in your iOS app.

Support

The PayPal iOS SDK supports a minimum deployment target of iOS 13+ and requires Xcode 13+ and macOS Big Sur 11.3+. See our Client Deprecation policy to plan for updates.

Package Managers

This SDK supports:

  • CocoaPods
  • Swift Package Manager

Languages

This SDK supports Swift 5.1+. This SDK is written in Swift.

UI Frameworks

This SDK supports:

  • UIKit
  • SwiftUI

Modularity

The PayPal iOS SDK is comprised of various submodules.

  • Card
  • PayPal
  • ...

To accept a certain payment method in your app, you only need to include that payment-specific submodule.

Sample Code

// STEP 0: Fetch an ACCESS_TOKEN and ORDER_ID from your server.

// STEP 1: Create a PaymentConfiguration object
paymentConfig = PaymentConfig(token: ACCESS_TOKEN)

// STEP 2: Create payment method client objects
cardClient = CardClient(config: paymentConfig)

// STEP 3: Collect relevant payment method details
card = Card(number: 4111111111111111, cvv: 123, ...)

// STEP 4: Call checkout method
cardClient?.checkoutWithCard(orderID: ORDER_ID, card: card) { result in
    switch result {
    case .success(let orderId):
      // Send orderID to your server to process the payment
    case .error(let error):
      // handle checkout error
    }
}

// STEP 5: Send orderID to your server to capture/authorize

Testing

This project uses the XCTest framework provided by Xcode. Every code path should be unit tested. Unit tests should make up most of the test coverage, with integration, and then UI tests following.

This project also takes advantage of Fastlane to run tests through our CI and from terminal. In order to invoke our unit tests through terminal, run the following commands from the root level directory of the repository:

bundle install
bundle exec fastlane unit_tests

If you would like to get the code coverage for all of the modules within the iOS-SDK, run the following:

bundle install
bundle exec fastlane coverage

CI

GitHub Actions CI will run all tests and build commands per package manager on each PR.

Local Testing

TBD until development progresses. We will use Rake, Fastlane, or some other tool for easy command-line build tasks.

Release Process

This SDK follows Semantic Versioning. The release process will be automated via GitHub Actions.

Analytics

Client analytics will be collected via Lighthouse/FPTI.

Comments
  • PayPalUI: Separate buttons for SwiftUI and UIKit

    PayPalUI: Separate buttons for SwiftUI and UIKit

    Reason for changes

    The buttons all extended from PaymentButton, which is in essence a UIButton. In order to make the buttons available on SwiftUI, the buttons conformed to the UIViewRepresentable protocol as well. As of iOS 16, we started getting: Fatal error: UIViewRepresentables must be value types: PayPalButton. Any SwiftUI view must be a struct and cannot inherit from any class, only conform to protocols. So, this PR splits the buttons into two classes, one for UIKit and another one for SwiftUI. The SwiftUI ones are essentially a container to theUIKit buttons.

    Summary of changes

    • Refactor to split the buttons into UIKit and SwiftUI implementations
    • UIKit Buttons: UIPaPalButton, UIPayPalPayLaterButton and UIPayPalCreditButton
    • SwiftUI buttons: PayPalButton, PayPalPayLaterButton and PayPalCreditButton

    Checklist

    • [ ] Added a changelog entry

    Authors

    List GitHub usernames for everyone who contributed to this pull request.

    • @jcnoriega
    opened by jcnoriega 22
  • Add Fastlane

    Add Fastlane

    Reason for changes

    We can use Fastlane to

    1. Run tests locally and (potentially) via Github Actions
    2. Release the SDK via each of our dependency managers as part of our CI process
    3. Attach code coverage test reports / code coverage reports to PRs (in conjunction with GH actions)

    These are all things that can be done via a rakefile or exclusively through GH actions, but using fastlane means we can take advantage of the built in fastlane actions (https://docs.fastlane.tools/actions/), as well as have flexibility to run lanes from the command line instead of relying exclusively on GH actions to not fail.

    In order to run fastlane via CI, we would just need to run bundle exec fastlane tests

    Summary of changes

    • Added a Gemfile and a Fastfile
    • Added a single lane to execute our unit tests
    • Edited the test scheme to be able to run all of our test targets (this was causing the test command to fail)
    opened by jonathajones 12
  • HTTPClient

    HTTPClient

    Reason for changes

    This PR adds an HTTPClient to allow for a single HTTPResponse type used to simplify the response of a (URLResponse?, Data?, Error?) result from URLSession data tasks.

    Summary of changes

    • Create API and HTTP protocols
    • Create HTTPClient and APIClient to use HTTPClient
    • Move response parsing up a level in CardClient
    • Create MockAPIClient and MockHTTPClient to use in unit tests

    Checklist

    ~- [ ] Added a changelog entry~

    opened by sshropshire 7
  • Create Xcode Workspace, Demo, & Package project

    Create Xcode Workspace, Demo, & Package project

    Summary

    This PR:

    • Adds root-level PayPal.xcworkspace. This workspace will be the main workstation for this project.
      • The workspace contains two xcodeproj files. One is for the Demo, the other is for the framework's source code & tests.
      • The Demo app imports the Card and PayPal modules.
    • Adds framework targets for PaymentsCore, Card, and PayPal modules.
      • The code in here is "Dummy" code that is included for us to test that the project setup works (meant to be replaced).
      • The Card and PayPal modules depend on PaymentsCore. We can follow this pattern when adding new payment methods in the future.
    • Adds unit test targets for each module.
    • Adds Demo, UnitTest, Card, PayPal, and PaymentCore schemes.
    • Adds a Package.swift & PayPal.podspec.

    Notes

    This PR will be much easier to review by checking out the branch and opening PayPal.xcworkspace. The auto-generated Xcode code is a lot.

    This project requires Xcode 13-beta.

    What's Next

    • Add GitHub Actions CI
      • Add build commands per package manager
    • Add UITest & IntegrationTest targets
    • Create README from HackMD iOS RFC
    • Add Rakefile (or Fastlane) setup for running tests locally
      • Add instructions for running these commands in README
    • Create new, shared, development team for Demo App signing. (Currently using Braintree Payment Solutions, LLC)
    • Add Demo app Icon

    Screenshot

    Screen Shot 2021-08-02 at 6 05 40 PM
    opened by scannillo 7
  • Card: Add ApplicationContext to ConfirmPaymentSourceRequest

    Card: Add ApplicationContext to ConfirmPaymentSourceRequest

    Reason for changes

    There was a bug in ordersv2 where we had to add appliction_context to the order creation request, in order for 3DS to work. Now, we only have to add it in the confirm_payment_source request, removing it from order creation

    Jira Ticket: https://engineering.paypalcorp.com/jira/browse/DTNOR-606

    Summary of changes

    • Add Application context to ConfirmPaymentSourceRequestFactory

    Checklist

    • [ ] Added a changelog entry

    Authors

    List GitHub usernames for everyone who contributed to this pull request.

    • @jcnoriega
    opened by jcnoriega 5
  • Card Client Confirm Payment Source

    Card Client Confirm Payment Source

    Reason for changes

    This PR updates the CardClient API to better align with the Orders v2 API. In the future, we may revisit API naming to improve the developer experience.

    Summary of changes

    • Rename CardClient approveOrder method to confirmPaymentSource

    Checklist

    ~- [ ] Added a changelog entry~

    opened by sshropshire 5
  • PayPal and PayPal Credit Buttons SwiftUI Representable

    PayPal and PayPal Credit Buttons SwiftUI Representable

    Reason for changes

    To represent a button in SwiftUI we need the buttons to be represented as a UIViewRepresentable. Taking a look at some best practices across other SDKs, extending the button and adding a Representable struct is the best way to do this. We also needed a coordinator class to coordinate the button actions. While there is some duplication involved, adding this to our SDK allows for us to account for merchants using either/both UIKit and SwiftUI without needing to build out this logic themselves.

    Adding this to our SDK allows a merchant to do the following to create a button in their SwiftUI view:

    PayPalButton {
        // button action here
    }
    

    This very closely models the way a merchant would do this in standard SwiftUI without a representable:

    Button("Title") {
        // button action here
    }
    

    Summary of changes

    • Add Coordinator class to pass action to UIKit button in SwiftUI
    • Add PayPalButton and PayPalCreditButton as UIViewRepresentable conforming classes
    • Add both buttons to the SwiftUIPayPalDemo
    • Moved shared PayPal logic to BaseViewModel - this could probably use a refactor in the future

    Checklist

    • ~[ ] Added a changelog entry~

    Authors

    List GitHub usernames for everyone who contributed to this pull request.

    • @jaxdesmarais @sarahkoop
    opened by jaxdesmarais 5
  • Add Swiftlint Build Phase Script

    Add Swiftlint Build Phase Script

    Reason for changes

    This will allow us to see the linter warnings via Xcode when building instead of needing to wait for CI to finish to see them. If you've not installed swiftlint yet on your machine, to run the linter the first time you will need to install via:

    brew install swiftlint
    

    Once you install swiftlint via homebrew, you will not need to run the above command again.

    Summary of changes

    • Display swiftlint warnings inline
    • Make us all a little happier

    Checklist

    • ~[ ] Added a changelog entry~

    Authors

    List GitHub usernames for everyone who contributed to this pull request.

    • @jaxdesmarais
    opened by jaxdesmarais 5
  • PayPalUI Module

    PayPalUI Module

    Reason for changes

    This PR creates the PayPalUI module for iOS to separate PayPal SDK UI elements from other modules.

    Summary of changes

    • Create PayPalUI module

    Checklist

    ~- [ ] Added a changelog entry~

    opened by sshropshire 4
  • Paypal integration + demo

    Paypal integration + demo

    Reason for changes

    We need to integrate with PayPalCheckout and provide support for PayPal paysheet to handle PayPal transaction

    Summary of changes

    • Add PayPalCheckout as dependency for PayPal module
    • Add PayPalError and PayPalResult
    • Add PayPalPaysheet and PayPalCompletionState

    Sample integration

    class MerchantViewController: UIViewController {
        let config = CoreConfig(clientID: "clientID", environment: .sandbox)
        let paypalClient = PayPalClient(config: coreConfig, returnUrl: "returnUrl")
    
        func checkoutWithPayPal(orderID: String) {
            paypalClient.start(presentingViewController: self, orderID: orderID) { state in
                switch state {
                    case .success(let result):
                        print("Order is successfully approved and ready to be captured/authorized")
                    case .failure(let error):
                        print("There's an error: \(error)")
                    case .cancellation:
                        print("Buyer has canceled checkout")
                }
            }
        }
    }
    

    Checklist

    • [ ] Added a changelog entry

    Authors

    • @scannillo
    • @jonathajones
    • @jaxdesmarais
    • @minhthenguyen
    opened by minhthenguyen 4
  • Initial FPTI Networking Capability

    Initial FPTI Networking Capability

    Reason for changes

    • We want Northstar Mobile SDKs to send all analytics to FPTI. This PR sets up a very basic implementation of sending an analytic event to FPTI via APIClient.sendAnalyticsEvent().
    • In follow PRs we will address:
      • Batch event uploads
      • Refactoring into separate AnalyticsAPI if necessary / aligning with Android
      • Sending actual events in source code
      • Testing the sendAnalyticsEvent() function, once it is actually used

    Summary of changes

    • Add AnalyticsEventRequest type which conforms to APIRequest
    • Add AnalyticsEventRequest_Tests for validating metadata sent
    • Add encodable models for Analytics JSON post body

    Checklist

    • ~Added a changelog entry~ Will update CHANGELOG once events are sent.

    Authors

    @mattwylder @scannillo

    opened by scannillo 3
  • simplify code for getting presentation anchor

    simplify code for getting presentation anchor

    Reason for changes

    1. Simplify code snippet for retrieving presentation anchor
    2. couldn't fix runtime warning of running on background thread

    Summary of changes

    Checklist

    • [ ] Added a changelog entry

    Authors

    List GitHub usernames for everyone who contributed to this pull request.

    • @kgangineni @scannillo
    opened by kgangineni 1
Releases(0.0.3)
  • 0.0.3(Nov 3, 2022)

  • 0.0.2(Nov 3, 2022)

    • PayPalUI

      • Fix fatal crash with iOS 16: UIViewRepresentables must be value types. Separate buttons into UIKit and SwiftUI implementations.

        | UIKit | SwiftUI | | ----------- | ----------- | | PayPalButton | PayPalButton.Representable | | PayPalCreditButton | PayPalCreditButton.Representable | | PayPalPayLaterButton | PayPalPayLaterButton.Representable |

    • PayPalNativeCheckout

      • Update to version 0.109.0 that fixes shipping callback bug
    • Bump minimum supported deployment target to iOS 14+

    • Require Xcode 14

      • Bump Swift Tools Version to 5.7 for CocoaPods & SPM
    Source code(tar.gz)
    Source code(zip)
  • 0.0.1(Jul 21, 2022)

    • Card

      • Add Address
      • Add Card
      • Add CardClient
      • Add CardRequest
      • Add CardResult
    • PayPalCheckout

      • Add PayPalWebCheckout
    • PayPalUI

      • Add PayPalButton Button
      • Add PayPalPayLater Button
      • Add PayPalCredit Button
    • PayPalDataCollector

      • Add PayPalDataCollector
      • Add MagnesSDK
    Source code(tar.gz)
    Source code(zip)
Owner
PayPal
PayPal
Px-mobile-sdk-demo-app - PerimeterX Mobile SDK - Demo App

About PerimeterX PerimeterX is the leading provider of application security solu

PerimeterX 1 Nov 20, 2022
Alter SDK is a cross-platform SDK consisting of a real-time 3D avatar system, facial motion capture, and an Avatar Designer component built from scratch for web3 interoperability and the open metaverse.

Alter SDK is a cross-platform SDK consisting of a real-time 3D avatar system, facial motion capture, and an Avatar Designer component built from scratch for web3 interoperability and the open metaverse.

Alter 45 Nov 29, 2022
Native iOS implementation of RadarCOVID tracing client using DP3T iOS SDK

RadarCOVID iOS App Introduction Native iOS implementation of RadarCOVID tracing client using DP3T iOS SDK Prerequisites These are the tools used to bu

Radar COVID 146 Nov 24, 2022
TelegramStickersImport — Telegram stickers importing SDK for iOS

TelegramStickersImport — Telegram stickers importing SDK for iOS TelegramStickersImport helps your users import third-party programaticaly created sti

null 35 Oct 26, 2022
Muxer used on top of Feed iOS SDK for airplay

FeedAirplayMuxer Muxer used on top of Feed iOS SDK for airplay purposes. Demo Project --> https://github.com/feedfm/AirplayDemo Feed Airplay Muxer is

Feed Media 0 May 6, 2022
Basispay IOS SDK Version 2

BasisPay-IOS-KIT BasisPay IOS Payment Gateway kit for developers INTRODUCTION This document describes the steps for integrating Basispay online paymen

null 0 Oct 21, 2021
Release repo for Gini Bank SDK for iOS

Gini Bank SDK for iOS The Gini Bank SDK provides components for capturing, reviewing and analyzing photos of invoices and remittance slips. By integra

Gini GmbH 1 Dec 6, 2022
Da Xue Zhang Platform Lvb iOS SDK

Cloud_Lvb_SDK iOS API Reference Dxz Meeting iOS SDK是为 iOS 平台用户音视频服务的开源 SDK。通过大学长开放平台自研RTC,RTM系统,为客户提供质量可靠的音视频服务。 类 类名 描述 CLS_PlatformManager SDK的音视频主要

null 8 Jan 10, 2022
Unofficial Notion API SDK for iOS & macOS

NotionSwift Unofficial Notion SDK for iOS & macOS. This is still work in progress version, the module interface might change. API Documentation This l

Wojciech Chojnacki 59 Jan 8, 2023
150,000+ stickers API & SDK for iOS Apps.

English | 한국어 Stipop UI SDK for iOS Stipop SDK provides over 150,000 .png and .gif stickers that can be easily integrated into mobile app chats, comme

Stipop, Inc. 19 Dec 20, 2022
Spotify SDK for iOS

Spotify iOS SDK Overview The Spotify iOS framework allows your application to interact with the Spotify app running in the background on a user's devi

Spotify 522 Jan 6, 2023
Headless iOS/Mac SDK for saving stuff to Pocket.

This SDK is deprecated Howdy all! ?? Thanks for checking out this repo. Your ?? mean a lot to us. ?? Unfortunately, this project is deprecated, and th

Pocket 230 Mar 18, 2022
Evernote Cloud SDK for iOS

Evernote Cloud SDK 3.0 for iOS This is the official Evernote SDK for iOS. To get started, follow the instructions bellow. Additional information can b

Evernote 256 Oct 6, 2022
iOS SDK for the Box Content API

Box iOS SDK Getting Started Docs: https://developer.box.com/guides/mobile/ios/quick-start/ NOTE: The Box iOS SDK in Objective-C (prior to v3.0.0) has

Box 112 Dec 19, 2022
OneDrive SDK for iOS

Get started with the OneDrive SDK for iOS Integrate the OneDrive API into your iOS app! 1. Installation Install via Cocoapods Install Cocoapods - Foll

OneDrive 101 Dec 19, 2022
Stripe iOS SDK

Stripe iOS SDK The Stripe iOS SDK makes it quick and easy to build an excellent payment experience in your iOS app. We provide powerful and customizab

Stripe 1.8k Jan 5, 2023
AWS SDK for iOS. For more information, see our web site:

AWS SDK for iOS The AWS SDK for iOS provides a library and documentation for developers to build connected mobile applications using AWS. Features / A

AWS Amplify 1.6k Dec 26, 2022
Zendesk Mobile SDK for iOS

⚠️ This Repository has been deprecated, please go to here for the Zendesk Support SDK ⚠️ Zendesk Mobile SDK for iOS Zendesk SDK for mobile is a quick,

Zendesk 113 Dec 24, 2022
PlayKit: Kaltura Player SDK for iOS

Kaltura Player SDK Demo: Demo repo. If you are a Kaltura customer, please contact your Kaltura Customer Success Manager to help facilitate use of this

Kaltura 77 Jan 3, 2023