-
Notifications
You must be signed in to change notification settings - Fork 295
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
Add Cardinal UI Type and Render Types #1134
Changes from 7 commits
afedeac
978291d
c9f0d37
a588e3b
11627c7
ab933e6
6909deb
e260990
5911c55
1b9fa41
388024f
4bff6fa
ec32801
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,6 +98,14 @@ class ThreeDSecureViewController: PaymentButtonBaseViewController { | |
request.requestedExemptionType = .lowValue | ||
request.email = "[email protected]" | ||
request.shippingMethod = .sameDay | ||
request.uiType = .both | ||
request.renderTypes = [ | ||
BTThreeDSecureRenderType.otp, | ||
BTThreeDSecureRenderType.singleSelect, | ||
BTThreeDSecureRenderType.multiSelect, | ||
BTThreeDSecureRenderType.oob, | ||
BTThreeDSecureRenderType.html | ||
] | ||
|
||
let billingAddress = BTThreeDSecurePostalAddress() | ||
billingAddress.givenName = "Jill" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import Foundation | ||
|
||
/// Render types that the device supports for displaying specific challenge user interfaces within the 3D Secure challenge. | ||
@objcMembers public class BTThreeDSecureRenderType: NSObject { | ||
|
||
public typealias StringValue = String | ||
|
||
/// OTP | ||
public static let otp: StringValue = "CardinalSessionRenderTypeOTP" | ||
|
||
/// HTML | ||
public static let html: StringValue = "CardinalSessionRenderTypeHTML" | ||
|
||
/// Single select | ||
public static let singleSelect: StringValue = "CardinalSessionRenderTypeSingleSelect" | ||
|
||
/// Multi Select | ||
public static let multiSelect: StringValue = "CardinalSessionRenderTypeMultiSelect" | ||
|
||
/// OOB | ||
public static let oob: StringValue = "CardinalSessionRenderTypeOOB" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,6 +77,17 @@ import BraintreeCore | |
/// Optional. UI Customization for 3DS2 challenge views. | ||
public var v2UICustomization: BTThreeDSecureV2UICustomization? | ||
|
||
/// Optional. Sets all UI types that the device supports for displaying specific challenge user interfaces in the 3D Secure challenge. | ||
/// | ||
/// Defaults to `.both` | ||
public var uiType: BTThreeDSecureUIType = .both | ||
|
||
/// Optional. List of all the render types that the device supports for displaying specific challenge user interfaces within the 3D Secure challenge. | ||
/// | ||
/// - Note: When using `BTThreeDSecureUIType.both` or `BTThreeDSecureUIType.html`, all `BTThreeDSecureRenderType` options must be set. | ||
/// When using `BTThreeDSecureUIType.native`, all `BTThreeDSecureRenderType` options except `BTThreeDSecureRenderType.html` must be set. | ||
public var renderTypes: [BTThreeDSecureRenderType.StringValue]? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Arrays of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't have any better ideas for this but curious if we are planning to remove obj-c support in the next major version? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently there isn't a plan to remove Obj-C support in the next major version but we could consider discussing it further as an option! Or if Apple announces an official deprecation policy at some point it'd be a much easier choice. |
||
|
||
/// A delegate for receiving information about the ThreeDSecure payment flow. | ||
public weak var threeDSecureRequestDelegate: BTThreeDSecureRequestDelegate? | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import Foundation | ||
import CardinalMobile | ||
|
||
/// The interface types that the device supports for displaying specific challenge user interfaces within the 3D Secure challenge. | ||
@objc public enum BTThreeDSecureUIType: Int { | ||
|
||
/// Native | ||
case native | ||
|
||
/// HTML | ||
case html | ||
|
||
/// Both | ||
case both | ||
|
||
var cardinalValue: CardinalSessionUIType { | ||
switch self { | ||
case .native: | ||
return .native | ||
case .html: | ||
return .HTML | ||
case .both: | ||
return .both | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would the
@objc
annotation work for us (stack post)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That works for the enum but that's not the issue, the issue is that arrays of
Int
enums don't exist in Obj-C and enums can only be bridged toInt
types to be interoperable with Obj-C. A Swift array is bridged to Obj-C'sNSArray
, and an Obj-C array should contain only pointers, but an enum ofInt
doesn't contain pointers so cannot be bridged.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah got it yeah. That makes sense. Swift does have
OptionSet
as anNS_OPTIONS
equivalent, but I can't tell if option sets are accessible from Obj-C.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 we may be able to make that work - it'll need to be a class instead of a struct since structs don't exist in Obj-c, but I think that may be okay. I'll poke around at it a bit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done: 5911c55. Great suggestion, that's way cleaner 🔥
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also if anyone is interested this is how the implementation will look for Obj-C merchants: