Pay Kit Android: Getting Started
Pay Kit Android: Getting Started
Pay Kit Android: Getting Started
One-time payments can be authorized for a Merchant, Brand, or Client. On-file payments can only be authorized for a Brand or Client.
2136Get the latest version of the SDK from Maven.
Gradle
Gradle version catalogs
For the latest released version, check GitHub Releases or Cash App Pay Android SDK on Maven Central.
Use the Sandbox environment during the development phase and use the production environment for your actual production releases. Use the Sandbox App to more closely simulate a production experience while on Sandbox environment. This application is optional, but highly recommended as it will simulate Cash App, and allow you to easy trigger edge-cases for testing.
Use CashAppPayFactory to create an instance of the SDK.
client ID. This is a required field.createSandbox() will create an SDK instance in the Sandbox environment.Creating a Sandbox SDK instance:
Creating a Production SDK instance:
To receive updates from Pay Kit, implement the CashAppPayListener interface.
unregister function after you have finished using the SDK:CashAppPayState is a sealed class parameter. We recommend that you use a Kotlin when statement when integrating with the SDK. The following are examples of critical states:
The authorization flow brings Cash App to the foreground on the Customer’s device. After the Customer either authorizes or declines the request, your app must be returned to the foreground.
To call your app back to the foreground, declare an incoming intent filter on your app’s Android Manifest. When creating a customer request, pass a corresponding redirect URI that uses the SDK.
AndroidManifest
Create a Customer Request as soon as you know the amount you want to charge or if you want to create an on-file payment request. We recommend that you create this request as soon as your checkout view controller loads, so that the Customer can authorize the request immediately.
Note: If you’re using Afterpay SDK together with Cash App Pay SDK, the merchantId contained within that data is the same as scopeId in this context.
To charge $5.00 as a one-time payment, the create request call might look like this:
With payouts you can send money to a user’s Cash App account. For mobile development the Pay Kit SDK, the payout workflow is identical to the two above.
After the SDK is in the ReadyToAuthorize state, display the enabled Cash App Pay button. When the Customer taps the button, you can authorize the Customer Request.
Example
The Button provided by the SDK is unmanaged. It is a stylized button that isn’t aware of SDK events out-of-the-box. It is the developer’s responsibility to call the above method when the button is clicked and also manage any disabled and loading states.
Your app will redirect to Cash App for authorization. When the authorization is completed, your redirect URI is called to open your app. The SDK fetches your authorized request and returns it to your callback listener as one of 2 states: Approved or Declined.
The Approved state contains a Grants list object associated with it and it can be used with the Cash App Create Payment API. Pass these grants to your backend and call the CreatePayment API as a server-to-server call to complete your payment.