Skip to content

OutSystems-owned repository for the Payments plugin's iOS library.

License

Notifications You must be signed in to change notification settings

OutSystems/OSPaymentsLib-iOS

Repository files navigation

OSPaymentsPluginLib-iOS

The OSPaymentsPluginLib-iOS is a library build using Swift that lets you set a payment experience using Apple Pay. It allows to set the payment's details, such as the merchant’s information, payment amount and currency, as well as shipping and billing address. This information can then used to process a payment within an app.

The OSPMTActionDelegate protocol, along with the class that implements it - OSPMTPayments - allows this interaction, providing the following operations:

  • Setup Payment Configuration
  • Check if Device is Ready for Payment
  • Set Details and Trigger Payment

Each is detailed on following sections.

Index

Motivation

This library is to be used by the Payments Plugin. The repository contains a podspec file that is published and available on the CocoaPods' repository, and should be imported on the Cordova bridge as a pod.

Usage

  1. Include the OSPaymentsPluginLib pod in the Cordova Bridge. o accomplish this, the following needs to be inserted into the plugin.xml file. The spec field should be changed to the version the developer desires to use.
<platform>
	...
	<podspec>
        <config>
            <source url="https://cdn.cocoapods.org/"/>
        </config>
        <pods use-frameworks="true">
        	...
            <pod name="OSPaymentsPluginLib" spec="{VERSION TO USE}" />
            ...
        </pods>
    </podspec>
	...
</platform>
  1. Go to Apple Developer Portal and configure the Provisioning Profile with the Apple Pay Payment Processing and In-App Purchase capabilities enabled.

Methods

The library provides the following methods to interact with:

Setup Payment Configuration

func setupConfiguration()

Sets up the payment configuration.

The method's success is returned through a OSPMTCallbackDelegate call. Success operations returns an object of the structure type OSPMTConfigurationModel, encoded in a UTF-8 string. An OSPMTError error is returned in case of error.

Check if Device is Ready for Payment

func checkWalletSetup()

Verifies the device is ready to process a payment, considering the configuration provided before.

The method's success is returned through a OSPMTCallbackDelegate call. Success operations returns an empty string or a OSPMTError error otherwise.

Set Details and Trigger Payment

func set(_ details: String, and: accessToken: String?)

Sets payment details and triggers the request proccess. The method contains the following parameter:

  • details: Payment details model serialized into a text field. This model can be checked in the OSPMTDetailsModel structure.
  • accessToken: Authorisation token related with a full payment type. Can be empty, which should be the case for custom payments.

The method's success is returned through a OSPMTCallbackDelegate call. Success operations returns an object of the structure type OSPMTScopeModel, encoded in a UTF-8 string. An OSPMTError error is returned in case of error.