STPSourceParams

public class STPSourceParams : NSObject, STPFormEncodable, NSCopying

An object representing parameters used to create a Source object.

  • Declaration

    Swift

    @objc
    public var additionalAPIParameters: [AnyHashable : Any]
  • The type of the source to create. Required.

    Declaration

    Swift

    @objc
    public var type: STPSourceType { get set }
  • The raw underlying type string sent to the server. Generally you should use type instead unless you have a reason not to. You can use this if you want to create a param of a type not yet supported by the current version of the SDK’s STPSourceType enum. Setting this to a value not known by the SDK causes type to return STPSourceTypeUnknown

    Declaration

    Swift

    @objc
    public var rawTypeString: String?
  • A positive integer in the smallest currency unit representing the amount to charge the customer (e.g., @1099 for a €10.99 payment). Required for single_use sources.

    Declaration

    Swift

    @objc
    public var amount: NSNumber?
  • The currency associated with the source. This is the currency for which the source will be chargeable once ready.

    Declaration

    Swift

    @objc
    public var currency: String?
  • The authentication flow of the source to create. flow may be “redirect”, “receiver”, “verification”, or “none”. It is generally inferred unless a type supports multiple flows.

    Declaration

    Swift

    @objc
    public var flow: STPSourceFlow
  • A set of key/value pairs that you can attach to a source object.

    Declaration

    Swift

    @objc
    public var metadata: [AnyHashable : Any]?
  • Information about the owner of the payment instrument. May be used or required by particular source types.

    Declaration

    Swift

    @objc
    public var owner: [AnyHashable : Any]?
  • Parameters required for the redirect flow. Required if the source is authenticated by a redirect (flow is “redirect”).

    Declaration

    Swift

    @objc
    public var redirect: [AnyHashable : Any]?
  • An optional token used to create the source. When passed, token properties will override source parameters.

    Declaration

    Swift

    @objc
    public var token: String?
  • Whether this source should be reusable or not. usage may be “reusable” or “single_use”. Some source types may or may not be reusable by construction, while other may leave the option at creation.

    Declaration

    Swift

    @objc
    public var usage: STPSourceUsage
  • Initializes an empty STPSourceParams.

    Declaration

    Swift

    override public required init()

Constructors

  • Creates params for a Bancontact source.

    Declaration

    Swift

    @objc
    public class func bancontactParams(
      withAmount amount: Int,
      name: String,
      returnURL: String,
      statementDescriptor: String?
    ) -> STPSourceParams

    Parameters

    amount

    The amount to charge the customer in EUR.

    name

    The full name of the account holder.

    returnURL

    The URL the customer should be redirected to after they have successfully verified the payment.

    statementDescriptor

    (Optional) A custom statement descriptor for the payment. @note The currency for Bancontact must be “eur”. This will be set automatically for you.

    Return Value

    an STPSourceParams object populated with the provided values.

  • Creates params for a Card source.

    Declaration

    Swift

    @objc
    public class func cardParams(withCard card: STPCardParams) -> STPSourceParams

    Parameters

    card

    An object containing the user’s card details

    Return Value

    an STPSourceParams object populated with the provided card details.

  • Creates params for a Giropay source.

    Declaration

    Swift

    @objc
    public class func giropayParams(
      withAmount amount: Int,
      name: String,
      returnURL: String,
      statementDescriptor: String?
    ) -> STPSourceParams

    Parameters

    amount

    The amount to charge the customer in EUR.

    name

    The full name of the account holder.

    returnURL

    The URL the customer should be redirected to after they have successfully verified the payment.

    statementDescriptor

    (Optional) A custom statement descriptor for the payment. @note The currency for Giropay must be “eur”. This will be set automatically for you.

    Return Value

    an STPSourceParams object populated with the provided values.

  • Creates params for an iDEAL source.

    Declaration

    Swift

    @objc
    public class func idealParams(
      withAmount amount: Int,
      name: String?,
      returnURL: String,
      statementDescriptor: String?,
      bank: String?
    ) -> STPSourceParams

    Parameters

    amount

    The amount to charge the customer in EUR.

    name

    (Optional) The full name of the account holder.

    returnURL

    The URL the customer should be redirected to after they have successfully verified the payment.

    statementDescriptor

    (Optional) A custom statement descriptor for t he payment.

    bank

    (Optional) The customer’s bank. @note The currency for iDEAL must be “eur”. This will be set automatically for you.

    Return Value

    an STPSourceParams object populated with the provided values.

  • Creates params for a SEPA Debit source.

    Declaration

    Swift

    @objc
    public class func sepaDebitParams(
      withName name: String,
      iban: String,
      addressLine1: String?,
      city: String?,
      postalCode: String?,
      country: String?
    ) -> STPSourceParams

    Parameters

    name

    The full name of the account holder.

    iban

    The IBAN number for the bank account you wish to debit.

    addressLine1

    (Optional) The bank account holder’s first address line.

    city

    (Optional) The bank account holder’s city.

    postalCode

    (Optional) The bank account holder’s postal code.

    country

    (Optional) The bank account holder’s two-letter country code. @note The currency for SEPA Debit must be “eur”. This will be set automatically for you.

    Return Value

    an STPSourceParams object populated with the provided values.

  • Creates params for a Sofort source.

    Declaration

    Swift

    @objc
    public class func sofortParams(
      withAmount amount: Int,
      returnURL: String,
      country: String,
      statementDescriptor: String?
    ) -> STPSourceParams

    Parameters

    amount

    The amount to charge the customer in EUR.

    returnURL

    The URL the customer should be redirected to after they have successfully verified the payment.

    country

    The country code of the customer’s bank.

    statementDescriptor

    (Optional) A custom statement descriptor for the payment. @note The currency for Sofort must be “eur”. This will be set automatically for you.

    Return Value

    an STPSourceParams object populated with the provided values.

  • Creates params for a Klarna source.

    Declaration

    Swift

    public class func klarnaParams(
      withReturnURL returnURL: String,
      currency: String,
      purchaseCountry: String,
      items: [STPKlarnaLineItem],
      customPaymentMethods: [STPKlarnaPaymentMethods],
      billingAddress address: STPAddress? = nil,
      billingFirstName firstName: String? = nil,
      billingLastName lastName: String? = nil,
      billingDOB dateOfBirth: STPDateOfBirth? = nil
    ) -> STPSourceParams

    Parameters

    returnURL

    The URL the customer should be redirected to after they have successfully verified the payment.

    currency

    The currency the payment is being created in.

    purchaseCountry

    The ISO-3166 2-letter country code of the customer’s location.

    items

    An array of STPKlarnaLineItems. Klarna will present these on the confirmation page. The total amount charged will be a sum of the totalAmount of each of these items.

    customPaymentMethods

    Required for customers located in the US. This determines whether Pay Later and/or Slice It is offered to a US customer.

    address

    An STPAddress for the customer. At a minimum, an email, line1, postalCode, city, and country must be provided. The address’ name will be ignored in favor of the firstName andlastName` parameters.

    firstName

    The customer’s first name.

    lastName

    The customer’s last name. If the provided information is missing a line1, postal code, city, email, or first/last name, or if the country code is outside the specified country, no address information will be sent to Klarna, and Klarna will prompt the customer to provide their address.

    dateOfBirth

    The customer’s date of birth. This will be used by Klarna for a credit check in some EU countries. The optional fields (address, firstName, lastName, and dateOfBirth) can be provided to skip Klarna’s customer information form. If this information is missing, Klarna will prompt the customer for these values during checkout. Be careful with this option: If the provided information is invalid, Klarna may reject the transaction without giving the customer a chance to correct it.

    Return Value

    an STPSourceParams object populated with the provided values.

  • Creates params for a Klarna source.

    Declaration

    Swift

    public class func klarnaParams(
      withReturnURL returnURL: String,
      currency: String,
      purchaseCountry: String,
      items: [STPKlarnaLineItem],
      customPaymentMethods: [STPKlarnaPaymentMethods]
    ) -> STPSourceParams

    Parameters

    returnURL

    The URL the customer should be redirected to after they have successfully verified the payment.

    currency

    The currency the payment is being created in.

    purchaseCountry

    The ISO-3166 2-letter country code of the customer’s location.

    items

    An array of STPKlarnaLineItems. Klarna will present these in the confirmation dialog. The total amount charged will be a sum of the totalAmount of each of these items.

    customPaymentMethods

    Required for customers located in the US. This determines whether Pay Later and/or Slice It is offered to a US customer.

    Return Value

    an STPSourceParams object populated with the provided values.

  • Creates params for a 3DS source.

    Declaration

    Swift

    @objc
    public class func threeDSecureParams(
      withAmount amount: Int,
      currency: String,
      returnURL: String,
      card: String
    ) -> STPSourceParams

    Parameters

    amount

    The amount to charge the customer.

    currency

    The currency the payment is being created in.

    returnURL

    The URL the customer should be redirected to after they have successfully verified the payment.

    card

    The ID of the card source.

    Return Value

    an STPSourceParams object populated with the provided card details.

  • Creates params for a single-use Alipay source

    Declaration

    Swift

    @objc
    public class func alipayParams(
      withAmount amount: Int,
      currency: String,
      returnURL: String
    ) -> STPSourceParams

    Parameters

    amount

    The amount to charge the customer.

    currency

    The currency the payment is being created in.

    returnURL

    The URL the customer should be redirected to after they have successfully verified the payment.

    Return Value

    An STPSourceParams object populated with the provided values

  • Creates params for a reusable Alipay source

    Declaration

    Swift

    @objc
    public class func alipayReusableParams(
      withCurrency currency: String,
      returnURL: String
    ) -> STPSourceParams

    Parameters

    currency

    The currency the payment is being created in.

    returnURL

    The URL the customer should be redirected to after they have successfully verified the payment.

    Return Value

    An STPSourceParams object populated with the provided values

  • Creates params for a P24 source

    Declaration

    Swift

    @objc
    public class func p24Params(
      withAmount amount: Int,
      currency: String,
      email: String,
      name: String?,
      returnURL: String
    ) -> STPSourceParams

    Parameters

    amount

    The amount to charge the customer.

    currency

    The currency the payment is being created in (this must be EUR or PLN)

    email

    The email address of the account holder.

    name

    The full name of the account holder (optional).

    returnURL

    The URL the customer should be redirected to after they have

    Return Value

    An STPSourceParams object populated with the provided values.

  • Creates params for a card source created from Visa Checkout.

    Seealso

    https://stripe.com/docs/visa-checkout @note Creating an STPSource with these params will give you a source with type == STPSourceTypeCard

    Declaration

    Swift

    @objc
    public class func visaCheckoutParams(withCallId callId: String) -> STPSourceParams

    Parameters

    callId

    The callId property from a VisaCheckoutResult object.

    Return Value

    An STPSourceParams object populated with the provided values.

  • Creates params for a card source created from Masterpass.

    Seealso

    https://stripe.com/docs/masterpass @note Creating an STPSource with these params will give you a source with type == STPSourceTypeCard

    Declaration

    Swift

    @objc
    public class func masterpassParams(
      withCartId cartId: String,
      transactionId: String
    ) -> STPSourceParams

    Parameters

    cartId

    The cartId from a MCCCheckoutResponse object.

    transactionId

    The transactionid from a MCCCheckoutResponse object.

    Return Value

    An STPSourceParams object populated with the provided values.

  • Create params for an EPS source

    Declaration

    Swift

    @objc
    public class func epsParams(
      withAmount amount: Int,
      name: String,
      returnURL: String,
      statementDescriptor: String?
    ) -> STPSourceParams

    Parameters

    amount

    The amount to charge the customer.

    name

    The full name of the account holder.

    returnURL

    The URL the customer should be redirected to after the authorization process.

    statementDescriptor

    A custom statement descriptor for the payment (optional).

    Return Value

    An STPSourceParams object populated with the provided values.

  • Create params for a Multibanco source

    Declaration

    Swift

    @objc
    public class func multibancoParams(
      withAmount amount: Int,
      returnURL: String,
      email: String
    ) -> STPSourceParams

    Parameters

    amount

    The amount to charge the customer.

    returnURL

    The URL the customer should be redirected to after the authorization process.

    email

    The full email address of the customer.

    Return Value

    An STPSourceParams object populated with the provided values.

  • Create params for a WeChat Pay native app redirect source @note This feature is in private beta. For participating users, see https://stripe.com/docs/sources/wechat-pay/ios

    Declaration

    Swift

    @objc(wechatPayParamsWithAmount:currency:appId:statementDescriptor:)
    public class func wechatPay(
      withAmount amount: Int,
      currency: String,
      appId: String,
      statementDescriptor: String?
    ) -> STPSourceParams

    Parameters

    amount

    The amount to charge the customer.

    currency

    The currency of the payment

    appId

    Your WeChat-provided application id. WeChat Pay uses this as the redirect URL scheme

    statementDescriptor

    A custom statement descriptor for the payment (optional).

    Return Value

    An STPSourceParams object populated with the provided values.

Redirect Dictionary

  • Private setter allows for setting the name of the app in the returnURL so that it can be displayed on hooks.stripe.com if the automatic redirect back to the app fails. We intercept the reading of redirect dictionary from STPFormEncoder and replace the value of return_url if necessary

    Declaration

    Swift

    @objc
    public func redirectDictionaryWithMerchantNameIfNecessary() -> [AnyHashable : Any]

STPFormEncodable