search

POS SDK Method Details

 

Following are the available APIs with requests and response params. To access the respective params, click on + button.

Sale API

 

Usecase

 

Start a new Sale transaction on the connected EDC device. If the EDC device is not connected a Timeout error will be thrown. If the request parameters are valid and the device is not busy with another transaction then a SALE transaction will be initiated on the device.

 


/**
 * @param request      	Sale Request

 * @param responseListener A listener which will listen for the response

 * @see Config#isStatusCheckOnSaleRequestEnabled()

 * @see Config#getStatusCheckStartSeconds()

 * @see Config#getStatusCheckIntervalSeconds()

 * @see Config#getSaleRequestTimeoutSeconds()

 * If the statusCheckOnSaleRequestEnabled flag is true then the sdk will keep checking the

 * status of the SALE transaction at regular interval(statusCheckIntervalSeconds) after initial

 * delay of statusCheckStartSeconds and till saleRequestTimeoutSeconds. And in this case the

 * response returned will be of the type

 * {@link com.paytm.ecr.bluetooth.sdk.model.response.StatusCheckResponse}

 * <p>

 * If the statusCheckOnSaleRequestEnabled is false, then sdk will immediately return

 * the response of the type {@link com.paytm.ecr.bluetooth.sdk.model.response.SaleResponse} ,

 * this response will only give information whether the SALE transaction was initiated on the

 * device or not. And in this case the calling app needs to call the

 * @see #doStatusCheck(Request, ResponseListener) API to know the final status of the SALE

 * transaction on the device

 * <p>

 * If the device does not initiate the SALE transaction due to any reason, then the response

 * of the type {@link com.paytm.ecr.bluetooth.sdk.model.response.SaleResponse} will immediately

 * be returned to the calling App

 * @see SaleRequest

 * @see com.paytm.ecr.bluetooth.sdk.model.response.SaleResponse

 * @see com.paytm.ecr.bluetooth.sdk.model.response.StatusCheckResponse

 */

@Keep

void doSale(@NonNull Request<SaleRequest> request, @NonNull ResponseListener responseListener);


*****************************************************************************************

 

 

  1. Request Params-

     

    Serial No. Name Type Required Description
    1 merchantId String Conditional Paytm MID
    2 orderId String Mandatory Order Id of the transaction, which is unique for every new SALE order
    3 paymentMode String Mandatory PayMode (‘ALL’, ‘CARD’ or ‘QR’)
    4 cardReadMode String Optional CardReadMode (‘ALL’, ‘SWIPE’, ‘TAP’ or ‘INSERT’)
    5 amount String Mandatory Amount in Paise for the SALE transaction (Example: for Rs 1 transaction, the amount will be : 100)
    6 subWalletInfo String Optional Sub wallet param, so that user can pay through different sub-wallets associated with his / her Paytm account. Format: “FOOD:2000|GIFT:1000”. Here, the amount will be in Paise. 
    7 extendInfo String Optional Any number of extra key-value pair that needs to be passed in the SALE request from the EDC device to the Paytm server can be passed in {android.net.Uri} URI format in this parameter.
    Example:- "extendInfo"= "extendInfo://values?productValidationValue=12764874894894898&merchantTxnId=82938938983&caNumber=34567777"
    8 printInfo String Optional Any number of extra key-value pair that needs to be printed in the generated SALE receipt. Example: "printInfo"= "printInfo://values?merchantTxnId=82938938983&caNumber=34567777&billNumber=xyz123"
    9 gstInformation String Optional

    gstInformation parameter can be used by merchants to pass gst Info in SALE request. Here, the merchants need to pass all gst Info params(gstIn, gstBrkUp, invoiceNo, invoiceDate) as given below:

    The format of gstBrkUp should be as in the example and invoiceDate should be in yyyyMMddHHmmss format.
    Example :- "gstInformation" = "gstInformation://values?gstIn=08TESTF0078P1ZP&gstBrkUp=CGST:10|SGST:10|IGST:10|CESS:10|GSTIncentive:10|GSTPCT:10&invoiceNo=Invoice34234321&invoiceDate=20210512142919

    10 tipAmount String Optional Tip Amount in paise for the SALE transaction. Tip Amount should not be more than the maximum allowed amount for the Merchant.
    11 totalAmount String Optional Total Amount in paise for the SALE transaction. Total Amount is required if the SALE has tipAmount in its request. Sum of tipAmount and the amount in the request should be equal to totalAmount.

     

  2. Response Params+

Status Check API

 

Usecase

 

Check the status of a particular transaction on the Paytm POS machine. 

 

 Note- The Paytm POS machine stores only the transactions done on the current day, the status of older transactions cannot be checked through this API.

 

/**

 * @param request      	Status check request

 * @param responseListener A listener which will listen for the response

 * @see StatusCheckRequest

 * @see com.paytm.ecr.bluetooth.sdk.model.response.StatusCheckResponse

 */

@Keep

void doStatusCheck(@NonNull Request<StatusCheckRequest> request, @NonNull ResponseListener responseListener);


*****************************************************************************************

 

  1. Request Params-

     

    Serial No. Name Type Required Description
    1 merchantId String Mandatory Paytm MID
    2 orderId String Mandatory Order Id of the transaction

     

  2. Response Params+

Cancel API

 

Usecase

 

Cancels the currently ongoing SALE or VOID transaction initiated by the Merchant Billing System on the Paytm POS machine

 

/**

 * @param request      	Cancel request

 * @param responseListener A listener which will listen for the response

 * @see CancelRequest

 * @see com.paytm.ecr.bluetooth.sdk.model.response.CancelResponse

 */

@Keep

void doCancel(@NonNull Request<CancelRequest> request, @NonNull ResponseListener responseListener);


*****************************************************************************************

 

  1. Request Params-

     

    Serial No. Name Type Required Description
    1 merchantId String Mandatory Paytm MID
    2 orderId String Mandatory Order Id of the transaction

     

  2. Response Params+

Print API

 

Usecase

 

Generate receipt for a SALE / VOID transaction through the Paytm POS machine

 

 Note: The Paytm POS machines store the transactions done on the current day, therefore receipt of older transactions could not be printed through this API

 

/**
 *

 * @param request      	Print request

 * @param responseListener A listener which will listen for the response

 * @see PrintRequest

 * @see com.paytm.ecr.bluetooth.sdk.model.response.PrintResponse

 */

@Keep

void doPrint(@NonNull Request<PrintRequest> request, @NonNull ResponseListener responseListener);

*****************************************************************************************

 

  1. Request Params-

     

    Serial No. Name Type Required Description
    1 merchantId String Mandatory Paytm MID
    2 orderId String Mandatory Order Id of the transaction

     

  2. Response Params+

Void API

 

Usecase

 

Initiate VOID for a successful SALE transaction.

 

 Note: The Paytm POS machines store only the transactions done on the current day, therefore VOID of older transactions could not be initiated through this API

 

/**

 * @param request      	Void request

 * @param responseListener A listener which will listen for the response

 * @see VoidRequest

 * @see com.paytm.ecr.bluetooth.sdk.model.response.VoidResponse

 */

@Keep

void doVoid(@NonNull Request<VoidRequest> request, @NonNull ResponseListener responseListener);

*****************************************************************************************

 

  1. Request Params-

     

    Serial No. Name Type Required Description
    1 merchantId String Mandatory Paytm MID
    2 orderId String Mandatory Order Id of the transaction

     

  2. Response Params+

Connection Check API

 

Usecase

 

Check if the Merchant Billing System and Paytm POS machine are ready to communicate over Bluetooth. If this method returns timeout or any other error, then it may mean that the Merchant Billing System is connected to any other Bluetooth device and not the Paytm POS machine. 

 

/**

 * @param request      	Connection Check request

 * @param responseListener A listener which will listen for the response

 * @see ConnectionCheckRequest

 * @see com.paytm.ecr.bluetooth.sdk.model.response.ConnectionCheckResponse

 */

@Keep

void doConnectionCheck(@NonNull Request<ConnectionCheckRequest> request, @NonNull ResponseListener responseListener);

*****************************************************************************************

 

  1. Response Params-

     

    Serial No. Name Type Description
    1 statusCode String Status code returned by the device
    2 statusMessage String Status message returned by the device

Sample code

 

Merchant needs to add the below code of Constant and LifeCycleTracker on their application server.

 

package com.paytm.ecr.bluetooth.sample;

public interface Constants {
    String TXN_TYPE = "txn_type";
    String SALE = "sale";
    String CANCEL = "cancel";
    String STATUS_CHECK = "status_check";
    String CONNECTION_CHECK = "connection_check";
    String VOID = "void";
    String PRINT = "print";
}

 

package com.paytm.ecr.bluetooth.sample;

import android.app.Activity;
import android.app.Application;
import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

/**
 * This Class can be used for managing connection lifecycle aware.
 * This enables the application to open and close connection,
 * as the application comes to foreground and goes in background respectively
 *
 * @see SampleApp
 * @see com.paytm.ecr.bluetooth.sample.ui.BaseActivity
 */
public class LifeCycleTracker implements Application.ActivityLifecycleCallbacks {

    private int activityCount = 0;

    private boolean appStopped = true;

    private LifeCycleListener lifeCycleListener = null;


    @Override
    public void onActivityCreated(@NonNull Activity activity, @Nullable Bundle savedInstanceState) {

    }

    @Override
    public void onActivityStarted(@NonNull Activity activity) {
        activityCount += 1;
        if (activityCount == 1) {
            if (appStopped) {
                if (lifeCycleListener != null) {
                    lifeCycleListener.comingToForeGround(true);
                }
                appStopped = false;
            } else {
                if (lifeCycleListener != null) {
                    lifeCycleListener.comingToForeGround(false);
                }
            }
        }
    }

    @Override
    public void onActivityResumed(@NonNull Activity activity) {

    }

    @Override
    public void onActivityPaused(@NonNull Activity activity) {

    }

    @Override
    public void onActivityStopped(@NonNull Activity activity) {
        activityCount -= 1;
        if (activityCount == 0) {
            appStopped = activity.isFinishing();
            if (lifeCycleListener != null) {
                lifeCycleListener.goingToBackground(appStopped);
            }
        }
    }

    @Override
    public void onActivitySaveInstanceState(@NonNull Activity activity, @NonNull Bundle outState) {

    }

    @Override
    public void onActivityDestroyed(@NonNull Activity activity) {

    }

    public boolean isAppInForeground() {
        return activityCount > 0;
    }

    public void setLifeCycleListener(LifeCycleListener lifeCycleListener) {
        this.lifeCycleListener = lifeCycleListener;
    }

    public interface LifeCycleListener {

        void goingToBackground(boolean isAppFinishing);

        void comingToForeGround(boolean isAppStarting);
    }
}