- Pay
- Parameters
- addEventListener
- Parameters
- CustomerInteractionData
- CustomerRequestData
- Customer
- Grants
- Returns
- removeEventListener
- Parameters
- Returns
- customerRequest
- Parameters
- onFile
- payment
- Amount
- Returns
- CustomerRequestController
- update
- render
- Parameters
- Returns
- RenderController
- begin
- destroy
- restart
- Parameters
- Returns
- Custom elements
- Logo
- Customer
Technical Reference
Pay
Pay Kit initializes to window.CashApp when you include our script and exposes an asynchronous pay method which requires a Client ID. The Promise resolves an instance of Pay.
Parameters
addEventListener
Pay exposes an addEventListener method that listens for events throughout the lifecycle of paying.
Parameters
PayEventListener: (data: PayEventData) => void
The "CUSTOMER_REQUEST_DECLINED" and "CUSTOMER_REQUEST_FAILED" events will not receive data.
PayEventData: CustomerInteractionData | CustomerRequestData
CustomerInteractionData
CustomerRequestData
Customer
The Customer who approved the request.
Grants
The map of action to details about a grant may have keys payment or onFile (same as Actions below). GrantDetail has the following properties:
Returns
void
removeEventListener
Pay exposes a removeEventListener method that removes an event listener previously registered with addEventListener.
Parameters
Returns
void
customerRequest
Pay exposes a customerRequest method that creates a Customer Request with one or more actions. You’ll need a Merchant to create a payment.
Parameters
The customerRequest method takes a CustomerRequestDetails object as its only argument. It has the following properties:
Actions is an object with optional onFile and payment properties, but at least one must exist.
onFile
payment
Amount
Amount to charge the customer.
Returns
Promise<CustomerRequestController>
CustomerRequestController
CustomerRequestController controls the Customer Request.
update
The update method will update your Customer Request. The same validation applies (for example, must have at least one action) except redirectURL cannot be changed.
Returns Promise<boolean> to indicate if the update was successful. An example of when an update would not be successful is if the Customer Request has already been approved.
render
Pay exposes a render method that renders a managed Cash App Pay UI into your DOM.
Parameters
RenderOptions is an object with these optional properties:
ButtonOptions is an object with these optional properties:
Returns
Promise<RenderController>
RenderController
RenderController can control rendering.
begin
The begin method will begin the authorization flow for the customer if the manage option was false. Otherwise, it is a no-op. To use your own button and control the flow, you must set both manage and button to false.
destroy
The destroy method will remove the Cash App Pay UI from your DOM.
restart
Pay exposes a restart method that removes all rendered UI as well as the current customer request.
In a single page app,pay.restart() must be called whenever the buyer leaves the checkout page. You can only make a new customer request after restart, if the current customer request is approved.
Parameters
None
Returns
void
Custom elements
Pay Kit provides custom elements to help customize checkout experiences while making it easy to follow brand guidelines.
Logo
The <cash-app-pay-logo> element renders the Cash App Pay logo and can be customized with two attributes:
Customer
The <cash-app-pay-customer> element renders the Cash App Pay logo and a customer’s $Cashtag. The cashtag attribute is required and will be automatically truncated if needed. The element will grow to fill its parent container.