MyCheckWalletUI 1.2.5

MyCheckWalletUI 1.2.5

Maintained by Dudi Hisine, dudi.



 
Depends on:
MyCheckCore>= 0
Kingfisher~> 3.0
 

  • By
  • elad schiller

MyCheckWalletUI

An SDK that supplies UI for payment method managment.

Example

To run the example project, clone the repo, and run pod install from the Example directory first. The example demonstrates displaying a Checkout view controller , displaying a payment manager view controller and getting the token when ready to pay.

Requirements

iOS 9 or above. Swift 3.0

Installation

MyCheckWalletUI is available through CocoaPods. You will first need to ask a MyCheck team member to give you read privileges to the MyCheck Repository. Once you have gotten the privileges, install it by simply adding the following lines to the top of your Podfile:

source 'https://bitbucket.org/erez_spatz/pod-spec-repo.git'
source 'https://github.com/CocoaPods/Specs.git'

This will set both the public CocoaPods Repo and the MyCheck private repo as targets for CocoaPods to search for frameworks from.

You can add YOUR_USER_NAME@ before the 'bitbucket.org' so the pod tool won't need to ask you for it every time you update or install.

inside the target add:

pod "MyCheckWalletUI"

Now you can run 'pod install'

Use

In order to manage the users session (login, logout etc.) you will need to use the session singleton.

Start by adding

import MyCheckCore

import MyCheckWalletUI

to the top of the class where you want to use MyCheck.

In your app delegate's application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) function call the configure function of the Session singleton as well as the Wallets:

Session.shared.configure(YOUR_PUBLISHABLE_KEY, environment: .sandbox)

Wallet.shared.configureWallet()

This will setup the SDK to work with the desired environment.

Before using any other functions you will have to login the user. Login is done by first obtaining a refresh token from your server (that, in turn, will obtain it from the MyCheck server using the secret key). Once you have the refresh token call the login function on the Session singleton:

Session.shared.login(REFRESH_TOKEN, success: HANDLE_SUCCESS
}, fail: HANDLE_FAIL)

Once you are logged in add

import MyCheckWalletUI

###Wallet The Wallet singleton can be used in order to obtain a payment method if the MCCheckoutViewController is not used for checkout. If this is the case the default payment method can be used.

Wallet.shared.getDefaultPaymentMehthod(success: {method in

}, fail: {
error in

})

###Wallet.UI The Wallet singleton has a default UI settings ( default fonts ) , You can set your own fonts in order the SDK to use them. 1.Your fonts has to be in your app budle. 2.The fonts has to be in the Info.plist file. 3.Use setCustomeFont method.

Wallet.shared.setCustomeFonts(regularFont: UIFont , boldFont: UIFont)

###MCCheckoutViewController This view controller is meant to be embedded inside your view controller. It allows the user the basic functions needed from a wallet:

  1. Add a payment method

  2. Select a payment method The view controller should be added into a container view. It can be done in two ways.

  3. Interface builder: change the view controller that the container is connect to (by segue) to MCCheckoutViewController.

  4. In code: call MCCheckoutViewController.init() in order to create the instance.

Once an instance is created you should set checkoutDelegate and implement checkoutViewShouldResizeHeight in order to respond to height changes. You should resize the container view to have the height returned by the delegate method. When you want to use a payment method use the view controllers variable selectedMethod in order to get the method the user selected (or nil if nonexistent)

###MCPaymentMethodsViewController This class is a full screen view controller that allows the user to fully manage his/her payment methods:

  1. Display all his/her payment methods.
  2. Choose a default payment method.
  3. Delete payment methods.
  4. Add payment methods.

In order to create a MCPaymentMethodsViewController instance call the constructor and present it like so:

let controller = MCPaymentMethodsViewController.createPaymentMethodsViewController(self)
self.presentViewController(controller, animated: true, completion: nil)

You must also implement the MCPaymentMethodsViewControllerDelegate and dismiss the view controller when it is done (see example)


func dismissedMCPaymentMethodsViewController(controller: MCPaymentMethodsViewController){
controller.dismissViewControllerAnimated(true, completion: nil)
}

PayPal

There are additional steps to take in order for PayPal to work. Start by installing the PayPal model. This will add the Braintree PayPal SDK as well as extra source files from the MyCheck Wallet UI SDK. Add this line to your Podfile:

pod "MyCheckWalletUI/PayPal"

once this is done you will need to also add a line of code initializing the PayPal model.

PaypalFactory.initiate(YOUR_PACKAGE_NAME)

The last line of code necessary is to allow the MyCheck Wallet UI SDK to respond to app switching. This is necessary because the PayPal SDK opens an external app/ browser.

func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {

return MyCheckWallet.shared.handleOpenURL(url, sourceApplication: sourceApplication)

}

Lastly, to fully support PayPal and the app switching it uses please edit your info.plist as described in the "Register a URL type" section of the PayPal Braintree SDK guide found here.

Apple Pay

Their are a few extra steps to take in order for Apple Pay to work. Start by configuring your environment to support Apple Pay by following these instructions. Send a p12 with the the certificate and private key you have created and the merchant Id to a member of the MyCheck team. now install the Apple Pay model of the MyCheckWalletUI SDK by adding this line to your Podfile:

pod "MyCheckWalletUI/ApplePay"

After running pod install you will need to also add a line of code initializing the Apple Pay model with the merchant identifier you have created in the apple developers site in the last step .

ApplePayFactory.initiate(merchantIdentifier: YOUR_MERCHANT_ID)

The line of code above should be added in the application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) function of your application delegate after calling configure. Thats it for now. You will need to make a few more changes to add Apple Pay support to the Dine SDK, this is discussed in the Dine SDK README file and getting started guide.

Visa Checkout

Start by installing the Visa Checkout model. This will add the Visa Checkout SDK as well as extra source files from the MyCheck Wallet UI SDK. Add this line to your Podfile:

pod "MyCheckWalletUI/VisaCheckout"

once this is done you will need to also add a line of code initializing the Visa Checkout model.

VisaCheckoutFactory.initiate(apiKey: VISA_CHECKOUT_API_KEY )

Please make sure the api key has the corresponding environment to the one the MyCheck Wallet was configured with.

MasterPass

Start by installing the MasterPass model. Add this line to your Podfile:

pod "MyCheckWalletUI/MasterPass"

once this is done you will need to also add a line of code initializing the MasterPass model.

MasterPassFactory.initiate()

Authors

Elad Schiller, [email protected]

License

Please read the LICENSE file available in the project