@@ -206,6 +206,8 @@ class PaymentSheetFormFactory {
206
206
return makeiDEAL ( spec: spec)
207
207
} else if paymentMethod == . sofort {
208
208
return makeSofort ( spec: spec)
209
+ } else if paymentMethod == . SEPADebit {
210
+ return makeSepaDebit ( spec: spec)
209
211
}
210
212
211
213
// 2. Element-based forms defined in JSON
@@ -457,22 +459,42 @@ extension PaymentSheetFormFactory {
457
459
}
458
460
} ( )
459
461
let mandate : Element ? = isSettingUp ? makeSepaMandate ( ) : nil // Note: We show a SEPA mandate b/c sofort saves bank details as a SEPA Direct Debit Payment Method
460
- let elements : [ Element ? ] = [ contactSection, addressSection, mandate]
462
+ let checkboxElement : Element ? = makeSepaBasedPMCheckbox ( )
463
+ let elements : [ Element ? ] = [ contactSection, addressSection, checkboxElement, mandate]
461
464
return FormElement (
462
465
autoSectioningElements: elements. compactMap { $0 } ,
463
466
theme: theme
464
467
)
465
468
}
466
469
470
+ func makeSepaDebit( spec: FormSpec ) -> PaymentMethodElement {
471
+ let contactSection : Element ? = makeContactInformationSection (
472
+ nameRequiredByPaymentMethod: true ,
473
+ emailRequiredByPaymentMethod: true ,
474
+ phoneRequiredByPaymentMethod: false
475
+ )
476
+ let iban : Element = makeIban ( )
477
+ let mandate : Element ? = makeSepaMandate ( )
478
+ let addressSection : Element ? = makeBillingAddressSection ( )
479
+ let checkboxElement : Element ? = makeSepaBasedPMCheckbox ( )
480
+ let elements : [ Element ? ] = [ contactSection, iban, addressSection, checkboxElement, mandate]
481
+ return FormElement (
482
+ autoSectioningElements: elements. compactMap { $0 } ,
483
+ theme: theme
484
+ )
485
+ }
486
+
487
+
467
488
func makeBancontact( ) -> PaymentMethodElement {
468
489
let contactSection : Element ? = makeContactInformationSection (
469
490
nameRequiredByPaymentMethod: true ,
470
491
emailRequiredByPaymentMethod: isSettingUp,
471
492
phoneRequiredByPaymentMethod: false
472
493
)
473
494
let addressSection : Element ? = makeBillingAddressSectionIfNecessary ( requiredByPaymentMethod: false )
495
+ let checkboxElement : Element ? = makeSepaBasedPMCheckbox ( )
474
496
let mandate : Element ? = isSettingUp ? makeSepaMandate ( ) : nil // Note: We show a SEPA mandate b/c iDEAL saves bank details as a SEPA Direct Debit Payment Method
475
- let elements : [ Element ? ] = [ contactSection, addressSection, mandate]
497
+ let elements : [ Element ? ] = [ contactSection, addressSection, checkboxElement , mandate]
476
498
return FormElement (
477
499
autoSectioningElements: elements. compactMap { $0 } ,
478
500
theme: theme
@@ -518,7 +540,8 @@ extension PaymentSheetFormFactory {
518
540
519
541
let addressSection : Element ? = makeBillingAddressSectionIfNecessary ( requiredByPaymentMethod: false )
520
542
let mandate : Element ? = isSettingUp ? makeSepaMandate ( ) : nil // Note: We show a SEPA mandate b/c iDEAL saves bank details as a SEPA Direct Debit Payment Method
521
- let elements : [ Element ? ] = [ contactSection, bankDropdown, addressSection, mandate]
543
+ let checkboxElement = makeSepaBasedPMCheckbox ( )
544
+ let elements : [ Element ? ] = [ contactSection, bankDropdown, addressSection, checkboxElement, mandate]
522
545
return FormElement (
523
546
autoSectioningElements: elements. compactMap { $0 } ,
524
547
theme: theme
@@ -602,6 +625,26 @@ extension PaymentSheetFormFactory {
602
625
return FormElement ( elements: [ contactInfoSection, billingDetails] , theme: theme)
603
626
}
604
627
628
+ // Only show checkbox for PI+SFU & Setup Intent
629
+ func makeSepaBasedPMCheckbox( ) -> Element ? {
630
+ let isSaving = BoolReference ( )
631
+ let saveCheckbox = makeSaveCheckbox (
632
+ label: String (
633
+ format: STPLocalizedString (
634
+ " Save this account for future %@ payments " ,
635
+ " Prompt next to checkbox to save bank account. "
636
+ ) ,
637
+ configuration. merchantDisplayName
638
+ )
639
+ ) { value in
640
+ isSaving. value = value
641
+ }
642
+ isSaving. value = shouldDisplaySaveCheckbox && isSettingUp
643
+ ? configuration. savePaymentMethodOptInBehavior. isSelectedByDefault : isSettingUp
644
+
645
+ return shouldDisplaySaveCheckbox && isSettingUp ? saveCheckbox : nil
646
+ }
647
+
605
648
func makeCountry( countryCodes: [ String ] ? , apiPath: String ? = nil ) -> PaymentMethodElement {
606
649
let locale = Locale . current
607
650
let resolvedCountryCodes = countryCodes ?? addressSpecProvider. countries
0 commit comments