Create a recurring account
To create an account you need to:
- Get and register UserToken in client SDK
- Get available recurring account types. and select a
RecurringType
- Create recurring account in the server API and get string token
- Gather card details
- Call createRecurringAccount in Client with the token from previous step and
cardInformation
(SDK will trigger 3DS check if needed) - Verify account status through server (Client will return an initial success or fail, but the status should be verify through server)
This example uses RecurringCard as account type
info
Android: 2.4.0
iOS: 3.2.0
Creating card information object
As the user enters their card information, create a CardInformation
object.
Adding a recurring card
info
If a card needs to be 3DSecure enrolled, then a web view will be shown to the user.
The Svea App Wallet SDK will automatically dismiss this view once the information is processed.
The 3DSecure session is valid for 20 minutes.
Parameter | Description |
---|---|
recurringAccountToken | A valid recurring account token from your backend. |
card | A CardInformation object. |
receiveOn | The dispatch queue used when invoking the result callback handler. Defaults to main. |
onResult | Result callback handler. |
let cardInformation = CardInformation(
cardNumber: "XXXXXXXXXXXXXXXX",
expirationDate: CardDate(
month: "12",
year: "20"
),
label: "My card",
securityCode: "XXX"
)
SveaAppWallet.shared.createRecurringAccount(recurringAccountToken: recurringAccountToken,
card: cardInformation) { [weak self] result in
switch result {
case .success:
print("Recurring account card successfully added!")
case .failure(let error):
print("Recurring account card could not be added, got error \(error)")
}
}
onSuccess
Returned if the recurring card was successfully created.
Please note
The initial, unmasked card information added by the user should never be saved in your systems.
onFailure
Returned if the card cannot be added.
Possible errors
case noRecurringAccountTokenProvided // A recurring token was not provided.
case invalidCardNumber // The card number is not valid.
case invalidMonth // The month value is bigger than 12 or smaller than 1.
case invalidYear // The year value is not 2 digits.
case monthInThePast // The selected year is valid, but the month has passed.
case yearInThePast // The selected year has passed.
case invalidSecurityCode // Invalid security code.
case failedToCreateRecurringAccount // Something went wrong while creating account.
Test cards
In the stage environment test cards are expected.
Use one of the test card numbers from the list below together with an expire date in the future and random cvc code.
Note
These test cards should only be used in stage. Real card information should only be used in production.
Mastercard | Visa | Amex |
---|---|---|
5392127332010533 | 4916423239778102 | 373577924279157 |
5563015872367467 | 4539135129670408 | 349280060805312 |
5590714784028392 | 4307836552780776 | 34343434343434 |
5498729162772067 | 4556713187886682 |