Upgrade to Pro — share decks privately, control downloads, hide ads and more …

決済基盤の実践話 / Pragmatic Practices of Payment Foundation

mercari
August 25, 2022

決済基盤の実践話 / Pragmatic Practices of Payment Foundation

メルペイリリース時からメルカリグループの各事業を支えられる決済基盤が作られてきました。本セッションでは、決済基盤の構成から、各ドメインコンポネントの紹介、技術観点の課題などを含めてご紹介します。また、プロダクトチームに選ばれる基盤を目指すには日々進化していかないといけないので、今現在チャレンジしていることとこれからの方向性についてもお話したいと思います。
------
Merpay Tech Fest 2022は3日間のオンライン技術カンファレンスです。
IT企業で働くソフトウェアエンジニアおよびメルペイの技術スタックに興味がある方々を対象に2022年8月23日(火)から8月25日(木)までの3日間、開催します。 Merpay Tech Festは事業との関わりから技術への興味を深め、プロダクトやサービスを支えるエンジニアリングを知れるお祭りです。 セッションでは事業を支える組織・技術・課題などへの試行錯誤やアプローチを紹介予定です。お楽しみに!

■イベント関連情報
- 公式ウェブサイト:https://events.merpay.com/techfest-2022/
- 申し込みページ:https://mercari.connpass.com/event/249428/
- Twitterハッシュタグ: #MerpayTechFest
■リンク集
- メルカリ・メルペイイベント一覧:https://mercari.connpass.com/
- メルカリキャリアサイト:https://careers.mercari.com/
- メルカリエンジニアリングブログ:https://engineering.mercari.com/blog/
- メルカリエンジニア向けTwitterアカウント:https://twitter.com/mercaridevjp
- 株式会社メルペイ:https://jp.merpay.com/

mercari

August 25, 2022
Tweet

More Decks by mercari

Other Decks in Technology

Transcript

  1. Core Domains of Payment Foundation 決済処理 QRコード決済 精算 帳簿管理 外部決済機構接続

    クレカ等GW業者様 連携しているパートナー様 銀行接続 iD決済 会計処理 メルカリフリマ Product Services Common Foundation External Services ネット決済 暗号資産 Payment Foundation メルカリshops
  2. ¥ 個人のお客様のお財布・決済アカウント Funds Account 資金移動口座 ¥ Sales Account 売上金口座 P

    Free Point Account 無償ポイント口座 P Prepaid Point Account 有償ポイント口座 D Debt Accounts 債権口座 接続済みクレジットカード (only tokenized data) 接続済み銀行口座 Internal Accounts External Accounts C Credit Accounts 与信口座
  3. S 加盟店様のお財布・決済アカウント Partner Sales Account 未精算売上口座 ¥ Clearing Partner Sales

    Account 精算済み売上口座 D Clearing Partner Debt Account 精算済み債権口座 Internal Accounts 登録済み銀行口座 External Accounts
  4. システム帳簿の仕組み user_id type amount 123456 point 1000 balance_item_ id user_id

    amount remaining time aaaa 123456 1000 400 xxxx bbbb 123456 600 600 xxxx balance_item_id tx_id snapshot_id changes time aaaa txaaa +1000 xxxx aaaa txbbb ssss -200 xxxx aaaa txccc dddd -400 xxxx snapshot_id previous_id balance_item_id remaning created_at sssss aaaa 1000 xxxx dddd sssss aaaa 800 xxxx Account BalanceItem BalanceItemLog BalanceItemSnapshot
  5. Configurable Value Account ¥ Funds Account 資金移動口座 ¥ Sales Account

    売上金口座 P Free Point Account 無償ポイント口座 有効期限 180日 有効期限 180日 消費上限あり 有効期限なし 自動作成しない 自動作成 自動作成 滞留上限あり 属性 挙動 ? New Account 新しい口座種別 滞留上限あり 有効期限なし 滞留上限あり 自動作成 Configurable attributes with less code to support new account
  6. 個人の お客様 19 様々の決済処理 Merpay 個人の お客様 加盟店様 プラットフォー ム加盟店様

    加盟店決済 個人間送金 入出金・債権返済 加盟店売上精算・出金 インセンティブ付与 エスクロー決済 ¥ P D S ¥ D 売上分配 加盟店決済 加盟店売上精算・出金
  7. • 参加者 (Participants) • 支払い側の決済アカウント種別 (Source Payment Accounts) • 受取り側の決済アカウント種別

    (Destination Payment Accounts) • 決済処理を行うためのアクション (Actions of Payment Transaction) 考慮すべき要素
  8. エスクロ決済 (Escrow Payment) 個人の お客様 (Buyer) プラット フォーム 加盟店様 メルカリ

    ¥ P C 支払い CreateEscrow 資金移動口座 ポイント口座 与信口座 S 加盟店売上金口座 個人の お客様 (Seller) 売上金分配 CaptureEscrow S 売上金口座 接続済みクレジットカード ¥ 資金移動口座
  9. 加盟店決済 (Charge Payment) 個人の お客様 加盟店様 ¥ P C 仮処理

    CreateCharge 資金移動口座 ポイント口座 与信口座 S 売上金口座 仮売上 状態 確定処理 CaptureCharge
  10. Orchestration-based Saga with StateMachine Created State A 決済データ保存 State B

    内部残高消費 State C 外部カード決済 State D 決済成功 State E 決済通知 State RB 残高消費取消 State RC カード決済取消 State R 決済失敗 Succee ded Failed 補償処理 Rollback Rollback
  11. Orchestration-based Saga with Workflow SDK Activity: 決済データ保存 wf.Activity(Prepare, req).Execute(ctx) Activity:

    内部残高消費 wf.Activity(Balance, 1000).Execute(ctx) Activity: 外部カード決済 wf.Activity(Card, 500).Execute(ctx) Activity: 決済結果保存 wf.Activity(Update, id).Execute(ctx) Activity: 決済通知 wf.Activity(Notify, id).Execute(ctx) Activity: 残高消費取消 Activity: カード決済取消 補償処理 wf.Workflow(ChargePaymentWorkflow, request).Execute(ctx) Compensate Compensate
  12. 精算処理 決済処理 Payment Service Product Services 会計帳簿 サービス 会計イベント 精算

    サービス データ突合 リコンサイル 売上金クリアリング 売上金セトルメント(振込) 銀行接続 サービス 債権セトルメント (返済) 決済手数料クリアリング 加盟店決済リクエスト 決済イベント 振込リクエスト
  13. 決済処理の整合性の証明問題 決済処理 Payment Service Net Payment Service 加盟店決済リクエスト システム帳簿 サービス

    会計帳簿 サービス 外部決済サービス 精算サービス Code Payment Service 加盟店決済リクエスト 決済リクエスト 決済リクエスト 決済イベント 会計イベント すべての決済リクエストが複数のサービス跨いて正しく処理されたのか?
  14. 処理フローデータのリコンサイル 決済処理 Payment Service Net Payment Service リコンサイル システム帳簿 サービス

    会計帳簿 サービス 外部決済サービス 精算サービス Code Payment Service リコンサイル リコンサイル リコンサイル リコンサイル リコンサイル
  15. Build the Single Source Of True 決済処理 Payment Service システム帳簿

    サービス 外部決済サービス Product Services call external API BFF Service Distributed Processing Tracing Single Source of True for confirming the final results across multiple services Processing Participant Services Consistency Reports 決済リクエスト call API with ProcessingID call API with ProcessingID 1. RegisterProcessing 2. Participant Notification 4. ConsistencyReport ConsistencyReport 3. Reconcile Reconcile Reconcile