Payment Processing Command Overvie
Part 1: Core Commands
1. INIT <merchant_id> <starting_balance>
- Initializes a merchant with a unique identifier string and starting balance (the amount of money in their account).
- Behavior:
- If a merchant with the given identifier already exists, this command does nothing.
2. CREATE <payment_intent_id> <merchant_id> <amount>
- Creates a Payment Intent for a merchant with a specified amount.
- Initial State:
REQUIRES_ACTION
- Behavior:
- If a Payment Intent with the given identifier already exists, or if the merchant does not exist, or if the amount is negative, this command does nothing.
3. ATTEMPT <payment_intent_id>
- Transitions a Payment Intent from
REQUIRES_ACTION
toPROCESSING
. - Behavior:
- If no Payment Intent with the given identifier exists, or if the state of the Payment Intent is not
REQUIRES_ACTION
, this command does nothing.
- If no Payment Intent with the given identifier exists, or if the state of the Payment Intent is not
4. SUCCEED <payment_intent_id>
- Transitions a Payment Intent from
PROCESSING
toCOMPLETED
. - Behavior:
- If no Payment Intent with the given identifier exists, or if the state of the Payment Intent is not
PROCESSING
, this command does nothing.
- If no Payment Intent with the given identifier exists, or if the state of the Payment Intent is not
Example Input and Output
Input:
INIT m1 0
INIT m2 10
CREATE p1 m1 50
ATTEMPT p1
SUCCEED p1
CREATE p2 m2 100
ATTEMPT p2
Output:
m1 50
m2 10
Explanation:
INIT m1 0
: Merchantm1
is initialized with a starting balance of0
.INIT m2 10
: Merchantm2
is initialized with a starting balance of10
.CREATE p1 m1 50
: Payment Intentp1
is created for merchantm1
with an amount of50
in theREQUIRES_ACTION
state.ATTEMPT p1
: Payment Intentp1
transitions fromREQUIRES_ACTION
toPROCESSING
.SUCCEED p1
: Payment Intentp1
transitions fromPROCESSING
toCOMPLETED
, adding50
tom1
's balance.CREATE p2 m2 100
: Payment Intentp2
is created for merchantm2
with an amount of100
in theREQUIRES_ACTION
state.ATTEMPT p2
: Payment Intentp2
transitions fromREQUIRES_ACTION
toPROCESSING
.
Part 2: Additional Commands
1. UPDATE <payment_intent_id> <new_amount>
- Updates the monetary amount of an existing Payment Intent in the
REQUIRES_ACTION
state. - Behavior:
- If no Payment Intent with the given identifier exists, or if the state of the Payment Intent is not
REQUIRES_ACTION
, or if the new amount is negative, this command does nothing.
- If no Payment Intent with the given identifier exists, or if the state of the Payment Intent is not
Part 3: Advanced Commands
1. FAIL <payment_intent_id>
- Fails a Payment Intent in the
PROCESSING
state, transitioning it back toREQUIRES_ACTION
. - Behavior:
- If no Payment Intent with the given identifier exists, or if the state of the Payment Intent is not
PROCESSING
, this command does nothing.
- If no Payment Intent with the given identifier exists, or if the state of the Payment Intent is not
2. REFUND <payment_intent_id>
- Processes a refund for a previously successful Payment Intent in the
COMPLETED
state. - Effect: Decreases the merchant's balance by the amount of the Payment Intent to return the funds to the customer.
- Behavior:
- If no Payment Intent with the given identifier exists, or if the Payment Intent is not in the
COMPLETED
state, or if the Payment Intent has already been refunded, this command does nothing.
- If no Payment Intent with the given identifier exists, or if the Payment Intent is not in the
我们长期稳定承接各大科技公司如TikTok、Google、Amazon等的OA笔试代写服务,确保满分通过。如有需求,请随时联系我们。
We consistently provide professional online assessment services for major tech companies like TikTok, Google, and Amazon, guaranteeing perfect scores. Feel free to contact us if you're interested.