Integrating GMOPG

Endpoints for integrating [GMOPG](https://www.gmo-pg.com/) with Storeganise

- GET /v1/billing/gmopg/settings - list payment gateway settings

- GET /v1/billing/gmopg/settings/bank-account - list payment gateway bank data

- GET /v1/billing/gmopg/sources - list available payment methods, returns  { cards: Array<{CardNo, CardExpire}>, bankAccount: {Status}, paymentType: 'directDebit'|'creditCard' } 

- POST /v1/billing/gmopg/sources { token: String }  - registers a card, the token is acquired using the GMOPG client lib: https://static.mul-pay.jp/ext/js/token.js (or https://stg.static.mul-pay.jp/ext/js/token.js for a testing GMOPG account)

Sample code:

/*
Form data:
- cardno: card number without spaces
- securitycode: card security code without spaces
- expire: must follow this YYYYMM format, e.g. '202408'
- holdername: optional card holder's name, e.g. 'John Doe'
 */
const gmopgSettings = await fetch('/api/v1/billing/gmopg/settings', {headers: {authorization: 'Bearer ..'}}); // fetch the GMOPG settings from Storeganise API
window.Multipayment.init(gmopgSettings.ShopID); // load <script src="https://static.mul-pay.jp/ext/js/token.js"></script> first
return new Promise((resolve, reject) => {
  window.Multipayment.getToken(formData, ({ resultCode, tokenObject }) => {
    if (resultCode !== '000' || !tokenObject) {
      return reject(new Error(`Invalid credit card data ${resultCode === 102 ? '[card number]' : resultCode === 122 ? '[verification number]' : `[other: ${resultCode}]`}`));
    }
    resolve(tokenObject.token);
  });
})
  .then(token => {
    return fetch('/api/v1/billing/gmopg/sources', {
      method: 'POST',
      body: JSON.stringify({ token }),
      headers: {authorization: 'Bearer ..'}, 'content-type': 'application/json',
    });
  })
  .catch(err => {
    window.alert(`Saving card failed ${err.message}`);
  });

- POST /v1/billing/gmopg/sources/bank-account { bankCode, accountType, branchCode, accountNumber, accountName }  - registers a bank account, depending on the bank, not all fields are necessary. The required fields are given by the GET /v1/billing/gmopg/settings/bank-account endpoint

fetch('/api/v1/billing/gmopg/sources/bank-account', {
  method: 'POST',
  body: JSON.stringify({ bankCode, ... }),
  headers: {authorization: 'Bearer ..'}, 'content-type': 'application/json',
})
  .then(({ TranID, Token, StartUrl }) => {
    const redirectUrl = `/api/v1/billing/gmopg/sources/bank-account/register?${new URLSearchParams({ TranID, Token, StartUrl })}`;   window.location.href = redirectUrl; // also possible to open this page in a popup (window.open(redirectUrl, '_blank'))
  });

.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us