Skip to content

Commit

Permalink
docs: Updated PayBC Sequence and State Diagrams (#1149)
Browse files Browse the repository at this point in the history
  • Loading branch information
john-fletcher-aot authored Feb 6, 2024
1 parent 596148e commit 77f9e96
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 19 deletions.
39 changes: 20 additions & 19 deletions common/payment/PayBC Sequence.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,33 @@

```mermaid
sequenceDiagram
participant Browser
participant onRouteBC
participant PayBC
participant CFS
Browser->>onRouteBC: Request to pay for permit
onRouteBC->>PayBC: Generate token
note over onRouteBC,PayBC: Supply client id and secret
PayBC-->>onRouteBC: Send bearer token
onRouteBC->>onRouteBC: Generate transaction number
onRouteBC->>onRouteBC: Save transaction number to DB
onRouteBC->>onRouteBC: Set permit status to 'WAITING FOR PAYMENT'
onRouteBC->>onRouteBC: Set permit status to 'WAITING_PAYMENT'
onRouteBC-->>Browser: Send redirect to PayBC
Browser->>PayBC: Forward to payment page
note over Browser,PayBC: Include all transaction details such as<br/>transaction number, amount, and auth token
PayBC-->>Browser: Display payment details form
Browser->>PayBC: Supply payment information (credit card)
PayBC->>PayBC: Process payment
note over PayBC: Assume for this diagram<br/>that the payment is<br/>successful
PayBC-->>Browser: Send redirect with details of transaction
Browser->>PayBC: Forward to PayBC
note over Browser,PayBC: Include all transaction details such as<br/>transaction number, amount, hash, etc.
PayBC->>PayBC: Record transaction
PayBC-->>Browser: Send redirect to Bambora
Browser->>Bambora: /payment.asp
Bambora-->>Browser: Display payment details form
Browser->>Bambora: Supply payment details (credit card)
Bambora-->>Browser: Send redirect to /process_transaction.asp
Browser->>Bambora: /process_transaction.asp
note over Bambora: Assume for this diagram<br/>that the payment is<br/>successful
Bambora->>Bambora: Charge credit card
Bambora-->>Browser: Send redirect to PayBC
note over Browser,PayBC: Includes auto-generated receipt number, transaction ID,<br/>and hash value to verify transaction integrity
Browser->>onRouteBC: Forward to transaction<br/>confirmation URL
onRouteBC->>onRouteBC: Verify transaction hash
Browser->>PayBC: /public/paysuccess
PayBC-->>Browser: Send redirect to alternate PayBC URL
Browser->>PayBC: /public/directsale/paysuccess
PayBC->>PayBC: Record transaction result
PayBC-->>Browser: Send redirect to onRouteBC
Browser->>onRouteBC: /payment
Note over Browser,onRouteBC: This is the original redirect URI
note over onRouteBC: Assume for this diagram<br/>that the transaction hash<br/>is valid
onRouteBC->>onRouteBC: Save transaction details to DB
onRouteBC->>onRouteBC: Issue permit
note over Browser,PayBC: Permit issuance includes setting permit status to 'ISSUED',<br/>generating the permit and payment receipt PDFs, and sending the<br/>permit to the applicant via email.<br/>Note that we issue the permit at this stage instead of after the CFS<br/>stage because the payment has been collected, and there may be<br/>periods of time when CFS is not available and we need to defer the<br/>CFS step to a later time.
onRouteBC->>CFS: Record transaction
note over onRouteBC,CFS: Refer to the CFS Sequence Diagram for details
```
64 changes: 64 additions & 0 deletions common/payment/PayBC State.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# PayBC State Diagram for Payment

```mermaid
stateDiagram-v2
s1: onRouteBC - Pending<br/>PayBC - Unknown<br/>Bambora - Unknown
s2: onRouteBC - Pending<br/>PayBC - Pending<br/>Bambora - Unknown
s3: onRouteBC - Pending<br/>PayBC - Pending<br/>Bambora - Pending
s4: onRouteBC - Pending<br/>PayBC - Pending<br/>Bambora - Declined
s5: onRouteBC - Pending<br/>PayBC - Pending<br/>Bambora - Approved
s6: onRouteBC - Pending<br/>PayBC - Declined<br/>Bambora - Declined
s7: onRouteBC - Pending<br/>PayBC - Approved<br/>Bambora - Approved
s8: onRouteBC - Active<br/>PayBC - Declined<br/>Bambora - Declined
s9: onRouteBC - Issued<br/>PayBC - Approved<br/>Bambora - Approved
state app_decl <<choice>>
[*] --> s1
s1 --> s2
s2 --> s3
s3 --> app_decl
app_decl --> s5 : Approved
s5 --> s7
s7 --> s9
app_decl --> s4 : Declined
s4 --> s6
s6 --> s8
note left of s1
The user has clicked Pay Now
end note
note left of s2
The browser has been redirected to PayBC
end note
note left of s3
The browser has been redirected to Bambora
but the user has not clicked Submit or Cancel
end note
note left of s5
User has clicked submit,
transaction approved by Bambora
end note
note right of s4
User has clicked cancel, or
user has clicked submit but transaction
declined by Bambora
end note
note left of s7
The browser has been redirected to the
PayBC redirect URI and PayBC has processed
the transaction successfully
end note
note right of s6
The browser has been redirected to the
PayBC redirect URI and PayBC has processed
the transaction successfully
end note
note left of s9
The browser has been redirected to the
onRouteBC redirect URI and onRouteBC has
processed the transaction successfully
end note
note right of s8
The browser has been redirected to the
onRouteBC redirect URI and onRouteBC has
processed the transaction successfully
end note
```

0 comments on commit 77f9e96

Please sign in to comment.