PCSDKModule Documentation Beta

Class PCTransactions​Manager

public class PCTransactionsManager

Creates and manages PCTransaction objects

Methods

import​Transaction(from:​)

public static func importTransaction(from string: String) throws -> PCTransaction

Makes the new PCTransaction object from the string

Parameters

string String

The source string which contains the transaction's data

Returns

The new PCTransaction object or nil if the source is invalid

get​Transaction​List(for:​target​Queue:​completion:​)

public static func getTransactionList(for user: PCUser, targetQueue: DispatchQueue = .main, completion: @escaping (_ result: Result<[String], Error>) -> Void)

Fetches all transactions identifiers for the provided user from the server

Parameters

user PCUser

The user which transactions should be fetched for

target​Queue Dispatch​Queue

The queue where a completion will be invoked on

completion @escaping (_ result:​ Result<[String], Error>) -> Void

A closure to be invoked after finishing the fetching process

result

Transactions identifiers or error

get​Transaction(for:​user:​target​Queue:​completion:​)

public static func getTransaction(for transactionID: String, user: PCUser, targetQueue: DispatchQueue = .main, completion: @escaping (_ result: Result<PCTransaction, Error>) -> Void)

Fetches the transaction's data for the provided transactionID from the server.

The downloaded transaction may have a binary data. You can check availability of a binary data using transaction.hasBinaryData property.

If transaction has binary data it must be downloaded before signing or declining. Otherwise, the method PCTransactionManager.sign or .decline will return an error (PCError.binaryDataIsRequired).

Parameters

transaction​ID String

Transaction's identifier which data sould be fetched for

user PCUser

User which transaction's data should be fetched for

target​Queue Dispatch​Queue

The queue where a completion will be invoked on

completion @escaping (_ result:​ Result<PCTransaction, Error>) -> Void

Closure to be invoked after finishing the fetching process

result

Returns PCTransaction or error

get​Transaction​Binary​Data(for:​user:​target​Queue:​completion:​)

public static func getTransactionBinaryData(for transaction: PCTransaction, user: PCUser, targetQueue: DispatchQueue = .main, completion: @escaping (_ result: Result<PCTransaction, Error>) -> Void)

Gets the transaction's binary data from the server

Check transaction.hasBinaryData parameter before using this method

Parameters

transaction PCTransaction

The transaction the binary data got for

user PCUser

User which transaction's binary data should be got for

target​Queue Dispatch​Queue

The queue where a completion will be invoked on

completion @escaping (_ result:​ Result<PCTransaction, Error>) -> Void

Closure to be invoked after finishing the process

result

Returns the new instance of PCTransaction with filled binary data or error

sign(transaction:​by:​parameters:​target​Queue:​completion:​)

public static func sign(transaction: PCTransaction, by user: PCUser, parameters: PCParameters? = nil, targetQueue: DispatchQueue = .main, completion: @escaping (_ result: Result<Void, Error>) -> Void)

Confirms the provided transaction and attaches scoring parameters to the request

if transaction.hasBinaryData is true be sure that you downloaded the binary data for this transaction before signing. Otherwise, this method will return an error (PCError.binaryDataIsRequired).

Parameters

transaction PCTransaction

The transaction to be signed

user PCUser

The user to sign

parameters PCParameters?

An additional parameters, e.g. scoring settings

target​Queue Dispatch​Queue

The queue where a completion will be invoked on

completion @escaping (_ result:​ Result<Void, Error>) -> Void

A closure to be invoked after finishing the signing process

result

Returns nothing when success. Otherwise, returns error

decline(transaction:​by:​target​Queue:​completion:​)

public static func decline(transaction: PCTransaction, by user: PCUser, targetQueue: DispatchQueue = .main, completion: @escaping (_ result: Result<Void, Error>) -> Void)

Declines the provided transaction

if transaction.hasBinaryData is true be sure that you downloaded the binary data for this transaction before declining. Otherwise, this method will return an error (PCError.binaryDataIsRequired).

Parameters

transaction PCTransaction

Transaction to be declined

user PCUser

The user to decline

target​Queue Dispatch​Queue

The queue where a completion will be invoked on

completion @escaping (_ result:​ Result<Void, Error>) -> Void

Closure to be invoked after finishing the declining process

result

Returns nothing when success. Otherwise, returns error

sign​Offline(transaction:​by:​)

public static func signOffline(transaction: PCTransaction, by user: PCUser) throws -> PCConfirmation

Makes PCConfirmation object for signing in offline mode

Parameters

transaction PCTransaction

Transaction to be signed

user PCUser

User whose transaction should be singed by

Returns

PCConfirmation object which contains the signing data

decline​Offline(transaction:​by:​)

public static func declineOffline(transaction: PCTransaction, by user: PCUser) throws -> PCDeclination

Makes PCDeclination object for declining in offline mode

Parameters

transaction PCTransaction

Transaction to be declined

user PCUser

User whose transaction should be declined by

Returns

PCDeclination object which contains the declining data