I’m a beginner, and I’m trying to implement Omise to process payments in an iOS application. I need to save a new user’s card during the registration process, and then I need a way to charge that saved card later.
I’ve setup a SQLite database using Realm.
I’ve imported OmiseSDK and created a client constant with my public key using the init method below.
- let client = OmiseSDK.Client.init(publicKey: “omise_public_key”)
I’ve added an extension containing the required didSucceedWithToken, didFailWithError, and creditCardFormViewControllerDidCancel methods.
I’m able to present the built-in creditCardFormViewController by pushing it onto the navigation controller stack.
When I run my app and use the test card number, it succeeds, and the didSucceedWithToken method is called. At this point, I have these questions:
I know I’m not supposed to save actual card info to my database, so what do I save, just the token identifier?
Do I need to create an Omise Customer object and add the token identifier to that Customer as a card? If so, how do I create a customer? The Omise docs say “When unused token identifiers are added to customers, they are saved as Cards which can be used for repeated purchases,” but it doesn’t provide examples of how to create a new Omise Customer in Swift; it shows other languages, but not Swift. I tried using the Client class to check if there are some ‘create’ or ‘customer’-related methods or properties, but I’m not seeing any.
Once I figure out how to save the card and associate it with a specific customer, what method do I use to actually charge the card later?
Sorry if some of these questions have obvious answers. I’m really a beginner, and I would appreciate any help you could offer. Thank you!