SavedPaymentMethod
public class SavedPaymentMethod: PaymentMethod
This is the base class to save a payment method and use it to process recurring payments or fast checkouts.
This class is sufficient for some payment methods (e.g. Twint). More complex payment
methods require you to specify additional details in their SavedPaymentMethod
subclass (e.g. card payments, PostFinance, etc.).
Please refer to this list to see if you need to use one of the subclasses for your payments:
- Easy payment methods: Swisscom Pay, SEPA (ELV), Twint, Apple Pay, CembraPay, SwissPass, Powerpay Invoice
- Complex payment methods (requiring a
SavedPaymentMethodsubclass): Card payments, PayPal, PostFinance, Reka, Boncard
Please refer to the Datatrans documentation to see if you can register a payment method during payment or require a dedicated registration.
-
The alias that can be used to process recurring payments or fast checkouts.
Declaration
Swift
public var alias: String -
A human readable title.
Declaration
Swift
public var displayTitle: String -
For VoiceOver this title is used instead of displayTitle.
Declaration
Swift
public var accessibilityTitle: String -
This init method has to be used to initialize a saved payment method.
Declaration
Swift
public init(type: PaymentMethodType, alias: String)Parameters
typePayment method type, e.g. PayPal or Twint
aliasThe alias that can be used to process recurring payments or fast checkouts.
-
Creates a
SavedPaymentMethodfrom a JSON string.Use this method to deserialize a saved payment method. It takes a JSON string that has been created with
toJson().The JSON string is compatible with the Android version of the Datatrans SDK.
Declaration
Swift
public class func create(jsonString: String) -> SavedPaymentMethod?Parameters
jsonStringThe JSON string representation
Return Value
The decoded
SavedPaymentMethodor one of its subclasses, if successful, nil ifjsonStringis invalid. -
Creates a
SavedPaymentMethodfrom data encoded by the old payment library.Declaration
Swift
public class func create(legacySavedPaymentMethodData: Data) -> SavedPaymentMethod?Parameters
legacySavedPaymentMethodDataData encoded by
DTRecurringPaymentMethod.data(),DTCreditCard.data(),DTPostFinanceCard.data(),DTReka.data(),DTPayPal.data()orDTELV.data().Return Value
The decoded
SavedPaymentMethodor one of its subclasses, if successful, nil iflegacySavedPaymentMethodDatais invalid. -
Returns a JSON string representation of this saved payment method object.
Use this method to serialize a saved payment method. The resulting JSON string can be deserialized with
create(jsonString:).The JSON string is compatible with the Android version of the Datatrans SDK.
Declaration
Swift
public func toJson() -> StringReturn Value
The JSON string representation
-
This function checks if the saved payment method is valid.
When e.g. called on a
SavedCardit tells you if the expiration date is in the future or not.Declaration
Swift
public func isValid() -> Bool
View on GitHub