Portmone eCommerce iOS SDK
Glossary
| Term | Definition |
|---|---|
| Merchant, Online Store or Partner | Organization which has signed a payment acceptance agreement with Portmone.com |
| Buyer, Client or Customer | A person who visits the Merchant's Online Store in order to learn about the range of goods (services) and to make a purchase |
| Card, Payment Card | Payment cards of Visa, Mastercard international card associations and the National payment system PROSTIR |
| Token | A unique digital identifier of a card, which is generated during the first operation and then used for quick payment |
| Authorization | The procedure of obtaining confirmation from the issuing bank to make a payment by card |
| Biometric authorization | The process of payment confirmation using biometric data (e.g. fingerprint, facial features) identification technology |
| Issuing Bank (Card Issuing Bank) | A bank licensed as a member of a card association (like Visa or Mastercard), that issues and maintains payment cards |
| 3-D Secure | 3-D Secure is a protocol which is used for secure handling of online bank card payments |
General description
Portmone SDK supports iOS 12.0 version and above.
SDK can be integrated into the project in two ways:
- copy PortmoneSDKEcom.framework to the project manually:
Target → Build Phases → Embed Frameworks add this file and set Destination → Frameworks
- use CocoaPods:
pod 'PortmoneSDKEcom'
Usage scenarios
- Payment by card.
- Card token receiving (saving a card).
- Payment by token (card token can be obtained using scenario 1 or 2).
- Money transfer from card to card using token.
- Payment via Apple Pay.
- Making payments with Touch/Face ID.
- Mass payment of utility bills
Software interface description
1. Get started with the SDK
Before you get started to use the SDK methods, you need to initialize Payment Presenter which accepts a set of parameters:
/// Initializer
public init(delegate: PaymentPresenterDelegate,
styleSource: StyleSource? = nil,
language: PortmoneSDKEcom.PaymentPresenter.Language? = nil,
biometricAuth: Bool = false),
customUid: String? = nil)
Parameters
| Field | Type | Description | Nullability |
|---|---|---|---|
| delegate | PaymentPresenterDelegate | Delegate protocol. Provides information on payment status | required |
| styleSource | StyleSource | Protocol for screen elements customization | optional |
| language | Language | Enum to set the SDK interface language. Possible values: ukrainian, english. If the parameter is not transferred, the language of the client device will be used | required |
| biometricAuth | Bool | Parameter used to activate biometric authorization. Default value: false | optional |
| customUid | String | The ID of the endpoint to which requests will be sent. The need for filling agrees with the Portmone.com manager | optional |
Please contact our Account Managers to activate biometric authorization
E-mail: [email protected]
PaymentPresenterDelegate protocol
/// Protocol for return payment result
@objc public protocol PaymentPresenterDelegate: class {
/// Method triggered as result of payment process.
///
/// - Parameter bill: Bill
/// - Parameter error: Error
func didFinishPayment(bill: Bill?, error: Error?)
/// Method triggered as result of payment bills process.
///
/// - Parameter bills: [UBill]
/// - Parameter error: Error
@objc optional func didFinishPaymentBills(bills: [UBill]?, error: Error?)
/// Optional method.
/// Method triggered when PortmoneSDK had already dismissed.
@objc optional func dismissedSDK()
/// Optional method.
/// Method triggered when the client closed the PortmoneSDK.
@objc optional func canceledSDK()
}
PayeePaymentDelegate methods
| Method | Parameters | Description |
|---|---|---|
| didFinishPayment | PortmoneSDKEcom.Bill? Error? | Called after payment completion. The Bill object is present in case of successful payment. A system error or an Error protocol object may be present when an error occurs |
| didFinishPaymentBills | [PortmoneSDKEcom.UBill]?Error? | Called after bulk payment is completed. In case of success, UBill objects are present, in case of error, there may be a system error or protocol object Error |
| dismissedSDK | Called after closing the payment window | |
| cancelledSDK | Called after the payment window was closed by the user |
StyleSource protocol
/// Title label font (All screens)
func titleFont() -> UIFont
/// Title label color (All screens)
func titleColor() -> UIColor
/// Section header label font (Payment, commission screens)
func headersFont() -> UIFont
/// Section header label color (Payment, commission screens)
func headersColor() -> UIColor
/// Section header view background color (Payment, commission screens)
func headersBackgroundColor() -> UIColor
/// All textFields placeholder font
func placeholdersFont() -> UIFont
/// All textFields placeholder color
func placeholdersColor() -> UIColor
/// All textFields text font
func textsFont() -> UIFont
/// All textFields text color
func textsColor() -> UIColor
/// All error strings text font
func errorsFont() -> UIFont
/// All error strings text color
func errorsColor() -> UIColor
/// All background color (Table, cells, navigation bar)
func backgroundColor() -> UIColor
/// Message label font (Result, 2d verification screens)
func resultMessageFont() -> UIFont
/// Message label color (Result, 2d verification screens)
func resultMessageColor() -> UIColor
/// Save receipt title color (Result screen)
func resultSaveReceiptColor() -> UIColor
/// Informative label on button (Save card screen)
func infoTextsFont() -> UIFont
func infoTextsColor() -> UIColor
/// Buttons back and next title font
func buttonTitleFont() -> UIFont
/// Button bottom title color
func buttonTitleColor() -> UIColor
/// Buttons back and next tint color
func buttonColor() -> UIColor
/// Button corner radius
func buttonCornerRadius() -> CGFloat
/// Biometric button title color
func biometricButtonColor() -> UIColor
/// Image for success result
func successImage() -> UIImage?
/// Image for failure result
func failureImage() -> UIImage?
| Method | Returns the parameters | Description |
|---|---|---|
| titleFont | UIFont | The font of the titles is changed on all screens. The size remains constant |
| titleColor | UIColor | The color of the titles is changed on all screens |
| headersFont | UIFont | The font of all section headers is changed. The size remains constant |
| headersColor | UIColor | The color of all section headers is changed |
| headersBackgroundColor | UIColor | The background color of all section headers is changed |
| placeholdersFont | UIFont | The font of the placeholders on all screens is changed. The size remains constant |
| placeholdersColor | UIColor | The color of the placeholders on all screens is changed |
| textsFont | UIFont | The font of the main texts in the input fields on all screens is changed. The size remains constant |
| textsColor | UIColor | The color of the main text in the input fields on all screens is changed |
| errorsFont | UIFont | The font of errors on all screens is changed. The size remains constant |
| errorsColor | UIColor | The color of errors on all screens is changed. The size remains constant |
| backgroundColor | UIColor | The background color on all screens is changed |
| resultMessageFont | UIFont | The font of the information label on the 2d verification and the payment result screens is changed. The font size remains constant |
| resultMessageColor | UIColor | The color of the information label on the 2d verification and the payment result screens is changed |
| resultSaveReceiptColor | UIColor | The color of the receipt saving button title on the payment result screen is changed |
| infoTextsFont | UIFont | The font of the information text on the card saving screen is changed. The font size remains constant |
| infoTextsColor | UIColor | The color of the information text on the saving card screen is changed |
| buttonTitleFont | UIFont | The font of button titles on all screens is changed. The font size remains constant |
| buttonTitleColor | UIColor | The color of button titles on all screens is changed |
| buttonColor | UIColor | The button background color or color of the button titles on all screens is changed |
| buttonCornerRadius | CGFloat | The button corner radius on all screens is changed |
| biometricButtonColor | UIColor | The color of the biometric button title on the payment by token screen is changed |
| successImage | UIImage? | The successful payment icon is changed |
| failureImage | UIImage? | The failed payment icon is changed |
Example:
private var presenter: PaymentPresenter?
override func viewDidLoad() {
super.viewDidLoad()
presenter = PaymentPresenter(delegate: self,
styleSource: self,
language: .ukrainian,
biometricAuth: true),
customUid: “YOUR_CUSTOM_UID_FROM_PORTMONE”)
}
2. Payment by card
2.1. Initialization of payment by card
To call the payment by card screen use the presentPaymentByCard method with the required parameters.
PaymentPresenter
// Method to present payment by card screen
public func presentPaymentByCard(on controller: UIViewController,
params: PortmoneSDKEcom.PaymentParams,
showReceiptScreen: Bool = true)
presentPaymentByCard method parameters
| Parameter | Type | Description | Nullability |
|---|---|---|---|
| controller | UIViewController | The controller on top of which the payment by card screen is shown | required |
| params | PaymentParams | Object with a set of parameters required for the payment | required |
| showReceiptScreen | Bool | Displaying a screen with the receipt after successful payment. Default value: true (* available for SDK version 1.4.0 and higher) | optional |
PaymentParams object
| Field | Type | Description | Nullability |
|---|---|---|---|
| description | String | Description of payment details | optional |
| attribute1 | String | Payment attribute 1 | optional |
| attribute2 | String | Payment attribute 2 | optional |
| attribute3 | String | Payment attribute 3 | optional |
| attribute4 | String | Payment attribute 4 | optional |
| billNumber | String | Number of paid bill. Maximum length is 120 symbols. Must be unique within a single order. If the order with this number has already been paid, the Portmone.com system will reject the transaction | optional |
| preauthFlag | Bool | Payment pre-authorization mode. The funds are not charged from the account but only blocked. Default value: false | optional |
| billCurrency | Currency | Currency of the payment. Possible values: UAH (default value), USD, EUR, GBP, BYN, KZT | optional |
| billAmount | Double | Amount of the payment. Example: “1.00” | required |
| payeeId | String | A unique identifier (ID) of the payee company | required |
| type | PaymentType | Payment type. It can take one of two values: 1) .payment – standard option; 2) .mobilePayment – the description title is changed to "Phone number" and "+380" is added to the description value itself | optional |
| merchantIdentifier | String | An identifier you register with Apple that uniquely identifies your business as a merchant able to accept payments (Merchant ID) | optional |
| paymentFlowType | PaymentFlowType | An attribute that sets up possible payment scenarios: by card, by card and via Apple Pay, or via Apple Pay only. Possible values: .byCard (default value), .byCardAndApplePay, .byApplePay | optional |
Example:
@IBAction private func payButtonClicked(_ sender: UIButton) {
var billNumb = ""
if billNumber.text?.isEmpty ?? true {
billNumb = "SD\(Int(Date().timeIntervalSince1970))"
} else {
billNumb = billNumber.text ?? ""
}
let flowType = PaymentFlowType(payWithCard: payWithCardSwitch.isOn,
payWithApplePay: payWithAPaySwitch.isOn)
let paymentParams = PaymentParams(description: contractNumber.text ?? "",
attribute1: attribute1.text ?? "",
attribute2: attribute2.text ?? "",
attribute3: attribute3.text ?? "",
attribute4: attribute4.text ?? "",
billNumber: billNumb,
preauthFlag: preauthFlag.isOn,
billCurrency: .uah,
billAmount: Double(billAmount.text ?? "") ?? 0,
details: billDetails.text ?? "",
payeeId: payeeId.text ?? "",
merchantIdentifier: merchantIdTextField.text ?? "",
paymentFlowType: flowType)
presenter?.presentPaymentByCard(on: self, params: initParams)
}

Fig. 1a. Card payment screen (without branding)

Fig. 1b. Card payment screen (without branding)

Fig. 2a. Card payment screen (branding example)

Fig. 2b. Card payment screen (branding example)
2.2. Getting the result of payment by card
After a successful payment, the Bill object will be created containing payment information. The didFinishPayment method of the PaymentPresenterDelegate will be called after successful payment using the Bill object as a parameter. If an error occurs during the payment, the parameter will be a system error or an Error protocol object.
Bill object
| Field | Type | Description | Nullability |
|---|---|---|---|
| billId | String | A unique payment ID | optional |
| status | String | Payment status. Possible values: "PAYED" and "PREAUTH", depending on the type of payment selected at the initialization | required |
| billAmount | double | Amount of the payment | required |
| cardMask | String | The mask of the card used for payment containing the first six and the last four digits of the card number | optional |
| commissionAmount | double | Commission for the payment | required |
| recieptUrl | String | Link to get a pdf receipt | optional |
| contractNumber | String | Personal account number | optional |
| payDate | long | Time of payment in milliseconds | optional |
| payeeName | String | The name of the company to which the payment has been made | optional |
| token | String | Token value for the payment made. In case of payment via Apple Pay, nil will return | optional |
Example:
// self <-- PaymentPresenter
extension PayByCardViewController: PaymentPresenterDelegate {
func didFinishPayment(bill: Bill?, error: Error?) {
// Save used card
UserDefaults.standard.set(bill?.cardMask, forKey: cardMask)
UserDefaults.standard.set(bill?.token, forKey: cardToken)
if error != nil {
self.presentAlert(title: "Error", message: error?.localizedDescription)
}
if bill != nil {
let mask = bill?.cardMask ?? ""
let token = bill?.token ?? ""
self.presentAlert(title: "Payment Success",
message: "Card mask: \n\(mask), \nToken: \n\(token)")
}
}
}
3. Saving a card
The card saving mechanism provides the possibility to get the token value for further payment by this card without entering the payment card number and expiration date. To receive the token 1 UAH is blocked at the client's card account. Unblocking is performed automatically within 30 minutes.
3.1. Initialization of card saving
To call the card saving screen use the presentPreauthCard method with the required parameters.
PaymentPresenter
/// Method to present preauth card screen
public func presentPreauthCard(on controller: UIViewController,
params: PortmoneSDKEcom.PreauthParams)
presentPreauthCard method parameters
| Parameter | Type | Description | Nullability |
|---|---|---|---|
| controller | UIViewController | The controller on top of which the card saving screen is shown | required |
| params | PreauthParams | Object with a set of parameters required for the payment | required |