Skip to content

Frontend API

1. API

Use PMdropin.API.

APIDescriptionDetails
createInstantiate a built-in componentRefer create
mountMount instantiated component to div tagRefer mount
onListen eventsRefer on
emitTrigger eventsRefer emit

1.1 create

Used to initialize components, please use PMdropin.create(ComponentName, Options).

ComponentName Explanation

ComponentNameField TypeDescription
googlepaystringGooglePay Component

Options Explanation

OptionsRequired Or NotField TypeDefault Value
clientKeyYString-
sessionKeyYString-
sandboxNBooleanfalse
payButtonStyleNObject'{buttonRadius: "12",buttonColor: "default",buttonType: "plain",buttonLocale: "en",width: "240px",height: "40px"}'

1.2 mount

Used to mount initialization component instances, please use PMdropin.mount(Tag).

Tag Explanation

TagDescription
idThe value of the id element that needs to be mounted, such as PMdropin.mount('#googlepay-frame')
classThe value of the class element that needs to be mounted, such as PMdropin.mount('.googlepay-frame')

1.3 on

Used to listen to component built-in response events, please use PMdropin.on(Event, CallbackFunction).

Event Explanation

TagDescriptionReturned Value
readyTriggered when the component completes loadingnull
payButtonClickTriggered when the GooglePay button is clickednull

1.4 emit

Used to call component built-in methods, please use PMdropin.emit(Event, Params).

EventParamsDescription
canMakePayment-Get the payment token
switchThemestringSwitch theme
setDisabledBooleanSet the component available state
setPayButtonStyleObjectSet the button style
1.4.1 emit.canMakePayment

Checks whether the current component status meets the conditions for initiating payment. If the verification passes, returns the card ID.

canMakePayment Response:

CodeDescription
APPLY_SUCCESSGet paymentToken successfully
UNKNOWN_ISSUEException information
1.4.2 emit.setDisabled
  • Set the component available state
  • Type: Boolean
  • Default: false
js
// Button disabled state
PMdropin.emit('setDisabled', true)

// Button enabled state
PMdropin.emit('setDisabled', false)
1.4.3 emit.setPayButtonStyle
  • Set the button style
  • Type: Object
  • Default:
Go
{
  buttonRadius: "12", // Set the border radius of the googlepay button String
  buttonColor: 'default', // Set button color "default"/"white"/"black"
  buttonType: 'plain',
  buttonLocale: 'en',
  width:"240px",
  height:"40px",
}

2. Internal Field Description

FieldDefault ValueTypeEnumerationDescription
width"240px"String/Set Google Pay button width
height"40px"String/Set Google Pay button height
buttonRadius"12"String/Set the border radius of the googlepay button String
buttonColor'default'String'default'/'white'/ 'black' Set button color
buttonType'plain'String"plain","buy","book","checkout","donate","order","pay","subscribe"Set button type Same as GooglePay official. See Preview demo for customized button
buttonLocale'en'String'en'/'ja'/'zh'/... International language encodingSet the multi-language text on the button, the same as GooglePay official, only supports the specified type, such as "checkout", "donate", etc.

3. Color Display

InputEffect Preview
default
white
black

4. buttonType Display

InputEffect Preview
"plain"
"buy"
"book"
"checkout"
"donate"
"order"
"pay"
"subscribe"

5. buttonLocale Display

InputEffect PreviewDescription
"ja"Japanese
"bg"Bulgarian

Was this page helpful?

Thank you for your help in improving PayerMax Product Docs!

Last updated:

Released under the MIT License.