Skip to content

Commit

Permalink
Instant Debits: cleaned up logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
kgaidis-stripe committed May 13, 2024
1 parent c0397d6 commit 2de23f5
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ extension PlaygroundController {
"use_link": settings.linkEnabled == .on,
"use_manual_confirmation": settings.integrationType == .deferred_mc,
"require_cvc_recollection": settings.requireCVCRecollection == .on,
// "supported_payment_methods": ["card", "link"], // Uncomment to override payment methods (also make sure Automatic PM's is off)
// "set_shipping_address": true // Uncomment to make server vend PI with shipping address populated
] as [String: Any]
makeRequest(with: checkoutEndpoint, body: body) { data, response, error in
Expand Down
1 change: 1 addition & 0 deletions Stripe.xcworkspace/xcshareddata/swiftpm/Package.resolved
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"originHash" : "a6099f8b6f6e3d4e6a249794b40206685b3930858d8b410d4e86ef38217df380",
"pins" : [
{
"identity" : "capture-core-sp",
Expand Down
2 changes: 1 addition & 1 deletion Stripe/StripeiOS/Source/STPPaymentMethod+BasicUI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ extension STPPaymentMethod: STPPaymentOption {

@objc public var isReusable: Bool {
switch type {
case .card, .link, .USBankAccount:
case .card, .link, .USBankAccount, .instantDebits:
return true
case .alipay, // Careful! Revisit this if/when we support recurring Alipay
.AUBECSDebit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ extension STPPaymentMethodParams: STPPaymentOption {

@objc public var isReusable: Bool {
switch type {
case .card, .link, .USBankAccount:
case .card, .link, .USBankAccount, .instantDebits:
return true
case .alipay, .AUBECSDebit, .bacsDebit, .SEPADebit, .iDEAL, .FPX, .cardPresent, .giropay,
.grabPay, .EPS, .przelewy24, .bancontact, .netBanking, .OXXO, .payPal, .sofort, .UPI,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@ final public class FinancialConnectionsSheet {
/// :nodoc:
extension FinancialConnectionsSheet: HostControllerDelegate {
func hostController(
_ hostController: HostController, viewController: UIViewController,
_ hostController: HostController,
viewController: UIViewController,
didFinish result: HostControllerResult
) {
viewController.dismiss(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,7 @@ extension PaymentSheet {
intent.supportsLink,
!recommendedStripePaymentMethodTypes.contains(.USBankAccount),
!intent.isDeferredIntent,
intent.linkFlags["link_disable_instant_debits_on_mobile"] != true
// intent.linkFundingSources?.contains(.bankAccount) == true
intent.linkFundingSources?.contains(.bankAccount) == true
{
recommendedStripePaymentMethodTypes.append(.instantDebits)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -716,12 +716,7 @@ extension PaymentSheetFormFactory {
)
}
}(),
emailElement: (
// TODO: does this email logic make sense?
(configuration.billingDetailsCollectionConfiguration.email != .never)
? makeEmail()
: nil
),
emailElement: makeEmail(),
theme: theme
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,8 @@ final class InstantDebitsPaymentMethodElement: Element {
var mandateString: NSMutableAttributedString? {
var string: String?
if linkedBank != nil {
string = STPLocalizedString(
"By continuing, you agree to authorize payments pursuant to <terms>these terms</terms>.",
"Text providing link to terms for ACH payments"
)
// TODO(kgaidis): localize
string = "By continuing, you agree to authorize payments pursuant to <terms>these terms</terms>."
} else {
string = nil
}
Expand Down Expand Up @@ -93,19 +91,6 @@ final class InstantDebitsPaymentMethodElement: Element {
emailElement: PaymentMethodElement?,
theme: ElementsUITheme = .default
) {
let willShowEmailField = (configuration.billingDetailsCollectionConfiguration.email != .never)
let hasDefaultEmail = (
configuration.billingDetailsCollectionConfiguration.attachDefaultsToPaymentMethod
&& configuration.defaultBillingDetails.email != nil
)

// Fail loudly: This is an integration error
assert(
// TODO: is it a mandatory step to provide an email???
(willShowEmailField || hasDefaultEmail),
"If email is not collected, they must be provided through defaults"
)

self.configuration = configuration
self.linkedBankInfoView = BankAccountInfoView(frame: .zero, theme: theme)
self.linkedBankInfoSectionElement = SectionElement(
Expand Down

0 comments on commit 2de23f5

Please sign in to comment.