Guides

QR Code Flow for Merchants

Connecting with patrons using our QR Code Flow requires the merchant integration to create a Payment Request and present a QR Code for the patron to scan.

The sequence diagram below indicates the expected flow of behavior between the patron, the Point of Sale (POS) and Centrapay.

    sequenceDiagram
	autonumber

	participant Patron
	participant POS
	participant Centrapay

	POS->>Centrapay: Create Payment Request

	note over POS: Present QR Code

	Patron->>POS: Scan QR Code

	par
		loop
			POS->>Centrapay: Poll for Payment Confirmation
		end

		Patron->>Centrapay: Pay Payment Request
	end

	Note over POS: ✅ Display Successful Payment
	Note over Patron: ✅ Display Successful Payment
  
  1. The POS creates a Payment Request and presents a QR code to the Patron on a customer-facing display.

    The QR code decodes to a URL of the form https://app.centrapay.com/pay/{paymentRequestId}

    Request
    curl -X POST https://service.centrapay.com/api/payment-requests \
    -H "X-Api-Key: $api_key" \
    -H "Content-Type: application/json" \
    -d '{
    "configId": "5ee168e8597be5002af7b454",
    "value": {
    "amount": "10000",
    "currency": "NZD"
    }
    }'
    Response
    {
    "configId": "5ee168e8597be5002af7b454",
    "createdAt": "2021-06-08T04:04:27.426Z",
    "expiresAt": "2021-06-08T04:06:27.426Z",
    "expirySeconds": 120,
    "id": "MhocUmpxxmgdHjr7DgKoKw",
    "merchantId": "26d3Cp3rJmbMHnuNJmks2N",
    "merchantName": "Centrapay Café",
    "paymentOptions": [
    {
    "amount": "10000",
    "assetType": "centrapay.nzd.main"
    }
    ],
    "shortCode": "CP-C7F-ZS5",
    "status": "new",
    "updatedAt": "2021-06-08T04:04:27.426Z",
    "url": "https://app.centrapay.com/pay/MhocUmpxxmgdHjr7DgKoKw",
    "value": {
    "currency": "NZD",
    "amount": "10000"
    }
    }
  2. The patron scans the QR code using a Centrapay-enabled app.

  3. The POS polls the Payment Request for Payment Confirmation.

    Request
    curl https://service.centrapay.com/api/payment-requests/MhocUmpxxmgdHjr7DgKoKw \
    -H "Authorization: $jwt"
    Response
    {
    "configId": "5ee168e8597be5002af7b454",
    "createdAt": "2021-06-08T04:04:27.426Z",
    "expiresAt": "2021-06-08T04:06:27.426Z",
    "expirySeconds": 120,
    "id": "MhocUmpxxmgdHjr7DgKoKw",
    "merchantId": "26d3Cp3rJmbMHnuNJmks2N",
    "merchantName": "Centrapay Café",
    "paymentOptions": [
    {
    "amount": "10000",
    "assetType": "centrapay.nzd.main"
    }
    ],
    "shortCode": "CP-C7F-ZS5",
    "status": "new",
    "updatedAt": "2021-06-08T04:04:27.426Z",
    "url": "https://app.centrapay.com/pay/MhocUmpxxmgdHjr7DgKoKw",
    "value": {
    "currency": "NZD",
    "amount": "10000"
    }
    }
  4. While the POS continues to poll, the patron pays the Payment Request via their Centrapay integrated app. When the Payment Request status is paid, the POS stops polling and displays confirmation of the successful payment.

    Request
    curl -X POST https://service.centrapay.com/api/payment-requests/MhocUmpxxmgdHjr7DgKoKw/pay \
    -H "Authorization: $jwt" \
    -H "Content-Type: application/json" \
    -d '{
    "assetType": "centrapay.nzd.main",
    "assetId": "WRhAxxWpTKb5U7pXyxQjjY"
    }'
    Response
    {
    "activityNumber": "2",
    "assetType": "centrapay.nzd.main",
    "createdAt": "2021-06-08T04:04:27.426Z",
    "createdBy": "crn::user:0af834c8-1110-11ec-9072-3e22fb52e878",
    "merchantAccountId": "C4QnjXvj8At6SMsEN4LRi9",
    "merchantConfigId": "5ee168e8597be5002af7b454",
    "merchantId": "26d3Cp3rJmbMHnuNJmks2N",
    "merchantName": "Centrapay Café",
    "paymentRequestCreatedBy": "crn::user:0af834c8-1110-11ec-9072-3e22fb52e878",
    "paymentRequestId": "MhocUmpxxmgdHjr7DgKoKw",
    "shortCode": "CP-C7F-ZS5-015",
    "type": "payment",
    "value": {
    "currency": "NZD",
    "amount": "10000"
    }
    }