---
# System prepended metadata

title: mPOS / TDL_PAY (Payment Logging)
tags: [mPOS]

---

---
tags: mPOS
---

# mPOS / TDL_PAY (Payment Logging)

[toc]

## /pr/payment
### Sequence Diagram
```plantuml
@startuml
skinparam default {
    FontSize 12
}
skinparam sequence {
    MessageAlign center
    LifelineBorderColor grey
}
skinparam lifelineStrategy nosolid
participant "mPOS/iPad" As pos 


participant RPi As rpi
'boundary    boundary    as Foo2
'control     control     as Foo3
'entity      entity      as Foo4
box "SC DB" #LightBlue
database    TDL_PAY  
database    "THD + TDL" As thdtdl
end box

box "External"
participant PaymentRouter As PR 
end box
'collections collections as Foo6
'queue       queue       as Foo7



pos -> rpi : POST /pr/payment
activate rpi

rpi -> PR : POST /payment
activate PR

PR --> rpi : /payment Result
deactivate PR

alt #transparent Payment SUCCESS  
  rpi -> TDL_PAY : <b>Insert New PaymentLog
  activate TDL_PAY
  rnote  right of rpi
  <#lightblue>|= bank_ordno |= op_func |
  <#lightgreen>| <font size="16"><b><ordNo> | <font size="16"><b>4 |
  
  <#lightblue>|= card_no |= term_no |= part_cut |
  <#lightgreen>| <creditCardNo> | 0025  | <part_cut> |
  
  <#lightblue>|=  amt  |= update8time6  |
  <#lightgreen>| <amount> | <YYYYMMDDHH24MISS> |
  
  end rnote 
  TDL_PAY --> rpi : Insert Result
  deactivate TDL_PAY
end
rpi --> pos : /pr/payment Result
deactivate rpi
...
rnote  over rpi, bank
3-D Secure process...
end rnote 
...
pos -> rpi : POST /pr/postback
activate rpi

rpi -> PR : POST /callback
activate PR

PR --> rpi : /callback Result
deactivate PR

alt #transparent /callback SUCCESS
  rpi -> TDL_PAY : <b>Update PaymentLog
  activate TDL_PAY
  rnote  right of rpi
    <#lightblue>|= card_no |=  auth_no |
    <#lightgreen>| <creditCardNo> | <approveCode>  |
    
    <#lightblue>|=  amt  |= update8time6  |
    <#lightgreen>| <amount> | <YYYYMMDDHH24MISS> |
  end rnote 
  TDL_PAY --> rpi : Update Result
  deactivate TDL_PAY
end
rpi --> pos : /pr/postback Result
deactivate rpi
...
pos -> rpi : POST /transaction
activate rpi
rpi -> thdtdl :  <b>   Insert New Transaction (OP_FUNC=4)
activate thdtdl
thdtdl --> rpi :    Insert Result
deactivate thdtdl
alt #transparent Transaction Insert SUCCESS
  rpi -> TDL_PAY : <b>  Merge PaymentLog with THD
  activate TDL_PAY
  rnote  right of rpi
    <#lightblue>|=  store_no |=  serial_no  |= tdate |= subtot |
    <#lightgreen>| <storeNo> | <serialNo>  | <YYYYMMDD> | <subtotal> |
    
    <#lightblue>|=  sys_date |=  ttime  |= pterm_no |
    <#lightgreen>|  <YYYYMMDD>  | <HH24MISS>  | 07050025 |
  end rnote 
  TDL_PAY --> rpi :    Merge Result
  deactivate TDL_PAY
end

rpi --> pos : /transaction Result
deactivate rpi
'pos -> Foo2 : To boundary
'pos -> Foo3 : To control
'pos -> Foo4 : To entity
'pos -> Foo5 : To database
'pos -> Foo6 : To collections
'pos -> Foo7: To queue
@enduml
``` 

### Completion Verification

|| bank_ordno | op_func | term_no | amt | part_cut | auth_no | serial_no, tdate, ... |
|-| - |- | - | - | - | - |-|
|授權 未完成| &#10004;&#65039;  | &#10004;&#65039; | &#10004;&#65039; | &#10004;&#65039; |  &#10004;&#65039;  | &#10060; | &#10060; |
|授權 3D完成| &#10004;&#65039;  | &#10004;&#65039; | &#10004;&#65039; | &#10004;&#65039; | &#10004;&#65039;    | &#10004;&#65039;   | &#10060; |
|授權+交易完成| &#10004;&#65039; | &#10004;&#65039; | &#10004;&#65039; | &#10004;&#65039; | &#10004;&#65039;    | &#10004;&#65039;   |&#10004;&#65039;  |

---

## /pr/cancel
### Sequence Diagram
```plantuml
@startuml
skinparam default {
    FontSize 12
}
skinparam sequence {
    MessageAlign center
    LifelineBorderColor grey
}
skinparam lifelineStrategy nosolid
participant "mPOS/iPad" As pos 
participant RPi As rpi

'participant RPi.PaymentLogging As rpiLog
'boundary    boundary    as Foo2
'control     control     as Foo3
'entity      entity      as Foo4
box "SC DB" #LightBlue
database    TDL_PAY  
database    "THD + TDL" As thdtdl
end box

box "External"
participant PaymentRouter As PR 
end box
'collections collections as Foo6
'queue       queue       as Foo7

pos -> rpi++ : POST /pr/cancel


rpi -> PR++ : POST /cancel
PR --> rpi-- : /cancel Result
opt #transparent /cancel SUCCESS
  rpi -> PR++ : POST /query
  PR --> rpi-- : /query Result
  rpi -> TDL_PAY++ : <b>Insert New PaymentLog 
  rnote right of rpi
    <#lightblue>|= bank_ordno |= op_func |
    <#lightgreen>| <font size="16"><b><ordNo> | <font size="16"><b>8 |

    <#lightblue>|= term_no |= update8time6 |
    <#lightgreen>| 0025 | <YYYYMMDDHH24MISS> |
    
    <#lightblue>|= card_no |= auth_no  |
    <#lightgreen>| <creditCardNo> | <approveCode> |

    <#lightblue>|= amt |
    <#lightgreen>| <amount> * -1 |
    
    <#lightblue>|= update8time6 |
    <#lightgreen>| <YYYYMMDDHH24MISS> |
    
  end rnote 
  TDL_PAY --> rpi-- : Insert Result
end

rpi --> pos-- : /pr/cancel Result
...
pos -> rpi++ : POST /transaction/void
rpi -> thdtdl++ :  <b>   Insert New Transaction (OP_FUNC=8)
thdtdl --> rpi-- :    Insert Result
opt #transparent Transaction Insert SUCCESS
  rpi -> TDL_PAY++ : <b>  Merge PaymentLog with THD
  rnote  right of rpi
    <#lightblue>|=  store_no |=  serial_no |
    <#lightgreen>| <storeNo> | <serialNo> |
    
    <#lightblue>|= tdate |= subtot |
    <#lightgreen>| <YYYYMMDD> | <subtotal> |
    
    <#lightblue>|=  sys_date |= ttime |
    <#lightgreen>|  <YYYYMMDD>  | <HH24MISS> |
    
    <#lightblue>|= pterm_no |
    <#lightgreen>| 07050025 |
    
  end rnote 
  TDL_PAY --> rpi-- :    Merge Result
end

rpi --> pos-- : /transaction/void Result
'pos -> Foo2 : To boundary
'pos -> Foo3 : To control
'pos -> Foo4 : To entity
'pos -> Foo5 : To database
'pos -> Foo6 : To collections
'pos -> Foo7: To queue
@enduml
``` 

### Completion Verification

|| bank_ordno | op_func | term_no | auth_no | amt | serial_no, tdate, ... |
|-| - |- | - | - | - | - |
|退授權 未完成| &#10060;  | &#10060; | &#10060; |  &#10060;    |  &#10060;  | &#10060; |
|退授權完成| &#10004;&#65039;  | &#10004;&#65039; | &#10004;&#65039; | &#10004;&#65039;    | &#10004;&#65039;   | &#10060; |
|退授權+銷退完成| &#10004;&#65039;  | &#10004;&#65039; | &#10004;&#65039; | &#10004;&#65039;    | &#10004;&#65039;   |&#10004;&#65039;  |
