Skip to content

Commit

Permalink
Merge branch 'main' into convert-datacollector-viewcontroller
Browse files Browse the repository at this point in the history
# Conflicts:
#	Demo/Demo.xcodeproj/project.pbxproj
  • Loading branch information
jaxdesmarais committed Aug 29, 2023
2 parents eac05e7 + 205d493 commit 3274d5a
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 132 deletions.

This file was deleted.

96 changes: 0 additions & 96 deletions Demo/Application/Features/Ideal/BraintreeDemoIdealViewController.m

This file was deleted.

108 changes: 108 additions & 0 deletions Demo/Application/Features/Ideal/BraintreeDemoIdealViewController.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import Foundation
import BraintreeLocalPayment
import BraintreeCore

class BraintreeDemoIdealViewController: BraintreeDemoPaymentButtonBaseViewController {

var localPaymentClient: BTLocalPaymentClient!
var paymentIDLabel: UILabel = UILabel()

override func viewDidLoad() {
super.viewDidLoad()

progressBlock("Loading iDEAL Merchant Account...")
paymentButton.isHidden = false
progressBlock("Ready!")
title = "iDEAL"
}

override func createPaymentButton() -> UIView! {
let iDEALButton = UIButton(type: .custom)
iDEALButton.setTitle("Pay with iDEAL", for: .normal)
iDEALButton.setTitleColor(.blue, for: .normal)
iDEALButton.setTitleColor(.lightGray, for: .highlighted)
iDEALButton.setTitleColor(.lightGray, for: .disabled)
iDEALButton.addTarget(self, action: #selector(tappedIDEAL), for: .touchUpInside)
iDEALButton.translatesAutoresizingMaskIntoConstraints = false

let label = UILabel()
label.numberOfLines = 0
label.translatesAutoresizingMaskIntoConstraints = false

self.paymentIDLabel = label

let stackView = UIStackView(arrangedSubviews: [iDEALButton, label])
stackView.axis = .vertical
stackView.spacing = 5
stackView.alignment = .center
stackView.translatesAutoresizingMaskIntoConstraints = false

NSLayoutConstraint.activate([
iDEALButton.topAnchor.constraint(equalTo: stackView.topAnchor),
iDEALButton.heightAnchor.constraint(equalToConstant: 19.5),

label.topAnchor.constraint(equalTo: iDEALButton.bottomAnchor, constant: 5),
label.heightAnchor.constraint(equalToConstant: 19.5)
])

return stackView
}

@objc func tappedIDEAL() {
paymentIDLabel.text = nil
startPaymentWithBank()
}

private func startPaymentWithBank() {
let apiClient = BTAPIClient(authorization: "sandbox_f252zhq7_hh4cpc39zq4rgjcg")!
localPaymentClient = BTLocalPaymentClient(apiClient: apiClient)

let request = BTLocalPaymentRequest()
request.paymentType = "ideal"
request.paymentTypeCountryCode = "NL"
request.currencyCode = "EUR"
request.amount = "1.01"
request.givenName = "Linh"
request.surname = "Ngo"
request.phone = "639847934"
request.email = "[email protected]"
request.isShippingAddressRequired = false

let postalAddress = BTPostalAddress()
postalAddress.countryCodeAlpha2 = "NL"
postalAddress.postalCode = "2585 GJ"
postalAddress.streetAddress = "836486 of 22321 Park Lake"
postalAddress.locality = "Den Haag"

request.address = postalAddress
request.localPaymentFlowDelegate = self

localPaymentClient.startPaymentFlow(request) { result, error in
guard let result else {
if (error as? NSError)?.code == 5 {
self.progressBlock("Canceled 🎲")
} else {
self.progressBlock("Error: \(error?.localizedDescription ?? "")")
}
return
}

let nonce = BTPaymentMethodNonce(nonce: result.nonce)
self.completionBlock(nonce)
}
}
}

// MARK: - BTLocalPaymentRequestDelegate Conformance

extension BraintreeDemoIdealViewController: BTLocalPaymentRequestDelegate {

func localPaymentStarted(
_ request: BraintreeLocalPayment.BTLocalPaymentRequest,
paymentID: String,
start: @escaping () -> Void
) {
paymentIDLabel.text = "LocalPayment ID: \(paymentID)"
start()
}
}
33 changes: 4 additions & 29 deletions Demo/Demo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
A0988FE324DB44B20095EEEE /* Main.strings in Resources */ = {isa = PBXBuildFile; fileRef = A0988F5224DB44B10095EEEE /* Main.strings */; };
A0988FE424DB44B20095EEEE /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = A0988F5424DB44B10095EEEE /* InfoPlist.strings */; };
A0988FE624DB44B20095EEEE /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = A0988F5824DB44B10095EEEE /* main.m */; };
A0988FEA24DB44B20095EEEE /* BraintreeDemoIdealViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A0988F6424DB44B10095EEEE /* BraintreeDemoIdealViewController.m */; };
A0988FEE24DB44B20095EEEE /* BraintreeDemoCardTokenizationViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A0988F6E24DB44B10095EEEE /* BraintreeDemoCardTokenizationViewController.m */; };
A0988FF024DB44B20095EEEE /* BraintreeDemoApplePayPassKitViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A0988F7424DB44B10095EEEE /* BraintreeDemoApplePayPassKitViewController.m */; };
A0988FF224DB44B20095EEEE /* BraintreeDemoThreeDSecurePaymentFlowViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A0988F7A24DB44B10095EEEE /* BraintreeDemoThreeDSecurePaymentFlowViewController.m */; };
Expand All @@ -74,8 +73,8 @@
BE777AC427D9370400487D23 /* BraintreeDemoSEPADirectDebitViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE777AC327D9370400487D23 /* BraintreeDemoSEPADirectDebitViewController.swift */; };
BE9BD75928872E4D00022983 /* BraintreeSEPADirectDebit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BE9BD75828872E4D00022983 /* BraintreeSEPADirectDebit.framework */; };
BE9BD75A28872E4D00022983 /* BraintreeSEPADirectDebit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = BE9BD75828872E4D00022983 /* BraintreeSEPADirectDebit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
BEAAAA342A98E5E6001ECA63 /* BraintreeDemoIdealViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BEAAAA332A98E5E6001ECA63 /* BraintreeDemoIdealViewController.swift */; };
BEAAAD052970A70D000BD296 /* BTSEPADirectDebitTestHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = BEAAAD042970A70D000BD296 /* BTSEPADirectDebitTestHelper.swift */; };
BEE2E4BC290043D100C03FDD /* PayPalCheckout in Frameworks */ = {isa = PBXBuildFile; productRef = BEE2E4BB290043D100C03FDD /* PayPalCheckout */; };
BEE930492A98FE9200C85779 /* BraintreeDemoBTDataCollectorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BEE930482A98FE9200C85779 /* BraintreeDemoBTDataCollectorViewController.swift */; };
/* End PBXBuildFile section */

Expand Down Expand Up @@ -177,8 +176,6 @@
A0988F5624DB44B10095EEEE /* Braintree-Demo-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Braintree-Demo-Prefix.pch"; sourceTree = "<group>"; };
A0988F5724DB44B10095EEEE /* Braintree-Demo-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Braintree-Demo-Info.plist"; sourceTree = "<group>"; };
A0988F5824DB44B10095EEEE /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
A0988F6324DB44B10095EEEE /* BraintreeDemoIdealViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BraintreeDemoIdealViewController.h; sourceTree = "<group>"; };
A0988F6424DB44B10095EEEE /* BraintreeDemoIdealViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BraintreeDemoIdealViewController.m; sourceTree = "<group>"; };
A0988F6C24DB44B10095EEEE /* BraintreeDemoCardTokenizationViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BraintreeDemoCardTokenizationViewController.h; sourceTree = "<group>"; };
A0988F6E24DB44B10095EEEE /* BraintreeDemoCardTokenizationViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BraintreeDemoCardTokenizationViewController.m; sourceTree = "<group>"; };
A0988F7324DB44B10095EEEE /* BraintreeDemoApplePayPassKitViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BraintreeDemoApplePayPassKitViewController.h; sourceTree = "<group>"; };
Expand All @@ -203,6 +200,7 @@
BE4F788F27EE3C1D00FF4C0E /* BraintreeDemoPayPalPayLaterViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BraintreeDemoPayPalPayLaterViewController.swift; sourceTree = "<group>"; };
BE777AC327D9370400487D23 /* BraintreeDemoSEPADirectDebitViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BraintreeDemoSEPADirectDebitViewController.swift; sourceTree = "<group>"; };
BE9BD75828872E4D00022983 /* BraintreeSEPADirectDebit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = BraintreeSEPADirectDebit.framework; sourceTree = BUILT_PRODUCTS_DIR; };
BEAAAA332A98E5E6001ECA63 /* BraintreeDemoIdealViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BraintreeDemoIdealViewController.swift; sourceTree = "<group>"; };
BEAAAD042970A70D000BD296 /* BTSEPADirectDebitTestHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BTSEPADirectDebitTestHelper.swift; sourceTree = "<group>"; };
BEE930482A98FE9200C85779 /* BraintreeDemoBTDataCollectorViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BraintreeDemoBTDataCollectorViewController.swift; sourceTree = "<group>"; };
C8E5BAD1DA81AAD310B19786 /* Pods-Demo.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Demo.release.xcconfig"; path = "Target Support Files/Pods-Demo/Pods-Demo.release.xcconfig"; sourceTree = "<group>"; };
Expand All @@ -224,7 +222,6 @@
803D64FB256DAF9A00ACE692 /* BraintreeCore.framework in Frameworks */,
9C36BD4C26B311D900F0A559 /* CardinalMobile.xcframework in Frameworks */,
803D64F5256DAF9A00ACE692 /* BraintreeAmericanExpress.framework in Frameworks */,
BEE2E4BC290043D100C03FDD /* PayPalCheckout in Frameworks */,
BE35FCD82A1BD162008F0326 /* BraintreeLocalPayment.framework in Frameworks */,
BE9BD75928872E4D00022983 /* BraintreeSEPADirectDebit.framework in Frameworks */,
9C36BD2926B3071B00F0A559 /* PPRiskMagnes.xcframework in Frameworks */,
Expand Down Expand Up @@ -417,8 +414,7 @@
A0988F6224DB44B10095EEEE /* Ideal */ = {
isa = PBXGroup;
children = (
A0988F6324DB44B10095EEEE /* BraintreeDemoIdealViewController.h */,
A0988F6424DB44B10095EEEE /* BraintreeDemoIdealViewController.m */,
BEAAAA332A98E5E6001ECA63 /* BraintreeDemoIdealViewController.swift */,
);
path = Ideal;
sourceTree = "<group>";
Expand Down Expand Up @@ -616,7 +612,6 @@
);
name = Demo;
packageProductDependencies = (
BEE2E4BB290043D100C03FDD /* PayPalCheckout */,
);
productName = Demo;
productReference = A0988E4924DB43DC0095EEEE /* Demo.app */;
Expand Down Expand Up @@ -693,7 +688,6 @@
);
mainGroup = A0988E4024DB43DC0095EEEE;
packageReferences = (
BEE2E4BA290043D100C03FDD /* XCRemoteSwiftPackageReference "paypalcheckout-ios" */,
);
productRefGroup = A0988E4A24DB43DC0095EEEE /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -799,13 +793,13 @@
files = (
A0988F9524DB44B20095EEEE /* BraintreeDemoBaseViewController.m in Sources */,
BE4F789027EE3C1D00FF4C0E /* BraintreeDemoPayPalPayLaterViewController.swift in Sources */,
BEAAAA342A98E5E6001ECA63 /* BraintreeDemoIdealViewController.swift in Sources */,
803FB9DE26D93146002BF92D /* BTCardFormView.swift in Sources */,
A0988FFA24DB44B20095EEEE /* BraintreeDemoMerchantAPIClient.swift in Sources */,
BE777AC427D9370400487D23 /* BraintreeDemoSEPADirectDebitViewController.swift in Sources */,
A0988FF424DB44B20095EEEE /* BraintreeDemoAmexViewController.m in Sources */,
A0988FE624DB44B20095EEEE /* main.m in Sources */,
A0988F9724DB44B20095EEEE /* BraintreeDemoContainmentViewController.m in Sources */,
A0988FEA24DB44B20095EEEE /* BraintreeDemoIdealViewController.m in Sources */,
BE4F788927EE2B6D00FF4C0E /* BraintreeDemoPayPalVaultViewController.swift in Sources */,
A0988FEE24DB44B20095EEEE /* BraintreeDemoCardTokenizationViewController.m in Sources */,
42D47A152554679D0012BAF1 /* BraintreeDemoSceneDelegate.m in Sources */,
Expand Down Expand Up @@ -1193,25 +1187,6 @@
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
BEE2E4BA290043D100C03FDD /* XCRemoteSwiftPackageReference "paypalcheckout-ios" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/paypal/paypalcheckout-ios/";
requirement = {
kind = exactVersion;
version = 1.1.0;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
BEE2E4BB290043D100C03FDD /* PayPalCheckout */ = {
isa = XCSwiftPackageProductDependency;
package = BEE2E4BA290043D100C03FDD /* XCRemoteSwiftPackageReference "paypalcheckout-ios" */;
productName = PayPalCheckout;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = A0988E4124DB43DC0095EEEE /* Project object */;
}

0 comments on commit 3274d5a

Please sign in to comment.