PAYSKY PAYBUTTON SDK ANDROID GUIDE

PaySky Button SDK – android #

Purpose of Document #

The purpose of this SDK to help programmers to use PaySky payment SDK for android.

Getting Started #

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes

Prerequisites #

  1. PaySky should provide you by merchant id and Terminal id & Secret ID
  2. JDK installed on your machine with minimum version 1.7
  3. Android Studio
  4. Create new Android project in Android Studio to use SDK or if you have created a Project before with minSdkVersion api version 17

Installing #

  1. Open your android project
  2. In your project in build.gradle file in project level in allproject{} inside it you will find repositories{} inside it add : maven { url ‘https://jitpack.io’ }

Example:-

allprojects { repositories {
maven { url ‘https://jitpack.io’ }
}
}

3. in your build.gradle file in app level in dependencies{} add :- implementation’com.github.payskyCompany:paybutton-sdk:2.0.4′

dependencies {
implementation ‘com.github.payskyCompany:paybutton-sdk: 2.0.4’
}

4. Sync your project.

Note:- version 2.0.4 may not be the last version check Releases tab in sdk github repository to get latest version

Sdk Path:- https://github.com/payskyCompany/paybutton-sdk

using sdk #

In order to use our SDK you should get merchant id and Terminal id from our company.

  1. create a new instance from PayButton:-PayButton payButton = new PayButton(context);
  2. you need to just pass some parameters to PayButton class instance :-
  • Testing type
  • Merchant id
  • Terminal id
  • Payment amount
  • Currency code [Optional]
  • Merchant secure hash.
  • Transaction Reference Number.

Note That:-

  • You should keep your secure hash and merchant id and terminal id with encryption before save them in storage if you want.
  • You need to set “PRODUCTION_Status” // set it PRODUCTION or TESTING_GREY or UPG_STAGGING or UPG_PRODUCTION
  • If merchant id, terminal id, merchant secure hash, or transaction reference number is null or amount is 0 and you called createTransaction method, SDK will throw an IllegalArgumentException.

Example:-

payButton.setMerchantId(merchantId); // Merchant id
payButton.setTerminalId(terminalId); // Terminal id
payButton.setPayAmount(amount); // Amount
payButton.setPRODUCTION_Status(PRODUCTION);
// set it PRODUCTION or TESTING_GREY or UPG_STAGGING or UPG_PRODUCTION
payButton.setCurrencyCode(currencyCode); // Currency Code [Optional]
payButton.setMerchantSecureHash(“Merchant secure hash”); // Merchant secure hash
payButton.setTransactionReferenceNumber(“reference number”); // unique transaction
reference number.
// you can get reference number from AppUtils.generateRandomNumber();

Example:-

payButton.setTransactionReferenceNumber(AppUtils.generateRandomNumber());

3. Before call createTransaction method you should pass all required data if you missing
merchantId , termialId , merchantSecureHash , terminalReferenceNumber , amount .
method will throw IllegalArgumentException.

4. In order to create transaction call:-

payButton.createTransaction(new PayButton.PaymentTransactionCallback() {

@Override

public void onCardTransactionSuccess(SuccessfulCardTransaction

cardTransaction) {

paymentStatusTextView.setText(cardTransaction.toString());

}

@Override

public void

onWalletTransactionSuccess(SuccessfulWalletTransaction walletTransaction) {

paymentStatusTextView.setText(walletTransaction.toString());

}

@Override

public void onError(Throwable error) {

paymentStatusTextView.setText(“failed by:- ” +

error.getMessage());

}

});

Creating transaction #

To create transaction in our sdk you just call createTransaction method and pass to it PaymentTransactionCallback listener to call it after transaction, this listener has 2 methods:-

On Card Transaction Success Method #

This method called in case transaction success by card payment with Successful Card Transaction object.

Successful Card Transaction object from create transaction listener contains:-

  • Network Reference variable that is reference number of transaction.
  • AuthCode variable
  • ActionCode variable.
  • ReceiptNumber variable.
  • Amount variable.
On Wallet Transaction Success Method #

This method will be called if customer make a wallet transaction with Successful Wallet Transaction object.

Successful Wallet Transaction object from create transaction listener contains:-

  • Network Reference variable that is reference number of transaction.
  • Amount variable.
On Error #

on Error method in case transaction failed with Throwable exception that has error info.

Example:-

payButton.createTransaction(new PayButton.PaymentTransactionCallback() {
@Override
public void onCardTransactionSuccess(SuccessfulCardTransaction
cardTransaction) {
paymentStatusTextView.setText(cardTransaction.toString());
cardTransaction.NetworkReference; // transaction reference number.
}
@Override
public void
onWalletTransactionSuccess(SuccessfulWalletTransaction walletTransaction) {
paymentStatusTextView.setText(walletTransaction.toString());
walletTransaction.NetworkReference ; // transaction reference number.
}
@Override
public void onError(Throwable error) {
paymentStatusTextView.setText(“failed by:- ” +
error.getMessage());
}
});
}
});

Resolving Conflicts #

Because we use some of libraries like Ok http, retrofit , Event Bus and you may use them with different version number , in some cases this will make a conflict in build project to solve this problem you should force the library that has conflict with specific version number.

Example conflict in Gson library we use version

implementation ‘com.google.code.gson:gson:2.8.5’
and in your build.gradle file
implementation ‘com.google.code.gson:gson:2.8.4’
in your build.gradle file add in bottom of it:-
configurations.all {
resolutionStrategy {
force ‘com.google.code.gson:gson:2.8.4’
}
}
force your specific version and sync project again.

Deployment #
  1. Before deploy your project live ,you should get a merchant id and terminal id from our company .
  2. you should keep your merchant id and terminal id secured in your project, encrypt them before save them in project.
Bulk with #
  • Retrofit – Android Networking library.
  • Event Bus – Event bus send events between your classes.
Authors #

PaySky Company – (https://www.paysky.io)

Powered by BetterDocs

Menu