Skip to content

Commit

Permalink
Merge pull request #7 from primer-io/jn/drop-in-example
Browse files Browse the repository at this point in the history
Drop-in Example App
  • Loading branch information
jnewc authored Mar 18, 2024
2 parents 1cfdcb4 + 6883112 commit c3d70ca
Show file tree
Hide file tree
Showing 47 changed files with 2,428 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ jobs:
max-parallel: 2
matrix:
project: [
{ scheme: 'Co-Badged Cards Example', path: 'Co-Badged Cards/SwiftUI/Co-Badged Cards Example.xcodeproj' }
{ scheme: 'Co-Badged Cards Example', path: 'Co-Badged Cards/SwiftUI/Co-Badged Cards Example.xcodeproj' },
{ scheme: 'Drop-in Checkout Example', path: 'Drop-in Checkout/SwiftUI/Drop-in Checkout Example.xcodeproj' }
]
steps:
- name: Cancel previous jobs
Expand Down
62 changes: 62 additions & 0 deletions Drop-in Checkout/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# 📲 Drop-in Checkout Example

This example demonstrates how to integrate drop-in checkout into your iOS app.

## Getting Started

To run the example app:

1. Clone the repo:

```sh
git clone https://github.com/primer-io/checkout-examples-ios.git
```

2. Change directory into the repo

```sh
cd "checkout-examples-ios/Drop-in Checkout/SwiftUI"
```

3. Open the project

```sh
open "Drop-in Checkout Example.xcodeproj"
```

4. Run the project from Xcode 🚀

----

This project requires a server to communicate with Primer's API. To get started quickly, we encourage you to use the [companion backend](https://github.com/primer-io/checkout-example-backend).

## Trying it out

This example app allows you to:

- Generate a client token
- Make a payment with one of your configured payment methods, using drop-in checkout

For card payments, we support several test cards for different cases. You can find these in our docs:

📄 **[Primer Payments Testing](https://primer.io/docs/payments/testing)**

## Understanding the integration

### PrimerDataService

This class contains all the business logic required to interact with the Primer SDK and start making payments.

This class is intended to be a `kitchen sink` that shows the whole integration in one place. You can use it to bootstrap your own integration.

### ExampleApp

This class contains two static properties that are used to auto-fill settings. You can get a head start by providing a client token or a URL for an endpoint serving client tokens directly in the code.

If you don't provide these, you can provide them on the app's start page once it's launched.

### ExampleAppLogger

This is a logger used to print useful messages during app execution.

You can find these logs by filtering on `[Drop-in Checkout Example App]` in the Xcode debug console.

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"pins" : [
{
"identity" : "primer-sdk-ios",
"kind" : "remoteSourceControl",
"location" : "https://github.com/primer-io/primer-sdk-ios.git",
"state" : {
"revision" : "1c47e744c228057504a6bb3aa4d2279d4e5e0ff0",
"version" : "2.22.1"
}
}
],
"version" : 2
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1500"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "04FAF9F52AE81563002E4BAE"
BuildableName = "Drop-in Checkout Example.app"
BlueprintName = "Drop-in Checkout Example"
ReferencedContainer = "container:Drop-in Checkout Example.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
<Testables>
<TestableReference
skipped = "NO"
parallelizable = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "04FAFA052AE81565002E4BAE"
BuildableName = "Drop-in Checkout ExampleTests.xctest"
BlueprintName = "Drop-in Checkout ExampleTests"
ReferencedContainer = "container:Drop-in Checkout Example.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO"
parallelizable = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "04FAFA0F2AE81565002E4BAE"
BuildableName = "Drop-in Checkout ExampleUITests.xctest"
BlueprintName = "Drop-in Checkout ExampleUITests"
ReferencedContainer = "container:Drop-in Checkout Example.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "04FAF9F52AE81563002E4BAE"
BuildableName = "Drop-in Checkout Example.app"
BlueprintName = "Drop-in Checkout Example"
ReferencedContainer = "container:Drop-in Checkout Example.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "04FAF9F52AE81563002E4BAE"
BuildableName = "Drop-in Checkout Example.app"
BlueprintName = "Drop-in Checkout Example"
ReferencedContainer = "container:Drop-in Checkout Example.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"images" : [
{
"filename" : "[email protected]",
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "icon-primer@3x(1).png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "icon-primer@3x(1) 1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "icon-primer@3x(1) 2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "icon-primer@3x(1).png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="22155" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<device id="retina6_12" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22131"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="393" height="852"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="obG-Y5-kRd">
<rect key="frame" x="0.0" y="832" width="393" height="0.0"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="LaunchImage.png" translatesAutoresizingMaskIntoConstraints="NO" id="Wah-0U-38u">
<rect key="frame" x="84.666666666666686" y="318.66666666666669" width="240" height="240.00000000000006"/>
<constraints>
<constraint firstAttribute="width" constant="240" id="jje-3b-xbB"/>
<constraint firstAttribute="height" constant="240" id="lux-vk-H3c"/>
</constraints>
</imageView>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Drop-in Checkout Example" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="GJd-Yh-RWb">
<rect key="frame" x="16" y="582.66666666666663" width="361" height="37"/>
<constraints>
<constraint firstAttribute="height" constant="37" id="FFz-uI-7OD"/>
</constraints>
<fontDescription key="fontDescription" type="boldSystem" pointSize="31"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<viewLayoutGuide key="safeArea" id="Bcu-3y-fUS"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstItem="Bcu-3y-fUS" firstAttribute="centerX" secondItem="obG-Y5-kRd" secondAttribute="centerX" id="5cz-MP-9tL"/>
<constraint firstItem="Bcu-3y-fUS" firstAttribute="trailing" secondItem="GJd-Yh-RWb" secondAttribute="trailing" constant="16" id="7um-Qg-9XU"/>
<constraint firstItem="Wah-0U-38u" firstAttribute="centerY" secondItem="Bcu-3y-fUS" secondAttribute="centerY" id="RJ2-E5-ZBh"/>
<constraint firstItem="GJd-Yh-RWb" firstAttribute="top" secondItem="Wah-0U-38u" secondAttribute="bottom" constant="24" id="Rxf-5O-TMQ"/>
<constraint firstItem="obG-Y5-kRd" firstAttribute="leading" secondItem="Bcu-3y-fUS" secondAttribute="leading" symbolic="YES" id="SfN-ll-jLj"/>
<constraint firstAttribute="bottom" secondItem="obG-Y5-kRd" secondAttribute="bottom" constant="20" id="Y44-ml-fuU"/>
<constraint firstItem="Wah-0U-38u" firstAttribute="centerX" secondItem="Bcu-3y-fUS" secondAttribute="centerX" constant="8" id="la2-tc-nzO"/>
<constraint firstItem="GJd-Yh-RWb" firstAttribute="leading" secondItem="Bcu-3y-fUS" secondAttribute="leading" constant="16" id="oMA-uE-Pcg"/>
</constraints>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="52.671755725190835" y="374.64788732394368"/>
</scene>
</scenes>
<resources>
<image name="LaunchImage.png" width="18" height="18"/>
</resources>
</document>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// LaunchScreenViewController.swift
// Drop-in Checkout Example
//
// Created by Jack Newcombe on 02/11/2023.
//

import Foundation
import UIKit

class LaunchScreenViewController: UIViewController {

@IBOutlet var imageView: UIImageView!

override func viewDidLoad() {
self.imageView.image = UIImage(named: "primer-icon")
}
}
Loading

0 comments on commit c3d70ca

Please sign in to comment.