Supporting Multiple PGs with pg attribute


In some cases, your service should support multiple PG services for various reasons. For example, you may support a simple payment method such as KakaoPay or PAYCO, or use a different PG service for each payment method.

To support this scenario, we will learn how to add multiple PG services in Iamport Admin Dashboard and change pg attribute of the param when calling IMP.request_pay to call the desired payment window based on the situation.

In this guide, we will assume that Inicis is a default PG and another Inicis setting will be added for the recurring payment. KakaoPay will be also added for the simple payment.

Configure multiple PGs in Admin Dashboard

Before using the Iamport JavaScript library, you need to set the default PG company and additional PG services to use in Admin Dashboard.
1Set up a default PG service
In Iamport Admin Dashboard > System Configuration page, set a default PG in Default PG tab in PG Settings tab. Set the PG service to be used primarily as the default PG. The PG service set as the default PG is used by default when calling the IMP.request_pay function of the Iamport JavaScript library.In this example, KG Inicis (web standard method) is set as the default PG service.

Default PG service

When IMP.request_pay(param, callback) is called, if the value specified in the pg attribute of param is not found, it calls the payment window of the PG that is set as the default PG. This is the policy of Iamport to prevent loss of sales by setting the default PG and calling the payment window in any case, because such a situation may occur due to a mistake in the value of the pg attribute or a programmer’s mistake.
2Add PG services
First, we will add the recurring payment to the service. In order to use the regular recurring payment, we will assume that an additional merchant ID (MID) for the recurring payment was issued from KG Inicis.

Click Add PG tab on the left to create a tab where the additional PG can be configured.
Then, enter the information of additionally issued PG (e.g. merchant ID) for the recurring payment in the newly added PG tab.For recurring payment, KG Inicis (web standard payment window) is selected as PG, and the newly issued information was entered: PG merchant ID (MID), web standard payment signKey, and merchantKey for billing.

Next, we will add KakaoPay, one of the simple payment services, for users’ convenience.

Likewise, click the Add PG tab on the left and set PG Service to KakaoPay.
Through the above steps, we registered a total of 3 PG services. In this example, the configuration for each PG is as below.
PG serviceMerchant IDPurposeDefault PG
KG InicisMID-a(example)General paymentO
KG InicisMID-b(example)Recurring PaymentX
카카오페이MID-c(example)Simple PaymentX

Use desired PG service when calling IMP.request_pay

When you start the payment process by calling IMP.request_pay(param, callback) of Iamport JavaScript library, you can use the payment window of desired PG among the PG services previously registered using the pg attribute of param. The following values can be specified for the pg attribute.
  • { PG service code }
  • { PG service code }.{ PG merchant ID }

pg attribute matching priority

The PG will be matched with specified pg property in the order of PG configurations set in Admin Dashboard. The payment window corresponding to the first matching PG service is called.

Identify PG with { pg service code }

Among the three PG services set in the example above, the PG company that can be identified by the pg service code is KakaoPay. Thus, it can be easily identified using the pg service code.
  IMP.request_pay({
    pg : "kakaopay",  // Call KakaoPay payment window
    amount : 1000,
    name : "Test order",
    buyer_name : "Buyer",
    buyer_email : "buyer@iamport.kr"
  });
If you specify kakaopay as pg attribute as above, the payment window corresponding to the KakaoPay configuration in the PG setting in Admin Dashboard is called.

pg service code

  • KG Inicis (web standard method ), billing payment : html5_inicis
  • KCP : kcp
  • KCP(billing payment) : kcp_billing
  • LGU+ : uplus
  • Nice Payments : nice
  • JTNet : jtnet
  • KICC : kicc
  • BlueWalnut : bluewalnut
  • KakaoPay : kakaopay
  • Danal (mobile micropayment) : danal
  • Danal (Credit card/bank transfer/virtual account) : danal_tpay
  • Mobilians : mobilians
  • CHAI simple payment : chai
  • PAYCO : payco
  • Syrup Pay : syrup
  • PayPal : paypal
  • Eximbay : eximbay
  • Naver Pay (on-demand) : naverco
  • Naver Pay (payment type) : naverpay

Identify by { pg service code }.{ pg merchant ID }

Among the three PG services set in the above example, KG Inicis (general payment) and KG Inicis (recurring payments) have the same PG service code. It is not possible to identify the specific PG setting with just html_inicis as PG attribute. In this case, the first PG setting of KG Inicis is used among the PG settings in Admin Dashboard.

In order to solve this problem, the pg merchant ID can be provided along with the pg service code to point to the desired PG setting even for the same PG service.

Therefore, you can point to the PG setting of KG Inicis (recurring payments) by specifying the pg attribute as html5_inicis.MID-b as shown below.
  IMP.request_pay({
    pg : "html5_inicis.MID-b",  // Call KG Inicis recurring payment window (merchant ID MID-b is applied)
    amount : 1000,
    name : "Test order",
    buyer_name : "Buyer",
    buyer_email : "buyer@iamport.kr"
  });
In the same way, you can point to the PG setting of KG Inicis (general payment) by specifying the pg attribute as html5_inicis.MID-a.
  IMP.request_pay({
    pg : "html5_inicis.MID-a",  // Call KG Inicis general payment window (merchant ID MID-a is applied)
    amount : 1000,
    name : "Test order",
    buyer_name : "Buyer",
    buyer_email : "buyer@iamport.kr"
  });