Skip to content

Commit

Permalink
feat: add paypal refunds diagram
Browse files Browse the repository at this point in the history
  • Loading branch information
syedsajjadkazmii committed Dec 31, 2024
1 parent 59ab5f8 commit 4c542c2
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
45 changes: 45 additions & 0 deletions docs/arch-diagrams/automatic-refunds.mmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
sequenceDiagram
actor User as User
participant LMS as LMS
participant CC
participant CoCo
participant AWS as AWS EventBridge
participant PSP as Stripe/PayPal

note over User,LMS: User Unenrolls from Course
User ->> LMS: Click on Gear CTA -> Click "Unenroll" -> Answer Question
LMS ->> LMS: Determines Which System to Hit
LMS ->> LMS: Checks Source System of Enrollment Attributes<br>(COMMERCE_COORDINATOR_REFUND_SOURCE_SYSTEMS)

critical Create Refund
LMS ->> CC: Hits RefundView() Endpoint
activate CC
CC ->> CoCo: Create ReturnItemDraft
activate CoCo
CoCo ->> CoCo: Creates LineItemReturnItem
CoCo ->> CoCo: Shipment State Transitions to "Returned"
CoCo ->> CoCo: Payment State Transitions to "Initial"
CoCo -->> CC: Response
deactivate CoCo
CC -->> LMS: Response
deactivate CC
end

CoCo ->> AWS: Emits LineItemReturnItem Subscription Message
AWS ->> CC: Hits OrderReturnedView() Endpoint
CC ->> CC: Receives message from CoCo via AWS EventBridge <br> with details of ReturnItem
CC ->> CC: Triggers fulfill_order_returned_signal<br> worker_task
CC ->> PSP: Issue Credit
activate PSP
PSP -->> CC: Response
deactivate PSP
CC ->> CoCo: Add Refund Transaction to Payment Obj
activate CoCo
CoCo -->> CC: Response
deactivate CoCo
CC ->> CoCo: Update Refund Status
activate CoCo
CoCo -->> CC: Response
deactivate CoCo
note over User,LMS: LMS Unenrolls User
LMS -->> User: Removes Course from Dashboard
23 changes: 23 additions & 0 deletions docs/arch-diagrams/manual-refunds.mmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
sequenceDiagram
actor Support
participant CoCo
participant AWS EventBridge
participant Commerce Coordinator
participant PSP as Stripe/PayPal
Support->>CoCo: Create ReturnItem
CoCo->>AWS EventBridge: Emits LineItemReturnItem Subscription Message
AWS EventBridge->>Commerce Coordinator: Hits OrderReturnedView() Endpoint
Commerce Coordinator->>Commerce Coordinator: Receives message from CoCo via AWS EventBridge<br> with details of the ReturnItem
Commerce Coordinator->>Commerce Coordinator: Triggers fulfill_order_returned_signal<br> worker task
Commerce Coordinator->>PSP: Issue Credit
activate PSP
PSP-->>Commerce Coordinator: Response
deactivate PSP
Commerce Coordinator->>CoCo: Add Refund Transaction to Payment Obj
activate CoCo
CoCo-->>Commerce Coordinator: Response
deactivate CoCo
Commerce Coordinator->>CoCo: Update Refund Status
activate CoCo
CoCo-->>Commerce Coordinator: Response
deactivate CoCo
17 changes: 17 additions & 0 deletions docs/arch-diagrams/webhook-refunds.mmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
sequenceDiagram
actor Support
participant PSP as Stripe/PayPal
participant CC as Commerce Coordinator
participant CoCo
note over Support, PSP: Support Issues Refund<br>from PSP Dashboard
Support ->> PSP: Issue Refund
activate PSP
PSP -->> PSP: Issues Refund to User
PSP -->> PSP: Triggers refund Webhook
PSP ->> CC: Hits WebhookView() Endpoint
deactivate PSP
activate CC
CC -->> CC: Sends payment_refunded_signal<br> signal
CC -->> CC: Triggers refund_from_stripe_task<br> worker task
CC ->> CoCo: Adds Refund Transaction<br> to Payment Obj
deactivate CC

0 comments on commit 4c542c2

Please sign in to comment.