TM-SGNL-iOS/SignalServiceKit/Subscriptions/Donations/DonationPaymentMethod.swift
TeleMessage developers dde0620daf initial commit
2025-05-03 12:28:28 -07:00

41 lines
1.1 KiB
Swift

//
// Copyright 2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
//
/// Payment methods that a user could donate with.
///
/// May be confused with ``Stripe.PaymentMethod``, which represents a payment
/// method that's ready to submit to Stripe.
///
/// - Note
/// The raw value of this type is used for on-disk persistence, for historical
/// compatibility. However, a different format is used when parsing payment
/// methods from the service.
public enum DonationPaymentMethod: String {
case applePay
case creditOrDebitCard
case paypal
case sepa
case ideal
/// Parse a payment method from a string provided by the service.
///
/// - Note
/// Payments made using Apple Pay are returned as "card payments" by the
/// service.
public init?(serverRawValue: String) {
switch serverRawValue {
case "CARD":
self = .creditOrDebitCard
case "PAYPAL":
self = .paypal
case "SEPA_DEBIT":
self = .sepa
case "IDEAL":
self = .ideal
default:
return nil
}
}
}