Integration

To integrate plugin to your app you have to add a dependency for plugin itself and a dependecny for PCSDK.

1. Adding flutter plugin

In order to include a flutter plugin in your app, you are supposed to add the follwoing lines to pubspec.yaml:

yaml dependencies: pcsdk: git: https://repo.payconfirm.org/git/flutter/pcsdk-flutter.git

2. Adding PCSDK

To make the plugin work, you have to embed PCSDK for each platfrom separately.

  1. In iOS project (usually in <your_project>/ios folder) add the new dependency to a Podfile:

    target 'Runner' do
    
        ...
    
        pod 'PCSDKModule', :git => 'https://repo.payconfirm.org/git/ios/pcsdk.git'
    
        ...
    
    end
    
  2. In Android project (<your_project>/android folder) add the follwoing maven repository to a root build.gradle:

    allprojects {
        repositories {
            ...
            maven { url "https://repo.payconfirm.org/android/maven" }
        }
    }
    

    Then, add the dependency with the last PCSDK version into a module-level build.gradle:

        // Dependency in your module-level build.gradle
        implementation 'tech.paycon.sdk.v5:pcsdk:5.4.<LATEST_VERSION>'
    

Initialization

PCSDK must be initialized before using. To inialize PC SDK library you just call PCSDK.initialize() method. Also, you may turn on SDK's logger providing the required log level.

import 'package:pcsdk/pcsdk.dart';
import 'package:pcsdk/models/pcloggingoptions.dart';

...

await PCSDK.setLogLevel(PCLoggingOptions.debug + PCLoggingOptions.sensitive);
await PCSDK.initialize();

User registration

User registration process contains followings steps:

  1. Getting personalization data from the PC Server (via QR, QR + activation code, JSON-value)
  2. Registering PC User on PC Server
  3. Store user's keys in internal storage for futher using

The activation code could be delivered by other channel (SMS, Push Notifications)


import 'package:pcsdk/models/pcuser.dart';
import 'package:pcsdk/pcusersmanager.dart';

String userJSON = ... ; // String with user's data in JSON format

// Importing JSON info
PCUser user = await PCUsersManager.importUser(userJSON);

// Activating the user
if (await user.isActivated() == false) {
    await PCUsersManager.activate(user, activationCode);
}

// Registering
await PCUsersManager.register(user, deviceToken);

// Storing
await PCUsersManager.store(user, userName, passwordToStore);

After successfull registration you can use this user to confirm and decline transactions.


List<PCUser> users = await PCUsersManager.listUsers();
PCUser firstUser = users.first;

Transactions

Online Methods


// Getting the appropriate user.
// We are using the first stored user in this example
PCUser user = await PCUsersManager.listUsers().first;

// Getting the available transactions list for this user
List<String> transactionsIDs = await PCTransactionsManager.getTransactionsList(user);

// Getting transactions's data
// We are using the first transaction in the list in this example
PCTransaction transaction = await PCTransactionsManager.getTransaction(transactionsIDs.first, user);

// Transaction may contain the binary data
// It is necessary to download it before confirming or declining
if (transaction.hasBinaryData) {
    String? binaryDataURL = await transaction.getBinaryDataUrl();
    if (binaryDataURL == null) {
        await PCTransactionsManager.getTransactionBinaryData(transaction, user);
    }
}

// Providing password before processing
bool isReadyToSign = await user.isReadyToSign();
if (!isReadyToSign) {
     await PCUsersManager.submit(user, password);
}

// Confirming transaction
await PCTransactionsManager.sign([transaction], user);

// ... or declining transaction
await PCTransactionsManager.decline([transaction], user);

Offline Methods


// Getting the appropriate user.
// We are using the first stored user in this example
PCUser user = await PCUsersManager.listUsers().first;

String transactionJSON = ... ; // String with transaction's data in JSON format

// Importing a transaction from JSON
PCTransaction transaction = await PCTransactionsManager.importTransaction(transactionJSON);

// Providing password before processing
bool isReadyToSign = await user.isReadyToSign();
if (!isReadyToSign) {
     await PCUsersManager.submit(user, password);
}

// Confirming transaction
PCConfirmation confirmation = await PCTransactionsManager.signOffline(transaction, user);
// PCConfirmation contains a confirmationCode to complete confirmation process on the server

// ... or declining transaction
PCDeclination declination = await PCTransactionsManager.declineOffline(transaction, user);
// PCDeclination contains a declineCode to complete decline process on the server

Changelog

1.0.1

  • Supporting of offline transactions

1.0.0

  • Initial release with common functional