WEB JS SDK / Get PayToken

Get PayToken

When a user clicks the merchant’s pay button, please call getPayToken() function to get a PayToken. The PayToken is then used to call the Getting Token by Trade API.

				
					ECPay.getPayToken(callBack(paymentInfo, errMsg))
				
			

callBack description

The callback function after getPayToken is completed. For example, if initialization fails, error message received by the callBack.

				
					function (paymentInfo, errMsg) {}
				
			

You can get the payment information if getPayToken() is successful.

PaymentInfo Object

Payment information

PayToken String(64)
 

The lifespan is 30 minutes. Details please see PayToken.

PaymentType String(20)
 

Payment method

  • CreditCard: credit card pay at once
  • CreditInstallment: credit card installments
  • ATM
  • CVS: CVS (pay by convenience store reference number)
  • Barcode: BARCODE (pay by convenience store barcodes)
  • Period: Periodical payment (subscrioption plan)
  • UnionPay
  • ApplePay

❗ Special note: If using Apple Pay only, the PayToken will not be return. Merchant need implement GetApplePayResultData to get the payment result.

Example

				
					ECPay.getPayToken(function (paymentInfo, errMsg) {
    if (errMsg != null) {
        ErrHandle(errMsg);
        return;
    };
    $("#PayToken").val(paymentInfo.PayToken);
    return true;
});
				
			

Copyright © Green World FinTech Service Co., Ltd. All rights reserved.

Green World