Documentation - Android webteh modul

Versions

  • Version 1.8.1
    • Added add payment method with cancel transaction functionality (void after authorization)
    • Refactored existing code
    • Added add payment method example
  • Version 1.8.0.rc1
    • Added list payment methods
    • Added update payment method
    • Added delete payment method
    • Updated examples with multi merchant setup
  • Version 1.8.0.beta
    • Added Merchant class
    • Added OrderDetails class
    • Added PayCvvOrderDetails class
    • Extended AddCardModel with new constructor(Merchant, OrderDetails, Consumer)
      • Added user_id flag, used to save card
    • Updated usage example
  • Version 1.7.0
    • Added support for Customer data
    • Updated examples with Customer initialization
  • Version 1.7.0.rc.0
    • Added extensive logging
    • Added void logTransactionInfo(String loggingInfo) method on TransactionLifecycleDelegate
    • Migration guideline
      • Due to breaking api change new method must be implemented in order to compile successfully
  • Version 1.5.2.rc
    • Reduced visibility scope for RxErrorCallAdapterFactory from public to package local
    • Fixed RxErrorCallAdapterFactory error parsing
    • Fixed compile error in PgwModule
  • Version 1.5.2.beta
    • Added BusinessError
      • Business errors are now parsed into BusinessError instance with extra fields
        • transactionId
        • maskedPan
        • fullName
        • cardType
        • pmAlias
    • Error handling now creates BusinessError instance if possible
      • Error contains transaction_id, full_name, card_type, masked_pan, and library_error = false - BusinessError will be created
      • ApiError instance will be created
  • Version 1.5.1
    • Updated ApiErrors
    • Added BusinessErrors
  • Version 1.5.0
    • Updated library api handling in RxErrorHandlingCallAdaperFactory
    • Updated transaction failure handling
    • Added ApiError - all errors generated from lib/api will be ApiError instance
    • Added ApiErrors - contains all errors generated by library or proxy except business errors
    • Deprecated TransactionError
    • Deprecated TransactionErrorDetailed
    • Removed transactionFailure method from TransactionLifecycleAdapter
    • TransactionLifecycleDelegate refactored
      • removed void handleTransactionError(TransactionErrorDetailed)
      • type migration void handleTransactionError(Throwable -> ApiError)
      • removed void checkOrderIdFailure(Throwable)

Description

Module encapsulates basic functionality for payment system.

Installation


Add following in your application

  • settings.gradle add include ':app', ':pay'
  • build.gradle add compile project(':pay')

Usage & requirements


Overall functionality is shown in flow charts:

Pay module functionality is provided in two classes:

  • WebtehWebView class
  • PgwModule & PgwApi class

To use WebtehWebView add-card and pay-cvv developer must provide auth_token issued to merchant. Same case is for PgwModule.

Auth token is used to authenticate merchant and to decide which payment gateway endpoint will be used (test or production).

Note: if you do not have auth token please contact jasmin@trifolix.com to receive one.

WebtehWebView


Functionality

Include WebtehWebView in your layout or create dynamically in java code.

Usage example: code

  • Find in layour or create new instance in java code
    WebtehWebView webtehWebView = (WebtehWebView) findViewById(R.id.webView);
  • Instantiate PgwModule - PgwModule pgwModule = new PgwModule("auth_token", BuildConfig.DEBUG)
  • Create new order number - final String orderNumber = String.valueOf(System.currentTimeMillis()); or use your own business logic
  • Implement and instantiate TransactionLifecycleDelegate - final TransactionLifecycleDelegate transactionLifecycleDelegate = new TransactionLifecycleDelegateImpl();
  • Pick ResponseType - final TransactionLifecycleAdapter.ResponseType responseType = TransactionLifecycleAdapter.ResponseType.TransactionSuccess;
  • Instantiate TransactionLifecycleAdapter - final TransactionLifecycleAdapter transactionLifecycleAdapter = new TransactionLifecycleAdapter(orderNumber, pgwModule.getApi(), "client_secret", responseType, transactionLifecycleDelegate);
  • Initialize WebtehWebView - webtehWebView.initialize(transactionLifecycleAdapter, BuildConfig.DEBUG, 10000);
  • Invoke addCard or
    AddCardModel cardModel = new AddCardModelBuilder()
      .setAmount("1250")
      .setMerchantId("007007007007")
      .setAuthToken("00001111222233330000111122223333")
      .setCurrency(AddCardModel.Currency.EUR.toString())
      .setOrderInfo("order ifno")
      .setOrderNumber(String.valueOf(System.currentTimeMillis()))
      .setSign("signature")
      .setClientSecret("MegaSecretKey")
      .setClient("android")
      .createAddCardModel();
    //invoke addCard
    webtehWebView.addCard(cardModel);
  • invoke payCvv
    
    PayCvvModel payCvvModel = new PayCvvModelBuilder()
      .setAmount("1250")
      .setMerchantId("007007007007")
      .setAuthToken("00001111222233330000111122223333")
      .setCurrency(AddCardModel.Currency.EUR.toString())
      .setOrderInfo("order ifno")
      .setOrderNumber(String.valueOf(System.currentTimeMillis()))
      .setSign("signature")
      .setClientSecret("MegaSecretKey")
      .setPmAlias("xeNZhOQfRjtwOxLvRJK0EhJ4UogzSBR9kWMnep8c")
      .setClient("cvv_android")
      .createPayCvvModel();
    //invoke payCvv
    webtehWebView.payCvv(payCvvModel);
    
    

Models

-AddCard jsonschema
Proxy uses json schemas to validate input received on endpoints. For example this schema is used to validate on /add-card endpoint.
-PayCvv json schema
Proxy uses json schemas to validate input received on endpoints. For example this schema is used to validate on /pay-cvv endpoint.
-TransactionError
Model sent to TransactionLifecycle#transactionFailure(TransactionError error)
-TransactionSuccess
-TransactionErrorDetailed

PgwModule & PgwApi


Usage example - checkOrderId use checkOrder

    
PgwModule pgwModule = new PgwModule(BuildConfig.PGW_AUTH_KEY, BuildConfig.DEBUG);
final PgwApi api = pgwModule.getApi();
String orderNumber = "1482240015006";
String digest = "16ef726f3111de11ee8e4e47431bebad58e0ce14"; // sha1(merchant_key + orderNumber)
//Merchant key is provided on ipg merchant dashboard

api.checkOrderId(orderNumber, digest)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Action1&ltShowOrderResponse&gt() {
@Override
public void call(ShowOrderResponse showOrderResponse) {
Log.d(TAG + "checkOrderId", "call: " + showOrderResponse);
}
}, new Action1&ltThrowable&gt() {
@Override
public void call(Throwable throwable) {
Log.d(TAG + "checkOrderId", "call: " + throwable.getMessage(), throwable);
}
});


Usage example - checkOrder

NOTE - checkOrder will only work with new transactions (transactions after api update)

    
PgwModule pgwModule = new PgwModule(BuildConfig.PGW_AUTH_KEY, BuildConfig.DEBUG);
final PgwApi api = pgwModule.getApi();
String orderNumber = "1484635152";
String digest = "a67249a8f0de783a06c76c83bdb5e9fec7f20f9a"; // sha1(merchant_key + orderNumber)
//Merchant key is provided on ipg merchant dashboard

api.checkOrder(orderNumber, digest)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Action1&ltTransactionSuccess&gt() {
@Override
public void call(TransactionSuccess transactionSuccess) {
Log.d(TAG + "checkOrder", "call: " + transactionSuccess);
}
}, new Action1&ltThrowable&gt() {
@Override
public void call(Throwable throwable) {
Log.d(TAG + "checkOrderError", "call: " + throwable.getMessage(), throwable);
}
});


Usage example - checkTransaction

    
PgwModule pgwModule = new PgwModule(BuildConfig.PGW_AUTH_KEY, BuildConfig.DEBUG);
final PgwApi api = pgwModule.getApi();
int transactionId = 80547;

api.checkTransaction(transactionId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Action1&ltTransaction&gt() {
@Override
public void call(Transaction transaction) {
Log.d(TAG + "checkTransaction", "call: " + transaction);
}
}, new Action1&ltThrowable&gt() {
@Override
public void call(Throwable throwable) {
Log.d(TAG + "checkTransactionError", "call: " + throwable.getMessage(), throwable);
}
});


Usage example - getError

    
PgwModule pgwModule = new PgwModule(BuildConfig.PGW_AUTH_KEY, BuildConfig.DEBUG);
final PgwApi api = pgwModule.getApi();
int errorId = 19;

api.getError(errorId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Action1&ltTransactionErrorDetailed&gt() {
@Override
public void call(TransactionErrorDetailed transactionErrorDetailed) {
Log.d(TAG + "getError", "call: " + transactionErrorDetailed);
}
}, new Action1&ltThrowable&gt() {
@Override
public void call(Throwable throwable) {
Log.e(TAG + "getError", "call: " + throwable.getMessage(), throwable);
}
});