Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Co-Badged Cards Example App #1

Merged
merged 50 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
437247f
Add co-badged cards example app
jnewc Dec 7, 2023
8567402
Add gitignore + remove xcuserdata
jnewc Dec 7, 2023
25e3715
Fix issue with pasting client token directly into simulator (thanks B…
jnewc Dec 11, 2023
508d58e
Update project file + fix delegate method sigs
jnewc Jan 3, 2024
361da4d
Add fastlane + github workflow for building example app
jnewc Jan 3, 2024
6760ddd
Add missing platform to bundle lockfile
jnewc Jan 3, 2024
e91db92
Skip fastlane profile mapping
jnewc Jan 3, 2024
7308565
Fix README step
jnewc Jan 3, 2024
0f81b93
Merge remote-tracking branch 'origin/jn/co-badged-cards-example' into…
jnewc Jan 5, 2024
6cc8099
Point at branch for SDK + fix propogation of selected network
jnewc Jan 8, 2024
1c5f623
Fix scheme name in workflow file
jnewc Jan 8, 2024
2dd1e06
Fix scheme name in workflow matrix
jnewc Jan 8, 2024
087bc94
Merge pull request #2 from primer-io/jn/co-badged-cards/workflows
jnewc Jan 8, 2024
a29b76f
Fix selection of card network logic + project layout issue
jnewc Jan 11, 2024
ba098a6
Update with latest changes to feature branch
jnewc Jan 12, 2024
06fdabb
Clear selected index of co-badged card when new models are received
jnewc Jan 23, 2024
2b382f5
Add loading spinner during remote load
jnewc Jan 23, 2024
4da1b60
Remove available card networks control and logic
jnewc Jan 24, 2024
1bc605e
Fix loading + validation reloads + error order
jnewc Jan 24, 2024
57654f7
Change payment button title + error message
jnewc Jan 25, 2024
3198198
Fix state sync issue + fix CB-only not displaying correctly when not …
jnewc Jan 25, 2024
a0628dc
Remove debug print
jnewc Jan 25, 2024
29b4509
chore: update readme
xevious78 Jan 25, 2024
da96708
chore: update readme
xevious78 Jan 25, 2024
1482e90
Republish loading property
jnewc Jan 25, 2024
41c1f94
chore: update readme url
xevious78 Jan 25, 2024
29adcb6
chore: update url
xevious78 Jan 25, 2024
8e1fcf3
chore: update radme
xevious78 Jan 25, 2024
3084425
chore: update readme
xevious78 Jan 25, 2024
bd2b58e
chore: address pr feedback
xevious78 Jan 25, 2024
9251b52
Fix swiftui bug with duplicate binding triggers
jnewc Jan 25, 2024
a72af6a
AMEX and Diners card formatting
jnewc Jan 25, 2024
2326c4b
Minor code cleanup / reorg
jnewc Jan 26, 2024
db727e8
Re-add logic for disabling card button prior to validation pass
jnewc Jan 26, 2024
7fe3d52
Ensure url text field is lower case
jnewc Jan 26, 2024
a222256
Use new methods for setting textfield attributes
jnewc Jan 26, 2024
5ded10d
project file updates
jnewc Jan 31, 2024
d163b8c
pre-selection
jnewc Feb 2, 2024
417a957
Pin action versions
jnewc Feb 2, 2024
42fb5c6
update packages
jnewc Feb 2, 2024
d63e9bd
Add contribution guide
jnewc Feb 2, 2024
b74f8c9
Merge branch 'jn/co-badged-cards-example' into u/at/update-readme
jnewc Feb 2, 2024
7f74580
Merge pull request #3 from primer-io/u/at/update-readme
jnewc Feb 2, 2024
88d4124
add license
jnewc Feb 12, 2024
d4a1843
PR feedback
jnewc Feb 12, 2024
f734a0a
Remove body for client token
jnewc Feb 16, 2024
3774b87
Remove user defaults storage for client token
jnewc Feb 16, 2024
bc6b85b
Update placeholder for client token url
jnewc Feb 16, 2024
090bd03
Switch workflow actions to git refs
jnewc Feb 16, 2024
340b7d1
Switch workflow actions to git refs with full hashes ...
jnewc Feb 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
xcuserdata
72 changes: 72 additions & 0 deletions Co-Badged Cards/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# 💳 Co-Badged Cards Example

This example demonstrates how to integrate support for co-badged cards in 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/Co-Badged Cards/SwiftUI"
```

3. Open the project

```sh
open Package.swift
jnewc marked this conversation as resolved.
Show resolved Hide resolved
```

4. Run the project from Xcode 🚀

## Trying it out

This example app allows you to:

- Generate a client token (requires local server, see here TODO)
- Make a payment using a card
- Select a co-badged network when making a payment with a co-badged card

We support several test cards for different test cases, which you can find 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 includes:
* SDK ininitialisation
* Handling of card validation via `PrimerHeadlessUniversalCheckoutRawDataManagerDelegate`
* Handling of payment submission via `PrimerHeadlessUniversalCheckoutDelegate`

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.

### PrimerCardDataModel & PrimerCardDataErrorsModel

These models are used to reflect changes to user inputs via `CardDetailsFormView`.

The former is updated with user inputs as they are entered in to the form.
The latter is updated with validation errors that are displayed in the form during entry.

### 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 `[Co-Badged Cards 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-klarna-sdk-ios",
"kind" : "remoteSourceControl",
"location" : "https://github.com/primer-io/primer-klarna-sdk-ios.git",
"state" : {
"revision" : "f13260c24a900f28e21bafd213c22191e6280e86",
"version" : "1.0.4"
}
}
],
"version" : 2
}
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,21 @@
{
"images" : [
{
"filename" : "icon-cartes-bancaires.jpg",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"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,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" : [
{
"filename" : "MasterCard.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"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,21 @@
{
"images" : [
{
"filename" : "genericCard.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"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,21 @@
{
"images" : [
{
"filename" : "Visa.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"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,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="22154" 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="22130"/>
<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="Co-Badged Cards 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
// Co-Badged Cards 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