Add a card
Creating card information object
As the user enters their card information, create a CardInformation
object.
Adding a 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 |
---|---|
card | A CardInformation object. |
receiveOn | The dispatch queue used when invoking the result callback handler. Defaults to main. |
onResult | Result callback handler. |
Please note
SveaWalletClient
is deprecated in version 3.1.0. Use new class SveaAppWallet
instead.let cardInformation = CardInformation(
cardNumber: "XXXXXXXXXXXXXXXX",
expirationDate: CardDate(
month: "12",
year: "20"
),
label: "My card",
securityCode: "XXX"
)
SveaAppWallet.shared.add(card: cardInformation) { [weak self] result in
switch result {
case .success(let paymentMethod):
print("Card successfully added \(paymentMethod)")
case .failure(let error):
print("Card could not be added, got error \(error)")
}
}
let cardInformation = CardInformation(
cardNumber: "XXXXXXXXXXXXXXXX",
expirationDate: CardDate(
month: "12",
year: "20"
),
label: "My card",
securityCode: "XXX"
)
SveaWalletClient.shared.add(card: cardInformation) { [weak self] result in
switch result {
case .onSuccess(let paymentMethod):
print("Card successfully added \(paymentMethod)")
case .onFailure(let error):
print("Card could not be added, got error \(error)")
}
}
onSuccess
Returned if the card was successfully added, including the card information in a PaymentMethod
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 noUserTokenProvided // A user 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 failedToAddCard // Something went wrong while adding a card.
case unknownError // An unknown error occurred.
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 |