Cash App Pay

Take a Cash App Pay payment

Usage

index.html
HTML

<!-- Renders the Cash App Pay button -->

<form>

    <div id="cash-app-pay"></div>

</form>

<!-- Configure the WebSDK -->

<script type="text/javascript">

  async function main() {

    const payments = Square.payments(APPLICATION_ID, LOCATION_ID);



    const req = payments.paymentRequest({

      countryCode: 'US',

      currencyCode: 'USD',

      total: {

        amount: '1.00',

        label: 'Total',

      },

    });



    const options = {

      redirectURL: window.location.href,

      referenceId: 'my-distinct-reference-id',

    };



    const cashAppPay = await payments.cashAppPay(req, options);



    cashAppPay.addEventListener('ontokenization', function (event) {

      const { tokenResult } = event.detail;

      if (tokenResult.status === 'OK') {

          token = tokenResult.token;

      }

    });



    const cashAppPayButtonTarget = document.getElementById('cash-app-pay');

    cashAppPay.attach(cashAppPayButtonTarget);

  }



  main();

</script>

Payments

Returned by Square.payments(appId, locationId).

Use this object to instantiate Payment methods. Learn more on the Payments page.

Methods

payments.js
JS
JavaScript

const payments = Square.payments(appId, locationId);

CashAppPay

Create a CashAppPay method instance

Methods

cashAppPay.js
JS
JavaScript

const paymentRequest = payments.paymentRequest({

  countryCode: 'US',

  currencyCode: 'USD',

  total: { amount: '5.79', label: 'Total', pending: false },

});



const options = {

  redirectURL: window.location.href,

  referenceId: 'my-distinct-reference-id',

};



const cashAppPay = await payments.cashAppPay(req, options);



cashAppPay.addEventListener('ontokenization', (event) => {

  const { tokenResult } = event.detail;

  const tokenStatus = tokenResult.status;

  if (tokenStatus === 'OK') {

    const token = tokenResult.token;

  }

});



await cashAppPay.attach('#cashAppPay');