Logoelepay

Api Reference

Elepay

Kind: global class

new Elepay(key, options)

Initialize the SDK.

Returns: Elepay - Elepay instance

ParamTypeDescription
keystringRequired. Publishable key
optionsobjectOptions
options.localestringLanguage. Default is auto (auto‑detect from browser). You can also set ja, en, zh-CN, zh-TW.

elepay.handleCharge(charge) ⇒ Promise

Process a payment with a Charge object.

Kind: instance method of Elepay
Returns: Promise - Promise of the payment result. For methods that require frontUrl, the result is returned via frontUrl.

ParamTypeDescription
chargeobjectRequired. Charge object created on server

Example

elepay
  .handleCharge(chargeObject)
  .then(function (result) {
    // Normal flow
    if (result.type === 'cancel') {
      // Payment cancelled
    } else if (result.type === 'success') {
      // Payment succeeded
    }
  })
  .catch(function (err) {
    // Error handling
  });

elepay.handleSource(source) ⇒ Promise

Process an authorization with a Source object.

Kind: instance method of Elepay
Returns: Promise - Promise of the authorization result. For methods that require frontUrl, the result is returned via frontUrl.

ParamTypeDescription
sourceobjectRequired. Source object created on server

Example

elepay
  .handleSource(source)
  .then(function (result) {
    // Normal flow
    if (result.type === 'cancel') {
      // Cancelled
    } else if (result.type === 'success') {
      // Authorization succeeded
    }
  })
  .catch(function (err) {
    // Error handling
  });

elepay.createCodeWidget(options) ⇒ CodesWidget

Create an EasyQR widget.

Kind: instance method of Elepay Returns: CodesWidget - EasyQR widget instance

ParamTypeDescription
optionsobjectWidget options
options.containerstringCSS selector string for the target DOM element
options.directionstringWidget layout. vertical (default) or horizontal
options.iconbooleanIf true, show branded QR icon. Default false
options.parts.amountbooleanIf true, show amount. Default true
options.parts.paymentLogobooleanIf true, show payment method icon. Default true
options.parts.tipbooleanIf true, show help message. Default true
options.theme.primaryColorbooleanPrimary color
options.theme.borderColorbooleanBorder color. null: no border
options.theme.backgroundColorbooleanBackground color. Default white

Example

var widget = elepay.createCodeWidget({
  container: '#widget',
});
widget.on('success', () => {
  // Post‑payment handling
});
widget.on('expired', () => {
  // Generate a new EasyQR code, etc.
});
widget.show('cod_028123beb9f8c853fa845f4');

elepay.checkout(code) ⇒ Promise

Run EasyCheckout.

Kind: instance method of Elepay Returns: Promise - Promise for the checkout flow. Only handle on error.

ParamTypeDescription
codeobjectRequired. EasyQR object ID created on server

Example

elepay.checkout('cod_028123beb9f8c853fa845f4').catch(function (err) {
  // Error handling
});

CodesWidget

EasyQR widget class.

Kind: global class

codesWidget.show(code)

Show the EasyQR widget.

Kind: instance method of CodesWidget

ParamTypeDescription
codeobjectRequired. EasyQR object ID created on server

Example

widget.show('cod_028123beb9f8c853fa845f4');

codesWidget.destroy()

Destroy the EasyQR widget.

Kind: instance method of CodesWidget

"success" (ev, codeObject)

Event emitted when a payment completes.

Kind: event emitted by CodesWidget

ParamTypeDescription
evobjectEvent
ev.typestringsuccess
codeObjectobjectEasyQR code object

Example

widget.on('success', function (ev, codeObject) {
  // Post‑payment handling
});

"expired" (ev, codeObject)

Event emitted when an EasyQR code expires.

Kind: event emitted by CodesWidget

ParamTypeDescription
evobjectEvent
ev.typestringexpired
codeObjectobjectEasyQR code object

Example

widget.on('expired', function (ev, codeObject) {
  // Generate a new EasyQR code, etc.
});

"error" (ev, error)

Error event.

Kind: event emitted by CodesWidget

ParamTypeDescription
evobjectEvent
ev.typestringerror
errorErrorError object

Example

widget.on('error', function (ev, err) {
  // Error handling
});

Last updated on

On this page