Payment

The Payment API allows merchants to accept contactless credit and debit card payments via compatible NFC-enabled devices.

📘

API Method

SoftPOS SDK API Interface

🚧

References

SDK Payment Classes
SDK Payment Enums


1. Generate Payment Token

To prepare a payment token request, refer to the required parameters below.

📘

Payment Token API

Refer to: Payment Token API

{
    "merchantID": "JT04",
    "invoiceNo": "1595219400",
    "description": "2 days 1 night hotel room",
    "amount": 10.0,
    "currencyCode": "THB",
    "nonceStr": "a8092512-b144-41b0-8284-568bb5e9264c",
    "paymentChannel": ["ALL"]
}

2. Receive Payment Token Response

To receive a payment token response, refer to the sample payment token response below. The response will contain the payment token ID which must be passed to the merchant application.

String paymentToken = "roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL";
val paymentToken = "roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL"

3. Prepare Payment Request

To prepare a payment request, refer to the parameters below.

📘

Request API Parameters

Refer to: Payment Request API Parameters

String profileId = "prof_01XXXXXXXXXXX1";

PaymentRequest paymentRequest = new PaymentBuilder(getActivity(), paymentToken)
                                .profileId(profileId)
                                .posType(SoftPOSType.Terminal)
                                .build();
val profileId = "prof_01JQB8Y9EMCRBG27NWXXXCRNA1"

val paymentRequest = PaymentBuilder(activity, paymentToken)
                     .profileId(profileId)
                     .posType(SoftPOSType.Terminal)
                     .build()

4. Receive Payment Response

To receive a payment response, refer to the parameters below.

📘

Response API Parameters

Refer to: Payment Response API Parameters

SoftPOSSDK.getInstance().pay(paymentRequest, new PaymentResultResponseCallback<SoftPOSPaymentResultResponse>() {

     @Override
     public void onResponse(SoftPOSPaymentResultResponse response) {

         if (response.getResponseCode().equals(SoftPOSPaymentResponseCode.PaymentSuccess)) {  
           
             //Read payment response. 
         } else {
 
             //Get error response and display error.
         }
     }

     @Override
     public void onFailure(@NonNull Throwable error) {

         //Get error response and display error.
     }
});
SoftPOSSDK.getInstance().pay(paymentRequest, object : PaymentResultResponseCallback<SoftPOSPaymentResultResponse> {
                             
      override fun onResponse(response: SoftPOSPaymentResultResponse) {
  
            if (response.equals(SoftPOSPaymentResponseCode.PaymentSuccess)) {
                
                  //Read payment response.
            } else {
 
                  //Get error response and display error.
            }
      }

      override fun onFailure(error: Throwable) {
          
            //Get error response and display error.
      }
})

 

Full Sample Code

The following sample code demonstrates requests and parameters for each step of the process.

//Step 1: Generate payment token.
String paymentToken = "roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL";
 
//Step 2: Construct payment request.
String profileId = "prof_01XXXXXXXXXXX1";

PaymentRequest paymentRequest = new PaymentBuilder(getActivity(), paymentToken)
                                .profileId(profileId)
                                .posType(SoftPOSType.Terminal)
                                .build();
 
//Step 3: Retrieve payment response.
SoftPOSSDK.getInstance().pay(paymentRequest, new PaymentResultResponseCallback<SoftPOSPaymentResultResponse>() {

     @Override
     public void onResponse(SoftPOSPaymentResultResponse response) {

         if (response.getResponseCode().equals(SoftPOSPaymentResponseCode.PaymentSuccess)) {  
           
             //Read payment response. 
         } else {
 
             //Get error response and display error.
         }
     }

     @Override
     public void onFailure(@NonNull Throwable error) {

         //Get error response and display error.
     }
});
//Step 1: Generate payment token.
val paymentToken = "roZG9I1hk/GYjNt+BYPYbxQtKElbZDs9M5cXuEbE+Z0QTr/yUcl1oG7t0AGoOJlBhzeyBtf5mQi1UqGbjC66E85S4m63CfV/awwNbbLbkxsvfgzn0KSv7JzH3gcs/OIL"
 
//Step 2: Construct payment request.
val profileId = "prof_01JQB8Y9EMCRBG27NWXXXCRNA1"

val paymentRequest = PaymentBuilder(activity, paymentToken)
                     .profileId(profileId)
                     .posType(SoftPOSType.Terminal)
                     .build()
 
//Step 3: Retrieve payment response.
SoftPOSSDK.getInstance().pay(paymentRequest, object : PaymentResultResponseCallback<SoftPOSPaymentResultResponse> {
                             
      override fun onResponse(response: SoftPOSPaymentResultResponse) {
  
            if (response.equals(SoftPOSPaymentResponseCode.PaymentSuccess)) {
                
                  //Read payment response.
            } else {
 
                  //Get error response and display error.
            }
      }

      override fun onFailure(error: Throwable) {
          
            //Get error response and display error.
      }
})