Initialization

Start using myPOS Mobile Checkout iOS SDK by initializing it. Find your account’s unique number on the Dashboard. Choose a store, which will accept the payments. Provide its store id to the SDK. Set the currency to match the store’s one and in which payments will be processed. Follow the instructions regarding the key generation on page. After obtaining a certificate and private key, you will need to convert it to DER format. Use to following command:

openssl x509 -outform der -in public_cert.txt -out public_cert.der

 

After generating and copying the private key save it to a file with .pem extension.

 

Note: Include the certificate and private key files in your project. Then go to Build Phases -> Copy Bundle Resource and add the files.

 

Only thing left is to provide all this data to the SDK.

 

MobilePaymentSDK.initialize(accountNumber: "1234567890",
                            storeId: "12345",
                            currency: .eur,
                            certificate: "public_cert",
                            privateKey: "private_key")
[MobilePaymentSDK initializeWithAccountNumber:@"1234567890"
                                      storeId:@"12345"
                                     currency:CurrencyEUR
                                  certificate:@"public_cert"
                                   privateKey:@"private_key"
                                       bundle:[NSBundle mainBundle]
                                     keyIndex:1];

Note: “bundle” and “keyIndex” are optional in Swift and default to main bundle and first key index. The key index represents the sequence of the generated key. In Objective-C we need to provide those to the SDK. The bundle will be used to look for the certificate, private key and localization files.

 

 The SDK allows further configuration by using the existing settings. These are the options:

  • Supported card networks – Allows you to determine the accepted card networks when using your app. The default value includes Visa, Visa Electron, MasterCard, Maestro and VPay.
  • Address Verification Service (AVS) – You will be able to capture the consumer’s country and postcode as an additional security layer.

 

Add a Card


 Create an instance of StoreCardViewController with a verification amount and a delegate to handle various outcomes of the operation:

 

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

present(controller, animated: true, completion: nil)
StoreCardViewController *controller = [[StoreCardViewController alloc] initWithVerificationAmount:1.00
                                                                                         delegate:self];

[self presentViewController:controller animated:YES completion:nil];

 

The delegate must implement StoreCardDelegate’s methods.

func storeCardDidComplete(withData storedCard: StoredCard)
func storeCardDidFailWithError(_ error: MobilePaymentSDKError)
- (void)storeCardDidCompleteWithData:(StoredCard *)storedCard
- (void)storeCardDidFailWithError:(MobilePaymentSDKError *)error;

 

Update a Stored Card


Create an instance of UpdateStoredCardViewController with a verification amount and a delegate to handle various outcomes of the operation:

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

present(controller, animated: true, completion: nil)
UpdateStoredCardViewController *controller = [[UpdateStoredCardViewController alloc] initWithCardToken:_card.token
                                                                                    verificationAmount:1.00
                                                                                              delegate:self];
[self presentViewController:controller animated:YES completion:nil];

 

The delegate must implement StoreCardDelegate’s methods.

 

func updateStoredCardDidComplete(withData storedCard: StoredCard, forCardWithToken cardToken: String)
func updateStoredCardDidFailWithError(_ error: MobilePaymentSDKError)
- (void)updateStoredCardDidCompleteWithData:(StoredCard *)storedCard forCardWithToken:(NSString *)cardToken
- (void)updateStoredCardDidFailWithError:(MobilePaymentSDKError *)error