Skip to content

Commit

Permalink
Merge pull request #216 from afterpay/docs/payment-diagrams
Browse files Browse the repository at this point in the history
docs: checkout sequence diagrams
  • Loading branch information
ScottAntonacAP authored May 27, 2024
2 parents cf5e89f + 6cc0c9e commit ecf6dd7
Show file tree
Hide file tree
Showing 9 changed files with 300 additions and 86 deletions.
113 changes: 61 additions & 52 deletions docs/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,46 +1,56 @@
GEM
remote: https://rubygems.org/
specs:
activesupport (7.0.5)
activesupport (7.1.3.3)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
addressable (2.8.4)
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
base64 (0.2.0)
bigdecimal (3.1.8)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.11.1)
coffee-script-source (1.12.2)
colorator (1.1.0)
commonmarker (0.23.9)
concurrent-ruby (1.2.2)
dnsruby (1.70.0)
commonmarker (0.23.10)
concurrent-ruby (1.2.3)
connection_pool (2.4.1)
dnsruby (1.72.1)
simpleidn (~> 0.2.1)
drb (2.2.1)
em-websocket (0.5.3)
eventmachine (>= 0.12.9)
http_parser.rb (~> 0)
ethon (0.16.0)
ffi (>= 1.15.0)
eventmachine (1.2.7)
execjs (2.8.1)
faraday (2.7.6)
execjs (2.9.1)
faraday (2.8.1)
base64
faraday-net_http (>= 2.0, < 3.1)
ruby2_keywords (>= 0.0.4)
faraday-net_http (3.0.2)
ffi (1.15.5)
ffi (1.16.3)
forwardable-extended (2.6.0)
gemoji (3.0.1)
github-pages (228)
github-pages-health-check (= 1.17.9)
jekyll (= 3.9.3)
jekyll-avatar (= 0.7.0)
jekyll-coffeescript (= 1.1.1)
gemoji (4.1.0)
github-pages (231)
github-pages-health-check (= 1.18.2)
jekyll (= 3.9.5)
jekyll-avatar (= 0.8.0)
jekyll-coffeescript (= 1.2.2)
jekyll-commonmark-ghpages (= 0.4.0)
jekyll-default-layout (= 0.1.4)
jekyll-feed (= 0.15.1)
jekyll-default-layout (= 0.1.5)
jekyll-feed (= 0.17.0)
jekyll-gist (= 1.5.0)
jekyll-github-metadata (= 2.13.0)
jekyll-github-metadata (= 2.16.1)
jekyll-include-cache (= 0.2.1)
jekyll-mentions (= 1.6.0)
jekyll-optional-front-matter (= 0.3.2)
Expand All @@ -67,28 +77,28 @@ GEM
jekyll-theme-tactile (= 0.2.0)
jekyll-theme-time-machine (= 0.2.0)
jekyll-titles-from-headings (= 0.5.3)
jemoji (= 0.12.0)
kramdown (= 2.3.2)
jemoji (= 0.13.0)
kramdown (= 2.4.0)
kramdown-parser-gfm (= 1.1.0)
liquid (= 4.0.4)
mercenary (~> 0.3)
minima (= 2.5.1)
nokogiri (>= 1.13.6, < 2.0)
rouge (= 3.26.0)
rouge (= 3.30.0)
terminal-table (~> 1.4)
github-pages-health-check (1.17.9)
github-pages-health-check (1.18.2)
addressable (~> 2.3)
dnsruby (~> 1.60)
octokit (~> 4.0)
public_suffix (>= 3.0, < 5.0)
octokit (>= 4, < 8)
public_suffix (>= 3.0, < 6.0)
typhoeus (~> 1.3)
html-pipeline (2.14.3)
activesupport (>= 2)
nokogiri (>= 1.4)
http_parser.rb (0.8.0)
i18n (1.14.1)
i18n (1.14.5)
concurrent-ruby (~> 1.0)
jekyll (3.9.3)
jekyll (3.9.5)
addressable (~> 2.4)
colorator (~> 1.0)
em-websocket (~> 0.5)
Expand All @@ -101,27 +111,27 @@ GEM
pathutil (~> 0.9)
rouge (>= 1.7, < 4)
safe_yaml (~> 1.0)
jekyll-avatar (0.7.0)
jekyll-avatar (0.8.0)
jekyll (>= 3.0, < 5.0)
jekyll-coffeescript (1.1.1)
jekyll-coffeescript (1.2.2)
coffee-script (~> 2.2)
coffee-script-source (~> 1.11.1)
coffee-script-source (~> 1.12)
jekyll-commonmark (1.4.0)
commonmarker (~> 0.22)
jekyll-commonmark-ghpages (0.4.0)
commonmarker (~> 0.23.7)
jekyll (~> 3.9.0)
jekyll-commonmark (~> 1.4.0)
rouge (>= 2.0, < 5.0)
jekyll-default-layout (0.1.4)
jekyll (~> 3.0)
jekyll-feed (0.15.1)
jekyll-default-layout (0.1.5)
jekyll (>= 3.0, < 5.0)
jekyll-feed (0.17.0)
jekyll (>= 3.7, < 5.0)
jekyll-gist (1.5.0)
octokit (~> 4.2)
jekyll-github-metadata (2.13.0)
jekyll-github-metadata (2.16.1)
jekyll (>= 3.4, < 5.0)
octokit (~> 4.0, != 4.4.0)
octokit (>= 4, < 7, != 4.4.0)
jekyll-include-cache (0.2.1)
jekyll (>= 3.7, < 5.0)
jekyll-mentions (1.6.0)
Expand Down Expand Up @@ -192,40 +202,42 @@ GEM
jekyll (>= 3.3, < 5.0)
jekyll-watch (2.2.1)
listen (~> 3.0)
jemoji (0.12.0)
gemoji (~> 3.0)
jemoji (0.13.0)
gemoji (>= 3, < 5)
html-pipeline (~> 2.2)
jekyll (>= 3.0, < 5.0)
kramdown (2.3.2)
kramdown (2.4.0)
rexml
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
liquid (4.0.4)
listen (3.8.0)
listen (3.9.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
mercenary (0.3.6)
mini_portile2 (2.8.2)
mini_portile2 (2.8.6)
minima (2.5.1)
jekyll (>= 3.5, < 5.0)
jekyll-feed (~> 0.9)
jekyll-seo-tag (~> 2.1)
minitest (5.18.0)
nokogiri (1.15.2)
minitest (5.23.1)
mutex_m (0.2.0)
nokogiri (1.15.6)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
octokit (4.25.1)
faraday (>= 1, < 3)
sawyer (~> 0.9)
pathutil (0.16.2)
forwardable-extended (~> 2.6)
public_suffix (4.0.7)
racc (1.7.0)
public_suffix (5.0.5)
racc (1.8.0)
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
rb-inotify (0.11.1)
ffi (~> 1.0)
rexml (3.2.5)
rouge (3.26.0)
rexml (3.2.8)
strscan (>= 3.0.9)
rouge (3.30.0)
ruby2_keywords (0.0.5)
rubyzip (2.3.2)
safe_yaml (1.0.5)
Expand All @@ -237,17 +249,14 @@ GEM
sawyer (0.9.2)
addressable (>= 2.3.5)
faraday (>= 0.17.3, < 3)
simpleidn (0.2.1)
unf (~> 0.1.4)
simpleidn (0.2.3)
strscan (3.1.0)
terminal-table (1.8.0)
unicode-display_width (~> 1.1, >= 1.1.1)
typhoeus (1.4.0)
typhoeus (1.4.1)
ethon (>= 0.9.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unf (0.1.4)
unf_ext
unf_ext (0.0.8.2)
unicode-display_width (1.8.0)

PLATFORMS
Expand Down
3 changes: 3 additions & 0 deletions docs/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ callouts:
info:
title: Info
color: blue

mermaid:
version: "10.9.1"
11 changes: 11 additions & 0 deletions docs/_includes/mermaid_config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
theme: "base",
'themeVariables': {
'primaryColor': '#b2fce4',
'primaryBorderColor': '#dfdfdf',
'lineColor': '#F8B229',
'secondaryColor': '#006100',
'tertiaryColor': '#fff',
'fontFamily': 'system-ui, -apple-system, blinkmacsystemfont, "Segoe UI", roboto, "Helvetica Neue", arial, sans-serif, "Segoe UI Emoji"'
}
}
1 change: 1 addition & 0 deletions docs/_sass/color_schemes/afterpay.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ $feedback-color: rgb(223, 234, 246);
$sidebar-color: $white;
$nav-width: 18.75rem;
$nav-width-md: 18.75rem;
$content-width: 60rem;
4 changes: 4 additions & 0 deletions docs/_sass/custom/custom.scss
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ code {
color: white;
display: inline-block;
padding: 4px;

&.language-mermaid {
display: block;
}
}

img {
Expand Down
77 changes: 77 additions & 0 deletions docs/getting-started/cash-app-pay.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,83 @@ Afterpay.validateCashAppOrder(

The `Approved` state will contain a **Grants list** object associated with it and it can be used with Afterpay's **Immediate Payment Capture** or **Deferred Payment Auth** API. Pass the **grant ID** along with the token to capture/authorize using a server-to-server request.

## Sequence Diagram

The below diagram describes the happy path.

``` mermaid
%%{
init: {
'theme': 'base',
'themeVariables': {
'primaryColor': '#00c846',
'primaryTextColor': '#FFFFFF',
'primaryBorderColor': '#dfdfdf',
'signalTextColor': '#000000',
'signalColor': '#000000',
'secondaryColor': '#006100',
'tertiaryColor': '#fff'
}
}
}%%
sequenceDiagram
participant App
participant Afterpay SDK
participant Cash App Pay SDK
participant Proxy Server
participant Afterpay API
Note over App,Afterpay API: Setup
App->>Afterpay SDK: Configure the SDK
Note over App,Afterpay SDK: Required for setting environment
App->>Cash App Pay SDK: Create Cash App Pay instance
Note over App,Cash App Pay SDK: Ensure same environment<br>as Afterpay SDK config
App->>App: Implement<br>deep linking
App->>Cash App Pay SDK: Register for state updates
Note over App,Afterpay API: Create Customer Request and Capture
App->>Proxy Server: Get Token Request
Proxy Server->>Afterpay API: Create Checkout Request
Note over Proxy Server,Afterpay API: Ensure same environment<br>as Afterpay SDK config<br><br>Request body should<br>contain `isCashAppPay: true`
Afterpay API-->>Proxy Server: Create Checkout Response
Note over Afterpay API,Proxy Server: Body contains a token
Proxy Server-->>App: Get Token Response
App->>Afterpay SDK: Sign the token
Afterpay SDK->>Afterpay API: Token signing request
Afterpay API-->>Afterpay SDK: Token signing response
Afterpay SDK-->>App: Decoded token data
App->>Cash App Pay SDK: Create a customer request
App->>Cash App Pay SDK: Authorize the customer request
App->>Afterpay SDK: Validate the order
App->>Proxy Server: Upon approved state send capture request
Note over App,Proxy Server: Pass the Grant Id (from the approved state)<br>and token in the body
Proxy Server->>Afterpay API: Capture Payment Request
Afterpay API-->>Proxy Server: Capture Payment Response
Proxy Server-->>App: Capture Payment Respnse
App->>App: Handle payment<br>capture response
```

[cash-on-maven]: https://central.sonatype.com/artifact/app.cash.paykit/core/1.0.3/overview
[configure-afterpay]: ../configuring-the-sdk
[sandbox-app]: https://developers.cash.app/docs/api/technical-documentation/sandbox/sandbox-app
Expand Down
Loading

0 comments on commit ecf6dd7

Please sign in to comment.