Skip to content

wcoder/worldpay-access-checkout-ios-xamarin

Repository files navigation

Access Checkout iOS SDK

version NuGet Badge

Port of Worldpay/access-checkout-ios SDK for Xamarin.iOS.

A lightweight library and sample app that generates a Worldpay session reference from payment card data. It includes, optionally, custom iOS views that identifies card brands and validates payment cards and card expiry dates.

Setup

NuGet:

Install-Package Xamarin.iOS.Worldpay.Access.Checkout

Integration

https://beta.developer.worldpay.com/docs/access-worldpay/checkout/ios

Also you can see Xamarin.iOS sample here.

Create an AccessCheckoutClient instance

var baseUrl = new NSUrl("<ACCESS_CHECKOUT_BASE_URL>");
var accessCheckoutDiscovery = new AccessCheckoutDiscovery(baseUrl);

accessCheckoutDiscovery.Discover(NSUrlSession.SharedSession, () =>
{
    var accessCheckoutClient = new AccessCheckoutClient(accessCheckoutDiscovery, "<MERCHANT_ID>");

});

Submitting Form and getting sessionState

accessCheckoutClient.CreateSession(
    pan: "4444333322221111",
    expiryMonth: 1,
    expiryYear: 2022,
    cvv: "123",
    NSUrlSession.SharedSession,
    result =>
    {
        DispatchQueue.MainQueue.DispatchAsync(() =>
        {
            switch ((ResultStatus)result)
            {
                case ResultStatus.Success:
                    // Session is returned here
                    var session = result.Success;
                    break;
                case ResultStatus.Failure:
                    // Error handling
                    if (result.Failure is AccessCheckoutClientError accessCheckoutClientError)
                    {
                        switch (accessCheckoutClientError.ErrorName)
                        {
                            case AccessCheckoutClientErrors.BodyDoesNotMatchSchema:
                                // Handle validation errors
                                break;
                            default:
                                break;
                        }
                    }
                    else
                    {
                        // handle other errors
                    }
                    break;
            }
        });
    });

Continue: https://beta.developer.worldpay.com/docs/access-worldpay/checkout/ios/create-sessionstate-ios

Development

Xamarin.iOS Worldpay Checkout SDK exists in two versions:

  • Binding - Binding native Swift library via Objective-C to Xamarin (WIP)
    • TODO
  • Porting - Porting Swift source code to equivalent C# code (WIP)
    • TODO