WorldpayTotal SDK

Build status

WorldpayTotal SDK is a library which allow partners to develop Apps to be able to connect to the Worldpay Total platform and make payments.

Features

  • [x] Card Sale, Refund, Pre-auth and Settle
  • [x] Tokenised Sale and Refund
  • [x] Cancel Card Sale
  • [x] Query Previous Payment for Results and Receipts

Requirements

  • iOS 9.0+
  • Xcode 11.3.1+

Installation

  • Download the WorldpayTotalSDK framework
  • Copy the framework to the root of your project
  • Add it, on the section Frameworks, Libraries and Embedded Content (General tab)
  • Add $(PROJECT_DIR)/** to Framework Search Paths (Build Settings tab)
  • Add $(PROJECT_DIR)/WorldpayTotalSDK.framework/Dependencies/** to Import Paths

Usage example

  • To start a payment, follow this simple steps:
    • Instantiate a PaymentManager object
    • Create a CardSale object (or any other sale/refund type you may want)
    • Set the callback handlers for each type of responses
    • Call the startPayment (or any of the payment options available) from the PaymentManager object
let cardSale = CardSale(laneId: "INST001",
                        type: .cardPresent,
                        value: 1099,
                        currencyCode: "GBP",
                        transactionReference: "MS_123-A54B3DF")

let notification = { notification in
    print(notification.transactionReference)
    print(notification.status)
}
let receipt = { receipt in
    print(receipt.transactionReference)
    print(receipt.content)
}
let result = { result in
    print(result.payments?[0].transactionReference)
    print(result.payments?[0].code)
}
[...]
let paymentResponse = PaymentResponseHandler(notificationReceived: notification,
                                             actionReceived: actionReceived,
                                             receiptReceived: receipt,
                                             resultReceived: result,
                                             paymentComplete: paymentComplete,
                                             errorReceived: errorReceived)

PaymentManager.shared.startPayment(request: cardSale, handler: paymentResponse)

Where to go from here?

Check out our documentation