Skip to content

第二步 Configure payment information

javascript
const testPayment = JsPayment.createPayment(PaymentOptions);

PaymentOptions Details

ParameterTypeRequiredDescription
tokenString(32)RequiredObtain token from Step 1 Get Token
environmentString(32)RequiredSet the current request environment: Production environment (Production) or Test environment (Sandbox)
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)RequiredVerification trigger timing, choose one of two: 'blur' / 'change', default is 'blur'
languageString(16)RequiredCurrently supports Chinese (zh-cn) or English (en) versions.
languageJsonJsonRequiredIf other languages are required, you can customize [Language Configuration](#Language configuration).
inputStyleStyleRequiredFor details, please refer to [Input Box Style in Payment Information](#Enter the box style in the payment information)

Input Box Style in Payment Information

ParameterDescription
colorText Color
caretColorCursor Color
fontSizeFont Size
fontWeightFont Weight

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",
        },
      }
    });
}