camaraproject / CarrierBillingCheckOut

Repository to describe, develop, document and test the Carrier Billing Check Out API family
Apache License 2.0
9 stars 9 forks source link

[Optional] validate Payment procedure in 2-STEP #116

Closed PedroDiez closed 6 months ago

PedroDiez commented 8 months ago

Problem description There can be the business scenario of 2-STEP payment where a specific payment needs to be validated. In TEF we have this scenario in ES and DE Telcos so far.

It is also understood this situation cannot (be) exists in other Telcos/countries, so we propose a way to have this feature as an optional one, so it does not compromise/impose additional logic to a Telco/Country that does not use/require it.

Possible evolution Proposal is the following:

Some Basis for the proposal: 1) Not needed in 1-STEP.

2) Only used in 2-STEP Payment when the validation information is provided. So optional due to Business Requirements In preparePayment response, define new param “validationInfo” (name open, maybe be also for instance otpValidation or paymentValidation), with two variants:

image

image

NEW validatePayment endpoint which would have as inputs: o code: OTP received out-of-band o authorizationId, as provided by API en preparePayment

Then validatePayment would look something like on this style:

Request image

Response image

Additional Points: confirmPayment we would need and extra Exception for the case the payment is not validated yet

• If preparePayment is SYNC and no validationInfo is present -> state is “reserved” • If preparePayment is SYNC and validationInfo is present -> state is “waiting for validation” -> when validated it transitions to “reserved” • If preparePayment is ASYNC and no validationInfo is present -> status is “processing” -> when process ends it transitions to “reserved” • If preparePayment is ASYNC and validationInfo is present -> state is “waiting for validation” -> when validated it transitions to “reserved”

Additional context N/A

PedroDiez commented 8 months ago

Please @bigludo7, @rartych, @mohamedsaeedstc take a look to it, in order for the next meeting, any initial doubt/comment is welcome

bigludo7 commented 8 months ago

@PedroDiez The state update seems to be correct but probably good for our next meeting to have an updated version of https://github.com/camaraproject/CarrierBillingCheckOut/blob/main/documentation/API_documentation/resources/Carrier_Billing_State_Engine.JPG to be shown (source here: https://github.com/camaraproject/CarrierBillingCheckOut/blob/main/documentation/API_documentation/resources/Carrier%20Billing%20lifecycle%20source.puml). That will be easier to validate - WDYT?

PedroDiez commented 8 months ago

Hi @bigludo7,

Yes, i will try to provide and updated version on Monday EoB

PedroDiez commented 7 months ago

1. Regarding Transactions (also considering the topic indicated in Issue#116).

For the analysis here, "waiting for validation" will be named as "pending_validation" Will draft image tomorrow (within Issue#116)

1-STEP

2-STEP (validation is optional depending Business Scenario)

FIRST STEP

VALIDATE (OPTIONAL)

SECOND STEP

PedroDiez commented 7 months ago

Source Code:

`@startuml Payment lifecycle

state fork <> state choice <> state end <>

[*] --> choice note left of choice: Business response is provided\nsynchronously or asynchronously

choice --> Processing : Async Processing: Payment request\nis initialised

choice --> fork : Sync Processing --> fork note right of fork: Distinction between 1 step (1S)\nor 2 steps (2S) payment fork: separation between one or stwo steps payment

fork -right-> Succeeded : (1S) Payment\nsuccessfully executed fork -left-> Denied : (1S)/(2S) Payment request\ndenied by carrier

fork --> Pending_Validation : (2S) [Optional] Payment\n validation required fork --> Reserved : (2S) Payment reserved\nsuccessfully executed Pending_Validation -> Reserved: (2S) Payment validated Pending_Validation -> Denied: (2S) Payment not validated

Reserved -down-> Cancelled : (2S) Request to cancel payment\nsuccessfully executed\nor payment reservation expired Reserved -right-> Succeeded : (2S) Payment confirmation\nsuccessfully executed Reserved -left-> Denied : (2S) Confirmation request\ndenied by carrier

Succeeded --> [*] Cancelled --> [*] Denied -up-> end

Pending_Validation: Perform payment validation Reserved: Payment is prepared &\nready to be confirmed.\nAmount is reserved Denied: Payment request is denied\nby back-end payment server Succeeded: Amount has been charged\non customer line Cancelled: Payment is cancelled\nAmount is released

@enduml`

PedroDiez commented 7 months ago

Carrier_Billing_State_Engine_Issue_116

PedroDiez commented 7 months ago

@bigludo7 full analysis done

PedroDiez commented 7 months ago

Let's check tomorrow this comment:

• (1STEP/2STEP) should be added in all transitions (missing on the first 2).

PedroDiez commented 7 months ago

Commented during meeting 21/NOV and aligned to be considered in the next PR.

A prior PR will be handled to update "Payment Lifecycle" diagram

PedroDiez commented 7 months ago

Source Code: (Updated)

`@startuml Payment lifecycle

state fork <> state choice <> state end <>

[*] --> choice note left of choice: Business response is provided\nsynchronously or asynchronously

choice --> Processing : (1S)/(2S) Async Processing: Payment request\nis initialised

choice --> fork : (1S)/(2S) Sync Processing --> fork note right of fork: Distinction between 1 step (1S)\nor 2 steps (2S) payment fork: separation between one or stwo steps payment

fork -right-> Succeeded : (1S) Payment\nsuccessfully executed fork -left-> Denied : (1S)/(2S) Payment request\ndenied by carrier

fork --> Pending_Validation : (2S) [Optional] Payment\n validation required fork --> Reserved : (2S) Payment reserved\nsuccessfully executed Pending_Validation -> Reserved: (2S) Payment validated Pending_Validation -> Denied: (2S) Payment not validated

Reserved -down-> Cancelled : (2S) Request to cancel payment\nsuccessfully executed\nor payment reservation expired Reserved -right-> Succeeded : (2S) Payment confirmation\nsuccessfully executed Reserved -left-> Denied : (2S) Confirmation request\ndenied by carrier

Succeeded --> [*] Cancelled --> [*] Denied -up-> end

Pending_Validation: Perform payment validation Reserved: Payment is prepared &\nready to be confirmed.\nAmount is reserved Denied: Payment request is denied\nby back-end payment server Succeeded: Amount has been charged\non customer line Cancelled: Payment is cancelled\nAmount is released

@enduml`

PedroDiez commented 7 months ago

Sequence Updated:

Payment_lifecycle

bigludo7 commented 7 months ago

Works for me. Thanks !