Skip to content

Commit

Permalink
Rename ThreeDSecureAttribute to ExtraAttribute
Browse files Browse the repository at this point in the history
  • Loading branch information
yatatsu committed Aug 28, 2024
1 parent eb26f0a commit 424baed
Show file tree
Hide file tree
Showing 14 changed files with 96 additions and 91 deletions.
8 changes: 4 additions & 4 deletions PAYJP.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
32167E0727B1C55800E4BCD5 /* OHHTTPStubs.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 32167E0627B1C55800E4BCD5 /* OHHTTPStubs.xcframework */; };
322BD1D6225C83CA00D83B5E /* JSONDecoder+PAYJP.swift in Sources */ = {isa = PBXBuildFile; fileRef = 322BD1D5225C83CA00D83B5E /* JSONDecoder+PAYJP.swift */; };
325E36B1233484C90037E6BE /* UIColor+PAYJP.swift in Sources */ = {isa = PBXBuildFile; fileRef = 325E36B0233484C90037E6BE /* UIColor+PAYJP.swift */; };
327C806E2C73D1F700CADF44 /* ThreeDSecureAttribute.swift in Sources */ = {isa = PBXBuildFile; fileRef = 327C806D2C73D1F700CADF44 /* ThreeDSecureAttribute.swift */; };
327C806E2C73D1F700CADF44 /* ExtraAttribute.swift in Sources */ = {isa = PBXBuildFile; fileRef = 327C806D2C73D1F700CADF44 /* ExtraAttribute.swift */; };
328622662C6C483F00DEA55B /* PhoneNumberKit.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 328622622C6C42CB00DEA55B /* PhoneNumberKit.xcframework */; };
3289C9D123EACB6D008FFBC1 /* ClientInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3289C9D023EACB6D008FFBC1 /* ClientInfo.swift */; };
3289C9D323EBFC87008FFBC1 /* ClientInfoTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3289C9D223EBFC87008FFBC1 /* ClientInfoTests.swift */; };
Expand Down Expand Up @@ -156,7 +156,7 @@
322BD1D5225C83CA00D83B5E /* JSONDecoder+PAYJP.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "JSONDecoder+PAYJP.swift"; sourceTree = "<group>"; };
325E36AE233482AC0037E6BE /* FormStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormStyle.swift; sourceTree = "<group>"; };
325E36B0233484C90037E6BE /* UIColor+PAYJP.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIColor+PAYJP.swift"; sourceTree = "<group>"; };
327C806D2C73D1F700CADF44 /* ThreeDSecureAttribute.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThreeDSecureAttribute.swift; sourceTree = "<group>"; };
327C806D2C73D1F700CADF44 /* ExtraAttribute.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExtraAttribute.swift; sourceTree = "<group>"; };
328622622C6C42CB00DEA55B /* PhoneNumberKit.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = PhoneNumberKit.xcframework; path = Carthage/Build/PhoneNumberKit.xcframework; sourceTree = "<group>"; };
3289C9D023EACB6D008FFBC1 /* ClientInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientInfo.swift; sourceTree = "<group>"; };
3289C9D223EBFC87008FFBC1 /* ClientInfoTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClientInfoTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -609,7 +609,7 @@
ED3FEF6E22EFE71900FA73BF /* FormError.swift */,
325E36AE233482AC0037E6BE /* FormStyle.swift */,
ED6DF6F4245ADC9C009E2EF3 /* FormTextField.swift */,
327C806D2C73D1F700CADF44 /* ThreeDSecureAttribute.swift */,
327C806D2C73D1F700CADF44 /* ExtraAttribute.swift */,
32F227B12C768CCB00259287 /* PresetPhoneNumberTextField.swift */,
);
path = Views;
Expand Down Expand Up @@ -886,7 +886,7 @@
444052DF2554ED2500CBEEAE /* CardIOCardParams.m in Sources */,
ED31B0822398E9F000DDFFE5 /* CardFormInput.swift in Sources */,
615AFF761C8C76E2003FB86F /* APIClient.swift in Sources */,
327C806E2C73D1F700CADF44 /* ThreeDSecureAttribute.swift in Sources */,
327C806E2C73D1F700CADF44 /* ExtraAttribute.swift in Sources */,
BE0203E9231F8DCB00FE5635 /* StringProtocol+PAYJP.swift in Sources */,
EDA0E4122435E8AA0083A5E0 /* ThreeDSecureStatus.swift in Sources */,
EDCF722D22F935D400272C10 /* Token.swift in Sources */,
Expand Down
4 changes: 2 additions & 2 deletions Sources/APIClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ import PassKit
/// - parameter expirationMonth: Credit card expiration month `01`
/// - parameter expirationYear: Credit card expiration year `2020`
/// - parameter name: Credit card holder name `TARO YAMADA`
/// - parameter email: Credit card email (3DS Attributes) e.g. `test@example.com`
/// - parameter phone: Credit card phone number (3DS Attributes) E.164 e.g. `+819012345678`
/// - parameter email: Credit card email (Extra Attributes) e.g. `test@example.com`
/// - parameter phone: Credit card phone number (Extra Attributes) E.164 e.g. `+819012345678`
/// - parameter completion: completion action
@nonobjc
public func createToken(
Expand Down
4 changes: 2 additions & 2 deletions Sources/Resources/Views/CardFormTableStyledView.xib
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@
<outlet property="expirationSeparator" destination="dYQ-X5-gpG" id="6gF-Gu-A0R"/>
<outlet property="expirationSeparatorConstraint" destination="mnt-dg-7Jt" id="Wlj-nh-rPp"/>
<outlet property="expirationTextField" destination="G9O-hO-3ha" id="Mkj-J2-1Jj"/>
<outlet property="extraAttributeInputsView" destination="vt7-D5-3Em" id="N3g-nH-Ial"/>
<outlet property="holderSeparator" destination="UV3-z2-UU5" id="3jK-kE-JPT"/>
<outlet property="holderSeparatorConstraint" destination="XwA-5B-AuG" id="gof-bR-EY4"/>
<outlet property="ocrButton" destination="Edh-Qk-Qqn" id="tHU-LT-iZG"/>
<outlet property="phoneNumberErrorLabel" destination="6H3-VY-mK8" id="Ta5-g3-n9d"/>
<outlet property="phoneNumberSeparator" destination="FZf-to-J82" id="mpW-cY-HvZ"/>
<outlet property="phoneNumberTextField" destination="iOc-p7-bTO" id="H4G-ZU-c0i"/>
<outlet property="phoneSeparatorConstraint" destination="whe-TA-30R" id="AAn-Ls-iAD"/>
<outlet property="threeDSecureAttributeInputsView" destination="vt7-D5-3Em" id="gFz-rE-rfH"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
Expand Down Expand Up @@ -244,7 +244,7 @@
<color key="backgroundColor" systemColor="systemGroupedBackgroundColor"/>
<edgeInsets key="layoutMargins" top="12" left="20" bottom="4" right="0.0"/>
</stackView>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="4" translatesAutoresizingMaskIntoConstraints="NO" id="vt7-D5-3Em" userLabel="Three D Secure Inputs">
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="4" translatesAutoresizingMaskIntoConstraints="NO" id="vt7-D5-3Em" userLabel="Extra Attribute Inputs">
<rect key="frame" x="0.0" y="229" width="352" height="181"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="mUa-5J-GcG" userLabel="Email">
Expand Down
38 changes: 19 additions & 19 deletions Sources/Views/CardFormDisplayStyledView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,8 @@ public class CardFormDisplayStyledView: CardFormView, CardFormProperties {
textField: cvcTextField,
errorLabel: cvcErrorLabel)
setupAdditionalInfoView()
setupCardHolderTdsAttributesView()
toggleCardHolderTdsAttributeErrorLabel()
setupCardHolderExtraAttributesView()
toggleCardHolderExtraAttributeErrorLabel()

formContentStackView.addArrangedSubview(cardNumberFieldContentView)
formContentStackView.addArrangedSubview(expirationFieldContentView)
Expand Down Expand Up @@ -462,12 +462,12 @@ public class CardFormDisplayStyledView: CardFormView, CardFormProperties {
self.additionalInfoView = additionalInfoStackView
}

private func setupCardHolderTdsAttributesView() {
private func setupCardHolderExtraAttributesView() {
phoneNumberSeparator = UIView()
phoneNumberSeparator.backgroundColor = Style.Color.separator
let cardHolderStackView = UIStackView()
let tdsStackView = UIStackView()
[cardHolderStackView, tdsStackView].forEach { stackView in
let extrasStackView = UIStackView()
[cardHolderStackView, extrasStackView].forEach { stackView in
stackView.axis = .vertical
stackView.alignment = .leading
stackView.distribution = .equalSpacing
Expand All @@ -476,27 +476,27 @@ public class CardFormDisplayStyledView: CardFormView, CardFormProperties {
}
cardHolderStackView.addArrangedSubview(cardHolderTextField)
cardHolderFieldBackground = cardHolderStackView
tdsStackView.addArrangedSubview(emailTextField)
tdsStackView.addArrangedSubview(phoneNumberSeparator)
tdsStackView.addArrangedSubview(phoneNumberTextField)
threeDSecureFieldsBackground = tdsStackView
extrasStackView.addArrangedSubview(emailTextField)
extrasStackView.addArrangedSubview(phoneNumberSeparator)
extrasStackView.addArrangedSubview(phoneNumberTextField)
threeDSecureFieldsBackground = extrasStackView

let separatorHeight = 1.0 / UIScreen.main.scale
NSLayoutConstraint.activate([
phoneNumberSeparator.leadingAnchor.constraint(equalTo: tdsStackView.leadingAnchor),
phoneNumberSeparator.trailingAnchor.constraint(equalTo: tdsStackView.trailingAnchor),
phoneNumberSeparator.leadingAnchor.constraint(equalTo: extrasStackView.leadingAnchor),
phoneNumberSeparator.trailingAnchor.constraint(equalTo: extrasStackView.trailingAnchor),
phoneNumberSeparator.heightAnchor.constraint(equalToConstant: separatorHeight),
cardHolderTextField.leadingAnchor.constraint(equalTo: cardHolderStackView.leadingAnchor,
constant: inputFieldMargin),
cardHolderTextField.trailingAnchor.constraint(equalTo: cardHolderStackView.trailingAnchor,
constant: -inputFieldMargin),
emailTextField.leadingAnchor.constraint(equalTo: tdsStackView.leadingAnchor,
emailTextField.leadingAnchor.constraint(equalTo: extrasStackView.leadingAnchor,
constant: inputFieldMargin),
emailTextField.trailingAnchor.constraint(equalTo: tdsStackView.trailingAnchor,
emailTextField.trailingAnchor.constraint(equalTo: extrasStackView.trailingAnchor,
constant: -inputFieldMargin),
phoneNumberTextField.leadingAnchor.constraint(equalTo: tdsStackView.leadingAnchor,
phoneNumberTextField.leadingAnchor.constraint(equalTo: extrasStackView.leadingAnchor,
constant: inputFieldMargin),
phoneNumberTextField.trailingAnchor.constraint(equalTo: tdsStackView.trailingAnchor,
phoneNumberTextField.trailingAnchor.constraint(equalTo: extrasStackView.trailingAnchor,
constant: -inputFieldMargin),
cardHolderTextField.heightAnchor.constraint(equalToConstant: 44.0),
emailTextField.heightAnchor.constraint(equalToConstant: 44.0),
Expand All @@ -512,7 +512,7 @@ public class CardFormDisplayStyledView: CardFormView, CardFormProperties {
contentStackView.addArrangedSubview(cardHolderStackView)
contentStackView.addArrangedSubview(cardHolderErrorLabel)
contentStackView.addArrangedSubview(additionalInfoView)
contentStackView.addArrangedSubview(tdsStackView)
contentStackView.addArrangedSubview(extrasStackView)
contentStackView.addArrangedSubview(emailErrorLabel)
contentStackView.addArrangedSubview(phoneNumberErrorLabel)

Expand All @@ -522,8 +522,8 @@ public class CardFormDisplayStyledView: CardFormView, CardFormProperties {
phoneNumberErrorLabel.heightAnchor.constraint(equalToConstant: 20.0),
cardHolderStackView.leadingAnchor.constraint(equalTo: contentStackView.leadingAnchor),
cardHolderStackView.trailingAnchor.constraint(equalTo: contentStackView.trailingAnchor),
tdsStackView.leadingAnchor.constraint(equalTo: contentStackView.leadingAnchor),
tdsStackView.trailingAnchor.constraint(equalTo: contentStackView.trailingAnchor)
extrasStackView.leadingAnchor.constraint(equalTo: contentStackView.leadingAnchor),
extrasStackView.trailingAnchor.constraint(equalTo: contentStackView.trailingAnchor)
])

cardHolderFieldContentView = contentStackView
Expand Down Expand Up @@ -662,7 +662,7 @@ public class CardFormDisplayStyledView: CardFormView, CardFormProperties {
}
}

private func toggleCardHolderTdsAttributeErrorLabel() {
private func toggleCardHolderExtraAttributeErrorLabel() {
// 複数項目のエラーを縦に並べる形なので、エラー文字列がない場合はLabel自体を非表示にする
cardHolderErrorLabel.isHidden = cardHolderErrorLabel.text?.isEmpty ?? true
emailErrorLabel.isHidden = emailErrorLabel.text?.isEmpty ?? true
Expand Down
8 changes: 4 additions & 4 deletions Sources/Views/CardFormTableStyledView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ public class CardFormTableStyledView: CardFormView, CardFormProperties {
var emailInputEnabled: Bool = true {
didSet {
emailInputView.isHidden = !emailInputEnabled
threeDSecureAttributeInputsView.isHidden = !emailInputEnabled && !phoneInputEnabled
extraAttributeInputsView.isHidden = !emailInputEnabled && !phoneInputEnabled
}
}
var phoneInputEnabled: Bool = true {
didSet {
phoneInputView.isHidden = !phoneInputEnabled
phoneNumberSeparator.isHidden = !emailInputEnabled || !phoneInputEnabled
threeDSecureAttributeInputsView.isHidden = !emailInputEnabled && !phoneInputEnabled
extraAttributeInputsView.isHidden = !emailInputEnabled && !phoneInputEnabled
}
}

Expand All @@ -68,7 +68,7 @@ public class CardFormTableStyledView: CardFormView, CardFormProperties {
@IBOutlet private weak var phoneSeparatorConstraint: NSLayoutConstraint!

@IBOutlet private weak var basicInputsContainerView: UIStackView!
@IBOutlet private weak var threeDSecureAttributeInputsView: UIStackView!
@IBOutlet private weak var extraAttributeInputsView: UIStackView!
@IBOutlet private weak var additionalInfoLabel: UILabel!

/// Camera scan action
Expand Down Expand Up @@ -104,7 +104,7 @@ public class CardFormTableStyledView: CardFormView, CardFormProperties {
}

basicInputsContainerView.backgroundColor = Style.Color.groupedBackground
threeDSecureAttributeInputsView.backgroundColor = Style.Color.groupedBackground
extraAttributeInputsView.backgroundColor = Style.Color.groupedBackground

// set images
brandLogoImage.image = "icon_card".image
Expand Down
6 changes: 3 additions & 3 deletions Sources/Views/CardFormView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -498,8 +498,8 @@ extension CardFormView: CardFormAction {
cardFormProperties.phoneNumberTextField.inputAccessoryView = view
}

public func apply(threeDSecureAttributes: [any ThreeDSecureAttribute]) {
viewModel.update(threeDSecureAttributes: threeDSecureAttributes)
public func apply(extraAttributes: [any ExtraAttribute]) {
viewModel.update(extraAttributes: extraAttributes)
}
}

Expand Down Expand Up @@ -621,7 +621,7 @@ extension CardFormView: CardFormViewModelDelegate {
showCameraPermissionAlert()
}

func updateThreeDSecureAttributes(email: ThreeDSecureAttributeEmail?, phone: ThreeDSecureAttributePhone?) {
func updateExtraAttributes(email: ExtraAttributeEmail?, phone: ExtraAttributePhone?) {
let emailInputEnabled = email != nil
let phoneInputEnabled = phone != nil
cardFormProperties.emailInputEnabled = emailInputEnabled
Expand Down
12 changes: 6 additions & 6 deletions Sources/Views/CardFormViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class CardFormViewController: UIViewController {
private var cardFormView: CardFormView!
private var presenter: CardFormScreenPresenterType?
private let errorTranslator = ErrorTranslator.shared
private var threeDSecureAttributes: [ThreeDSecureAttribute] = [ThreeDSecureAttributeEmail(), ThreeDSecureAttributePhone()]
private var extraAttributes: [ExtraAttribute] = [ExtraAttributeEmail(), ExtraAttributePhone()]

/// CardFormViewController delegate.
private weak var delegate: CardFormViewControllerDelegate?
Expand All @@ -70,15 +70,15 @@ public class CardFormViewController: UIViewController {
/// - tenantId: identifier of tenant
/// - delegate: delegate of CardFormViewControllerDelegate
/// - viewType: card form type
/// - threeDSecureAttributes: attributes for 3DS
/// - extraAttributes: extra attributes for 3-D Secure
/// - Returns: CardFormViewController
@objc(createCardFormViewControllerWithStyle: tenantId: delegate: viewType: threeDSecureAttributes:)
@objc(createCardFormViewControllerWithStyle: tenantId: delegate: viewType: extraAttributes:)
public static func createCardFormViewController(
style: FormStyle = .defaultStyle,
tenantId: String? = nil,
delegate: CardFormViewControllerDelegate,
viewType: CardFormViewType = .labelStyled,
threeDSecureAttributes: [ThreeDSecureAttribute] = [ThreeDSecureAttributeEmail(), ThreeDSecureAttributePhone()]
extraAttributes: [ExtraAttribute] = [ExtraAttributeEmail(), ExtraAttributePhone()]
) -> CardFormViewController {

let stotyboard = UIStoryboard(name: "CardForm", bundle: .payjpBundle)
Expand All @@ -90,7 +90,7 @@ public class CardFormViewController: UIViewController {
cardFormVc.tenantId = tenantId
cardFormVc.delegate = delegate
cardFormVc.cardFormViewType = viewType
cardFormVc.threeDSecureAttributes = threeDSecureAttributes
cardFormVc.extraAttributes = extraAttributes
return cardFormVc
}

Expand Down Expand Up @@ -276,7 +276,7 @@ public class CardFormViewController: UIViewController {
cardFormView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
cardFormView.delegate = self
cardFormView.setupInputAccessoryView(view: accessoryView)
cardFormView.apply(threeDSecureAttributes: threeDSecureAttributes)
cardFormView.apply(extraAttributes: extraAttributes)
if let formStyle = formStyle {
cardFormView.apply(style: formStyle)
submitButton.normalBackgroundColor = formStyle.submitButtonColor
Expand Down
8 changes: 4 additions & 4 deletions Sources/Views/CardFormViewDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ public protocol CardFormAction {
/// - Parameter view: input accessory view
func setupInputAccessoryView(view: UIView)

/// Enable additional attributes for 3-D Secure.
/// Both TdsAttributesEmail and TdsAttributesPhone is enabled as default.
/// Enable extra attributes for 3-D Secure.
/// Both [ExtraAttributesEmail] and [ExtraAttributesPhone] is enabled as default.
/// - Parameters:
/// - threeDSecureAttributes: array of attributes.
func apply(threeDSecureAttributes: [ThreeDSecureAttribute])
/// - extraAttributes: array of attributes.
func apply(extraAttributes: [ExtraAttribute])
}
Loading

0 comments on commit 424baed

Please sign in to comment.