Skip to content

Commit

Permalink
Merge pull request #281 from afterpay/mmroz/no-cash-docs
Browse files Browse the repository at this point in the history
Update documentation for unhappy path handling
  • Loading branch information
mmroz authored Dec 6, 2024
2 parents 893f973 + 363842f commit e3b9c19
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
12 changes: 10 additions & 2 deletions docs/src/getting-started/cash-app-pay-v3.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ func stateDidChange(to state: CashAppPayState) {
// This Customer Request is in a terminal state and any subsequent actions on this Customer Request will yield an error.
// To retry the customer will need to restart the Customer Request flow.
// You should make sure customers can select other payment methods at this point.
case .redirecting:
// The customer is being redirected to Cash App you can present a loading spinner if desired.
// NOTE: In the event that the customer does not have Cash App installed and navigates back to your app then it is
// up to you to set a reasonable timeout after which you dismiss the loading spinner and treat the Customer Request as failed.
case .integrationError:
// There is an issue with the way you are transitioning between states. Refer to the documentation to ensure you are
// moving between states in the correct order.
Expand Down Expand Up @@ -94,11 +98,11 @@ Your implementation should switch on the `state` parameter and handle the approp
|`approved` |Grants are ready for your backend to use to create a payment.|
|`declined`|Customer has declined the Cash App Pay authorization and must start the flow over or choose a new payment method.|

### Error States

{: .alert }
> Customer Requests can fail for a number of reasons, such as when customer exits the flow prematurely or are declined by Cash App for risk reasons. You must respond to these state changes and be ready to update your UI appropriately.
### Error States

| State | Description |
|:------|:------------|
|`integrationError` |A fixable bug in your integration.|
Expand Down Expand Up @@ -244,6 +248,10 @@ Once the SDK is in the `.readyToAuthorize` state, you can store the associated `

Your app will redirect to Cash App for authorization. When the authorization is completed, your redirect URL will be called and the `RedirectNotification` will post. Then, the SDK will fetch your authorized request and return it to your Observer, as part of the change to the `.approved` state.

### Unhappy Path

If the Customer does not have Cash App installed on their device then they will redirect to a webpage prompting them to download Cash App. In the event the customer does not download Cash App, then the SDK will remain in the `polling` state. The SDK does not handle this edge case and instead it is up to the implementor to set a reasonable timeout and treat the checkout as failed once that timeout is exceeded. It is suggested to dismiss any loading states and restart the Cash App Pay flow as to not block the customer from checking out.

## Step 9: Confirm the Cash App Pay Order

Back in Afterpay, confirm the payment using the `checkoutV3` data from step 5 and the `customerRequest.grant` from step 8:
Expand Down
10 changes: 8 additions & 2 deletions docs/src/getting-started/cash-app-pay.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ func stateDidChange(to state: CashAppPayState) {
// This Customer Request is in a terminal state and any subsequent actions on this Customer Request will yield an error.
// To retry the customer will need to restart the Customer Request flow.
// You should make sure customers can select other payment methods at this point.
case .redirecting:
// The customer is being redirected to Cash App you can present a loading spinner if desired.
// NOTE: In the event that the customer does not have Cash App installed and navigates back to your app then it is
// up to you to set a reasonable timeout after which you dismiss the loading spinner and treat the Customer Request as failed.
case .integrationError:
// There is an issue with the way you are transitioning between states. Refer to the documentation to ensure you are
// moving between states in the correct order.
Expand Down Expand Up @@ -97,11 +101,11 @@ Your implementation should switch on the `state` parameter and handle the approp
|`approved` |Grants are ready for your backend to use to create a payment.|
|`declined`|Customer has declined the Cash App Pay authorization and must start the flow over or choose a new payment method.|

### Error States

{: .alert }
> Customer Requests can fail for a number of reasons, such as when customer exits the flow prematurely or are declined by Cash App for risk reasons. You must respond to these state changes and be ready to update your UI appropriately.
### Error States

| State | Description |
|:------|:------------|
|`integrationError` |A fixable bug in your integration.|
Expand Down Expand Up @@ -231,7 +235,9 @@ Once the SDK is in the `.readyToAuthorize` state, you can store the associated `

Your app will redirect to Cash App for authorization. When the authorization is completed, your redirect URL will be called and the `RedirectNotification` will post. Then, the SDK will fetch your authorized request and return it to your Observer, as part of the change to the `.approved` state.

### Unhappy Path

If the Customer does not have Cash App installed on their device then they will redirect to a webpage prompting them to download Cash App. In the event the customer does not download Cash App, then the SDK will remain in the `polling` state. The SDK does not handle this edge case and instead it is up to the implementor to set a reasonable timeout and treat the checkout as failed once that timeout is exceeded. It is suggested to dismiss any loading states and restart the Cash App Pay flow as to not block the customer from checking out.

### Step 6B: Validate the Cash App Pay Order

Expand Down

0 comments on commit e3b9c19

Please sign in to comment.