Skip to main content

PAN Hash

Overview

The plugin obtains and shares a hash representation of the transaction card's PAN (Primary Account Number) to the integrating app.

Downloading plugin dependency

In order to install the plugin, the integrating app must obtain the dependency through cocoapods dependency manager.

target 'Integrating-App-Main-Target' do
use_frameworks!
.
.
pod 'GePanHashPlugin', '~> 1.0'
.
.
end

Once the dependency is installed, it can be imported and used as follows

import GeoiOSPanHashPlugin

Injecting Pan hash plugin to the SDK

All plugins are injected into the SDK during configuration by calling the set(plugins:) method

        do {
let paymentsConfiguration = try PaymentsConfiguration.Builder(
endpoint: URL(string: "https://valid-url")!,
.
.
).set(plugins:
[
SDKPanHashPluginInstallerFactory.getInstaller(
delegate: self,
url: URL(string: "https://valid-url")!
)
]
)
.
.
.build()

PaymentsSDK.configure(paymentsConfiguration: paymentsConfiguration)
} catch {
// Handle error
}

where SDKPanHashPluginInstallerFactory is the factory method to obtain an instance of the plugin. the delegate is any object that implements SDKPanHashCallback protocol and url is the integrating app's backend url, which most likely will be the same as the one injected to the SDK during configuration.

  • Once retrieved successfully, the data is decoded into the PanHashResponseData struct, which contains the Pan Hash as a UUID object, and the transaction card asociated with it

  • On PAN hash request error, the integrating app will receive a recoverable error of type internalError

public struct PanHashResponseData {
public let panHash: UUID
public let transactionCard: PanHashTransactionCard
}

public struct PanHashTransactionCard {
public let maskedPan: String
public let cardHolderName: String
public let cardReadMode: PanHashCardReadMode
}

Example of an implementation of the SDKPanHashCallback protocol

As mentioned earlier, the Integrating app must implement this protocol to provide mandatory data to the plugin when needed

extension someClass: SDKPanHashCallback {
func onRetrieved(_ panhash: PanHashResponseData) {
// Do something with the Pan hash
}

func getAuthToken() -> String {
"Integrating app's auth token"
}

func getApplicationKey() -> String {
"app_key"
}
}