Adding and Updating a Stored Card (iOS SDK)

This guide shows you how to let users add and update stored cards in your iOS app using the myPOS SDK. Follow the steps below for easy integration and a smooth card management experience.

Add a New Card

To add a new card, you need to create an instance of StoreCardViewController with a verification amount and assign a delegate to handle the outcomes.

let controller = MPStoreCardViewController(verificationAmount: 1.00, 
                                         delegate: self)

present(controller, animated: true, completion: nil)

Auto-Reverse Verification Amount (Optional)

If you want the SDK to automatically refund the verification amount after the card is tokenized, set autoReverse to true:

MobilePaymentSDK.initialize(accountNumber: "1234567890",
let controller = MPStoreCardViewController(verificationAmount: 0.00, autoReverse: true, delegate: self);

Implement the StoreCardDelegate

Make sure your class implements the StoreCardDelegate methods:

func storeCardDidComplete(withData storedCard: StoredCard)
func storeCardDidFailWithError(_ error: MobilePaymentSDKError)

Update an Existing Stored Card

To update a stored card (e.g., expiration date or cardholder name), create an instance of UpdateStoredCardViewController:

let controller = MPUpdateStoredCardViewController(cardToken: selectedCard.token
                                                verificationAmount: 1.00, 
                                                delegate: self)

present(controller, animated: true, completion: nil)

Implement the UpdateStoredCardDelegate

Your delegate should also implement these methods to handle update success or failure:

func updateStoredCardDidComplete(withData storedCard: StoredCard, forCardWithToken cardToken: String)
func updateStoredCardDidFailWithError(_ error: MobilePaymentSDKError)