宿泊 v1

examples/hotel/temporal/hotel.ja.flow · dandori doc

宿泊の予約を受けたらカードに与信を取り、チェックアウトの日に売上を確定する。与信の額と、フロントが先に確認するかどうかは規則が決め、決済は Stripe の PaymentIntent で行う。Temporal 向けの版:Stripe の呼び出しは dandori が生成するアクティビティで、秘密鍵は Transport が付ける。お客さまの 3-D セキュアの手続きが済んだことは、Stripe の Webhook が予約の ID を宛先にして知らせる(event)。お客さまが予約を取り消すと、与信も取り消す(on cancel)

flow
repeat at most 12 times確認自動on カード拒否requires_actionon timeoutrequires_capture,requires_payment_method,requires_confirmation,canceledrequires_capturerequires_payment_method,requires_confirmation,requires_actionon 状態の不一致canceledon 状態の不一致succeededprocessingsucceeded,requires_payment_methodprocessing12 回終えたらsucceededprocessing,requires_payment_method宿泊 v175 見積 = 与信(…)rule 宿泊の与信額.ruletimeout, failure → on failure!76 match 見積.扱い77 succeed 結果 = 確認待ち78 決済 ← 決済を作る(…)POST stripe /v1/payment_intentsstarts · retry 2 times every 2 secondstimeout, failure → on failure!79 決済 ← 与信を取る(…)POST stripe /v1/payment_intents/{intent}/confirmsends confirmカード拒否 → 80 行目; 状態の不一致, timeout, failure → on failure!80 決済 ← 決済を見る(…)GET stripe /v1/payment_intents/{intent}observes · retry 3 times every 2 secondstimeout, failure → on failure!81 match 決済.status83 決済 ← 本人認証の知らせ()eventobserves · timeout 1 hourtimeout → 84 行目; failure → on failure!84 決済 ← 決済を見る(…)GET stripe /v1/payment_intents/{intent}observes · retry 3 times every 2 secondstimeout, failure → on failure!86 match 決済.status87 wait until 予約.チェックアウト89 決済 ← 与信を取り消す(…)POST stripe /v1/payment_intents/{intent}/cancelsends cancel状態の不一致 → 90 行目; timeout, failure → on failure!91 fail 与信不可"カードの与信が取れませんでした"92 fail 決済の取消"PaymentIntent が取り消されていました"93 決済 ← 売上を確定する(…)POST stripe /v1/payment_intents/{intent}/capturesends capture · retry 2 times every 5 seconds状態の不一致 → 94 行目; timeout, failure → on failure!94 fail 与信の有効期限切れ"チェックアウトまでに与信の有効期限が切れていました"95 match 決済.status96 succeed 結果 = 宿泊済99 wait 1 hour100 決済 ← 決済を見る(…)GET stripe /v1/payment_intents/{intent}observes · retry 3 times every 2 secondstimeout, failure → on failure!101 match 決済.status103 break104 match 決済.status105 succeed 結果 = 宿泊済106 fail 確定の結果不明"売上の確定の結果が分かりません。担当者に引き渡します"leaving 決済
on failure
requires_payment_method,requires_confirmation,requires_action,requires_captureon 状態の不一致on failureprocessingnone108 on failure109 match 決済.status112 決済 ← 与信を取り消す(…)POST stripe /v1/payment_intents/{intent}/cancelsends cancel113 fail 取消の失敗"Stripe が与信の取消を拒否しました。売上が確定しているかもしれません。担当者に引き渡し…leaving 決済114 fail 取消の失敗"与信を取り消せませんでした。担当者に引き渡します"leaving 決済115 fail 確定の結果不明"売上の確定の途中で失敗しました。担当者に引き渡します"leaving 決済同じエラーで失敗する
on cancel
requires_payment_method,requires_confirmation,requires_action,requires_captureon 状態の不一致on failureprocessingnone118 on cancel119 match 決済.status122 決済 ← 与信を取り消す(…)POST stripe /v1/payment_intents/{intent}/cancelsends cancel123 fail 取消の失敗"Stripe が与信の取消を拒否しました。売上が確定しているかもしれません。担当者に引き渡し…leaving 決済124 fail 取消の失敗"与信を取り消せませんでした。担当者に引き渡します"leaving 決済125 fail 確定の結果不明"売上の確定の途中でキャンセルされました。担当者に引き渡します"leaving 決済キャンセルで終わる

呼び出し

行呼び出し呼ぶものリトライタイムアウト失敗したとき呼び出しのあとの案件
75見積 = 与信(…)規則 宿泊の与信額.rule1 秒後と 2 秒後の 2 回(failure)—timeout・failure → on failure—
78決済 ← 決済を作る(…)POST stripe /v1/payment_intents・starts payment_intent.payment then attach・key2 秒おきに 2 回(failure・timeout)—timeout・failure → on failure決済: requires_confirmation
79決済 ← 与信を取る(…)POST stripe /v1/payment_intents/{intent}/confirm・sends confirm・key——カード拒否 → 80 行目
状態の不一致・timeout・failure → on failure
決済: requires_payment_method・requires_action・requires_capture・canceled
80決済 ← 決済を見る(…)GET stripe /v1/payment_intents/{intent}・observes・idempotent2 秒おきに 3 回(failure・timeout)—timeout・failure → on failure決済: requires_payment_method・requires_confirmation・requires_action・requires_capture・canceled
83決済 ← 本人認証の知らせ()event・observes—1 時間timeout → 84 行目
failure → on failure
決済: requires_payment_method・requires_action・requires_capture・canceled
84決済 ← 決済を見る(…)GET stripe /v1/payment_intents/{intent}・observes・idempotent2 秒おきに 3 回(failure・timeout)—timeout・failure → on failure決済: requires_payment_method・requires_action・requires_capture・canceled
89決済 ← 与信を取り消す(…)POST stripe /v1/payment_intents/{intent}/cancel・sends cancel・key——状態の不一致 → 90 行目
timeout・failure → on failure
決済: canceled
93決済 ← 売上を確定する(…)POST stripe /v1/payment_intents/{intent}/capture・sends capture・key5 秒おきに 2 回(failure・timeout)—状態の不一致 → 94 行目
timeout・failure → on failure
決済: processing・succeeded
100決済 ← 決済を見る(…)GET stripe /v1/payment_intents/{intent}・observes・idempotent2 秒おきに 3 回(failure・timeout)—timeout・failure → on failure決済: requires_payment_method・processing・succeeded
112決済 ← 与信を取り消す(…)POST stripe /v1/payment_intents/{intent}/cancel・sends cancel・key——状態の不一致 → 113 行目
timeout・failure → 114 行目
決済: canceled
122決済 ← 与信を取り消す(…)POST stripe /v1/payment_intents/{intent}/cancel・sends cancel・key——状態の不一致 → 123 行目
timeout・failure → 124 行目
決済: canceled

終わり方

行終わり方決済
77succeed 結果 = 確認待ち始まっていない
91fail 与信不可 "カードの与信が取れませんでした"canceled
92fail 決済の取消 "PaymentIntent が取り消されていました"canceled
94fail 与信の有効期限切れ "チェックアウトまでに与信の有効期限が切れていました"canceled
96succeed 結果 = 宿泊済succeeded
105succeed 結果 = 宿泊済succeeded
106fail 確定の結果不明 "売上の確定の結果が分かりません。担当者に引き渡します" leaving 決済そのまま引き渡す: requires_payment_method・processing・succeeded
113fail 取消の失敗 "Stripe が与信の取消を拒否しました。売上が確定しているかもしれません。担当者に引き渡します" leaving 決済そのまま引き渡す: requires_payment_method・processing・succeeded・canceled
114fail 取消の失敗 "与信を取り消せませんでした。担当者に引き渡します" leaving 決済そのまま引き渡す: requires_payment_method・requires_confirmation・requires_action・processing・requires_capture・succeeded・canceled
115fail 確定の結果不明 "売上の確定の途中で失敗しました。担当者に引き渡します" leaving 決済そのまま引き渡す: requires_payment_method・processing・succeeded
115on failure が最後まで走り、ワークフローは元のエラーで失敗する始まっていないか、canceled
123fail 取消の失敗 "Stripe が与信の取消を拒否しました。売上が確定しているかもしれません。担当者に引き渡します" leaving 決済そのまま引き渡す: requires_payment_method・processing・succeeded・canceled
124fail 取消の失敗 "与信を取り消せませんでした。担当者に引き渡します" leaving 決済そのまま引き渡す: requires_payment_method・requires_confirmation・requires_action・processing・requires_capture・succeeded・canceled
125fail 確定の結果不明 "売上の確定の途中でキャンセルされました。担当者に引き渡します" leaving 決済そのまま引き渡す: requires_payment_method・processing・succeeded
125on cancel が最後まで走り、ワークフローはキャンセルで終わる始まっていないか、canceled