-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from primer-io/jn/drop-in-example
Drop-in Example App
- Loading branch information
Showing
47 changed files
with
2,428 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
824 changes: 824 additions & 0 deletions
824
Drop-in Checkout/SwiftUI/Drop-in Checkout Example.xcodeproj/project.pbxproj
Large diffs are not rendered by default.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
...t/SwiftUI/Drop-in Checkout Example.xcodeproj/project.xcworkspace/contents.xcworkspacedata
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
...p-in Checkout Example.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
14 changes: 14 additions & 0 deletions
14
...p-in Checkout Example.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
101 changes: 101 additions & 0 deletions
101
...op-in Checkout Example.xcodeproj/xcshareddata/xcschemes/Drop-in Checkout Example.xcscheme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
11 changes: 11 additions & 0 deletions
11
...wiftUI/Drop-in Checkout Example/Assets/Assets.xcassets/AccentColor.colorset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"colors" : [ | ||
{ | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
.../SwiftUI/Drop-in Checkout Example/Assets/Assets.xcassets/AppIcon.appiconset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
Binary file added
BIN
+82.1 KB
...Checkout Example/Assets/Assets.xcassets/AppIcon.appiconset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions
6
Drop-in Checkout/SwiftUI/Drop-in Checkout Example/Assets/Assets.xcassets/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...wiftUI/Drop-in Checkout Example/Assets/Assets.xcassets/LaunchImage.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
Binary file added
BIN
+6.4 KB
...out Example/Assets/Assets.xcassets/LaunchImage.imageset/icon-primer@3x(1) 1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.4 KB
...out Example/Assets/Assets.xcassets/LaunchImage.imageset/icon-primer@3x(1) 2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+6.4 KB
...ckout Example/Assets/Assets.xcassets/LaunchImage.imageset/icon-primer@3x(1).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions
21
...wiftUI/Drop-in Checkout Example/Assets/Assets.xcassets/primer-icon.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
Binary file added
BIN
+6.4 KB
...ckout Example/Assets/Assets.xcassets/primer-icon.imageset/icon-primer@3x(1).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
63 changes: 63 additions & 0 deletions
63
Drop-in Checkout/SwiftUI/Drop-in Checkout Example/Assets/Launch Screen.storyboard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
Binary file added
BIN
+6.4 KB
Drop-in Checkout/SwiftUI/Drop-in Checkout Example/Assets/LaunchImage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions
18
Drop-in Checkout/SwiftUI/Drop-in Checkout Example/Assets/LaunchScreenViewController.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
} | ||
} |
Oops, something went wrong.