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 #
- PaySky should provide you by merchant id and Terminal id & Secret ID
- JDK installed on your machine with minimum version 1.7
- Android Studio
- Create new Android project in Android Studio to use SDK or if you have created a Project before with minSdkVersion api version 17
Installing #
- Open your android project
- 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:-
3. in your build.gradle file in app level in dependencies{} add :- 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
using sdk #
In order to use our SDK you should get merchant id and Terminal id from our company.
- create a new instance from PayButton:-PayButton payButton = new PayButton(context);
- 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:-
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:-
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
Deployment #
- Before deploy your project live ,you should get a merchant id and terminal id from our company .
- 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)