Skip to content

Step 2: Configure payment information ​

javascript
const testPayment = JsPayment.createPayment(PaymentOptions);

PaymentOptions Details ​

ParameterTypeRequiredDescription
tokenString(32)RequiredObtain token from Step 1 Get Token
gatewayString(32)RequiredSet the environment for the current request to distinguish between the production environment and the test environment. (For specific links, contact the customer service for assistance.)
cardOptionsCardOptionsRequiredFor details, please refer to (CardOptions Details)

CardOptions Details ​

ParameterTypeRequiredDescription
elementIdString(64)RequiredElement ID, used to fill payment information (HTML) into the specified element
errorTriggerString(32)OptionalVerification trigger timing, choose one of two: 'blur' / 'change', default is 'blur'
languageString(16)OptionalCurrently supports Chinese (zh-cn) or English (en) versions.
languageJsonJsonOptionalIf other languages are required, you can customize Language Configuration.
inputStyleStyleOptionalFor details, please refer to (Input Box Style in Payment Information)
inputPlaceholderJsonOptionalFor details, please refer to (Input Box Placeholder in Payment Information)

Input Box Style in Payment Information ​

ParameterDescription
colorText Color
caretColorCursor Color
fontSizeFont Size
fontWeightFont Weight

Input Box Placeholder in Payment Information ​

ParameterDescription
firstNameFirst Name reminder phrase
lastNameLast Name reminder phrase
cardNumberCard Number reminder phrase
expirationDateExpiration Date reminder phrase
securityCodeSecurity Code reminder phrase

Language Configuration ​

json
{
  "firstName": "First Name",
  "firstName.required": "Please enter the first name",
  "lastName": "Last Name",
  "lastName.required": "Please enter the last name",
  "cardNumber.label": "Card Number",
  "cardNumber.required": "Please enter the card number",
  "cardNumber.error": "Please enter a valid card number",
  "expirationDate.label": "Expiration Date",
  "expirationDate.required": "Please enter the expiration date",
  "expirationDate.error": "Please enter a valid expiration date",
  "securityCode.label": "Security code",
  "securityCode.required": "Please enter the security code",
  "securityCode.error": "Please enter a valid security code"
}

Example ​

html
<div style="display: flex;align-items: center;justify-content: center;height: 100%;width: 100%">
  <div style="width: 430px;height: 300px;">
    <div id="test" style=" width: 100%;"></div>
    <button id="payment" type="button" style="width: 100%;height: 40px;">Payment</button>
  </div>
</div>
javascript
function createPayment(res: any) {
  const element = document.getElementById("payment");
  const testPayment: any = JsPayment.createPayment(
    {
      token: res.token,
      environment: 'Sandbox',
      cardOptions: {
        elementId: 'test',
        language: 'en',
        inputStyle: {
          color: "red",
          fontSize: "14px",
        },
        inputPlaceholder: {
          firstName: 'First Name',
          lastName: 'Last Name',
          cardNumber: 'Card Number',
          expirationDate: 'Expiration Date',
          securityCode: 'Security Code',
        }
      }
    });
}