This adds very basic support for donations via credit/debit card. It's missing important features which is why it's behind an internal-only feature flag. At a high level, this adds a new screen with a card form. This card data is submitted to Stripe and then uses the same "rails" as our existing Apple Pay donations. This change is missing a few important features, intended to be added soon: - [3D Secure][3DS] support - Validation error messages - Input formatting (e.g., "1234" becomes "12/34") - Gift badge support (currently only supports Apple Pay) - Various smaller UI changes [3DS]: https://stripe.com/docs/payments/3d-secure
41 lines
1.2 KiB
Swift
41 lines
1.2 KiB
Swift
//
|
|
// Copyright 2022 Signal Messenger, LLC
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
//
|
|
|
|
import Foundation
|
|
import PassKit
|
|
|
|
/// A fully valid payment method, ready to submit to Stripe.
|
|
///
|
|
/// May be confused with ``DonationPaymentMethod``, which represents a payment
|
|
/// method the user can choose.
|
|
public extension Stripe {
|
|
enum PaymentMethod {
|
|
public struct CreditOrDebitCard: Equatable {
|
|
public let cardNumber: String
|
|
public let expirationMonth: UInt8
|
|
public let expirationTwoDigitYear: UInt8
|
|
public let cvv: String
|
|
|
|
/// Creates a credit/debit card.
|
|
///
|
|
/// These fields should be fully valid.
|
|
public init(
|
|
cardNumber: String,
|
|
expirationMonth: UInt8,
|
|
expirationTwoDigitYear: UInt8,
|
|
cvv: String
|
|
) {
|
|
self.cardNumber = cardNumber
|
|
self.expirationMonth = expirationMonth
|
|
self.expirationTwoDigitYear = expirationTwoDigitYear
|
|
self.cvv = cvv
|
|
}
|
|
}
|
|
|
|
case applePay(payment: PKPayment)
|
|
case creditOrDebitCard(creditOrDebitCard: CreditOrDebitCard)
|
|
}
|
|
}
|