Accept QR Payments in Japan

Link to section

Accept QR payments

The Point of Sale API supports accepting QR code payments in Japan using the Square Point of Sale application and Square Reader.

Important

QR code payments are supported only in Japan. If you're developing a Point of Sale API integration for other regions, the content of this topic doesn't apply.

If a seller is approved to accept QR payments in Japan, the QR option appears if your application supports it. For more information, see Apply for QR code payment, which can be viewed in English or Japanese.

The following diagram illustrates the checkout flow with QR payments:

A graphic showing the payment flow on a mobile device in Japan with the payment form, a localized payment page with PayPay and other payment methods, and the PayPay QR code.

Link to section

Initiate a QR payment from your application

Add code that creates a new charge request and uses it to initiate a transaction in the Point of Sale application. The startTransaction function uses ChargeRequest.Builder to create a charge for ¥1 JPY and restrict the tender type to PAYPAY. It then uses that request to create a ChargeRequest and initiate the transaction with an Intent object.

Note

You need to use the PAYPAY enumeration for any kind of QR payment.

Create a new charge request as shown:

Note

The AlertDialogHelper object that's used in this code block is an example of a helper class instance and isn't part of the Point of Sale API.

Link to section

Initiate a QR code payment from your mobile web application

Mobile web transactions are initiated by choosing a link to the Square Point of Sale application. Because the request URL includes details about the transaction, you should build the URL dynamically instead of hardcoding it. The link URL includes the transaction information as parameters and is formatted differently for Android and iOS applications.

The request URLs of the Square Point of Sale application for Android are formatted as intent requests. For example:

<a href="intent:#Intent; action=com.squareup.pos.action.CHARGE; package=com.squareup; S.browser_fallback_url=https://my.website.com/index.html; S.com.squareup.pos.WEB_CALLBACK_URI=https://my.website.com/index.html; S.com.squareup.pos.CLIENT_ID=sq0ids-yourClientId; S.com.squareup.pos.API_VERSION=v2.0; i.com.squareup.pos.TOTAL_AMOUNT=100; S.com.squareup.pos.CURRENCY_CODE=JPY; S.com.squareup.pos.TENDER_TYPES=com.squareup.pos.TENDER_PAYPAY; end">Start Transaction</a>

Note

You need to use the TENDER_PAYPAY enumeration for any kind of QR payment.

Android requires URLs to be wrapped with Android start and end tokens when they contain key-value pairs delimited with semicolons. The Android start and end tokens are intent:#Intent; and end.

To build your request URL:

  1. Create a JavaScript file called open_pos.js.

  2. Add code to define some useful constants, configure your mobile web application, and set the transaction total.

    // The URL where the Point of Sale app will send the transaction results. var callbackUrl = "{YOUR CALLBACK URL}"; // Your application ID var applicationId = "{YOUR APPLICATION ID}"; // The total and currency code should come from your transaction flow. // For now, we are hardcoding them. var transactionTotal = "{TRANSACTION TOTAL}"; var currencyCode = "JPY"; // The version of the Point of Sale SDK that you're using. var sdkVersion = "v2.0";
  3. Add code to build the request URL. For a detailed list of all possible URL parameters, see Mobile Web Technical Reference.

  4. Add the following script tag to your HTML head to load your open_pos.js file:

    <head> <!-- Loads callback javascript --> <script type="text/javascript" src="/open_pos.js"></script> </head>
  5. Add a button to your mobile web application that runs open-POS.js.

    <button onclick="openUrl()"> Start Transaction </button>```