Java Library

Paga-connect Java Library is a Java module that helps you make API calls when processing Paga Transactions.

1. Create Paga Business Account

You need to create a Paga business account

2. Installation

Download the jar to your project.

If you are using build file such as Maven or Gradle, follow the process below,

Step 1. add the downloaded jar to .m2 directory

  • path .m2/repository/com/paga/connect/paga-connect/1.0

Step 2. Add the dependency to your pom.xml or build.gradle file.

Maven

Go to your pom file and add the following to your pom.xml

Then add the Paga Connect dependency under your dependencies

<dependencies>
    <dependency>
            <groupId>com.paga.connect</groupId>
            <artifactId>paga-connect</artifactId>
            <version>1.0</version>
        </dependency>
</dependencies>

Gradle

Add the Paga Connect dependency under your dependencies

compile 'com.paga.connect:paga-connect:1.0'

Also include mavenLocal( ) under your repositories

repositories {
    mavenCentral()
    mavenLocal()
}

3. Usage

To use PagaConnectRestClient, you would need to import it

import <packageName>.PagaConnectRestClient;

To Initialize the class, you use a builder to set all required values

PagaConnectClient pagaConnectClient = new PagaConnectClient.Builder()
                .setClientId("<Paga-Client-ID>")
                .setPassword("<Paga-Secret-Key>")
                .setRedirectUri(""<Your-Redirect-URL>")
                .setScopes(new String[]{"USER_DEPOSIT_FROM_CARD+MERCHANT_PAYMENT+USER_DETAILS_REQUEST"})
                .setUserData(new String[]{"FIRST_NAME+LAST_NAME+USERNAME+EMAIL+ACCOUNT_BALANCE"})
                .setTest(true)
                .build();

As shown above, you set the client id and secret given to you by Paga, then set your Redirect URL, scope and User data are arrays of strings and are required to inform Paga-connect which data and operations you would need and initiate for the user.

4. Paga Connect Functions

Authorisation Code

To obtain your authorisation code, click here

Access Token

Map<String,String>accessToken = pagaConnectClient
                               .getAccessToken(GetAccessTokenRequest.builder()
                               .authorizationCode("code")
                               .build());

Make Payments

This is the operation executed to make a payment to you on behalf of the customer. To make use of this function, call the getAccessToken inside the ConnectClient which will return a response with the access token which will be used to complete payment.

To get Access tokens, Use the authorization code gotten from the call to the backend :

MerchantPaymentResponse response =  pagaConnectClient
                               .merchantPayment(MerchantPayment.builder()
                               .accessToken("")
                               .amount(1000)
                               .currency("NGN")
                               .productCode("12322")
                               .transactionId("356727282")
                               .userId(12355)
                               .build());

Money Transfer

This operation allows you to credit a user's paga account. To make use of this function, call the moneyTransfer inside the ConnectClient which will return a MoneyTransferResponse.

Access Token is used in making money transfer like this:

MoneyTransferResponse response =  pagaConnectClient
                                 .moneyTransfer(MoneyTransferRequest.builder()
                                 .accessToken("56366")
                                 .amount(1000)
                                 .recipientCredential("08060075922")
                                 .referenceNumber("4356227273")
                                 .skipMessaging(true)
                                 .build());

User Details

This Operation allows the client to get the user's personal details. The data requested is included in the authentication and authorization request in the data parameter. Additionally, the scope parameter must contain the USER_DETAILS_REQUEST option. To make use of this function, call the getUserDetails inside the ConnectClient which will return a UserDetailResponse with user details.

Map<String, String> accessToken =  pagaConnectRestClient.getAccessToken(authorization_code);

Access Token is used in getting user details like this:

UserDetailResponse response = pagaConnectClient
                             .getUserDetails(GetUserDetailsRequest.builder()
                             .accessToken("56373773")
                             .referenceNumber("673892202")
                             .build());

What’s Next