-
Notifications
You must be signed in to change notification settings - Fork 982
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add promo badge in horizontal and vertical mode
- Loading branch information
1 parent
064831e
commit 91b5ab1
Showing
9 changed files
with
208 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
StripePaymentSheet/StripePaymentSheet/Source/PaymentSheet/PaymentMethodIncentive.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// | ||
// PaymentMethodIncentive.swift | ||
// StripePaymentSheet | ||
// | ||
// Created by Till Hellmund on 11/19/24. | ||
// | ||
|
||
import Foundation | ||
@_spi(STP) import StripePayments | ||
|
||
struct PaymentMethodIncentive { | ||
|
||
let identifier: String | ||
let displayText: String | ||
|
||
init( | ||
identifier: String, | ||
text: String | ||
) { | ||
self.identifier = identifier | ||
self.displayText = text | ||
} | ||
|
||
func takeIfAppliesTo(_ paymentMethodType: PaymentSheet.PaymentMethodType) -> PaymentMethodIncentive? { | ||
switch paymentMethodType { | ||
case .stripe, .external: | ||
return nil | ||
case .instantDebits, .linkCardBrand: | ||
return identifier == "link_instant_debits" ? self : nil | ||
} | ||
} | ||
} | ||
|
||
extension PaymentMethodIncentive { | ||
|
||
init?(from incentive: LinkConsumerIncentive) { | ||
guard let displayText = incentive.incentiveDisplayText else { | ||
return nil | ||
} | ||
|
||
self.identifier = incentive.incentiveParams.paymentMethod | ||
self.displayText = displayText | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.