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_ACTIONtoPROCESSING. - 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
PROCESSINGtoCOMPLETED. - 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: Merchantm1is initialized with a starting balance of0.INIT m2 10: Merchantm2is initialized with a starting balance of10.CREATE p1 m1 50: Payment Intentp1is created for merchantm1with an amount of50in theREQUIRES_ACTIONstate.ATTEMPT p1: Payment Intentp1transitions fromREQUIRES_ACTIONtoPROCESSING.SUCCEED p1: Payment Intentp1transitions fromPROCESSINGtoCOMPLETED, adding50tom1's balance.CREATE p2 m2 100: Payment Intentp2is created for merchantm2with an amount of100in theREQUIRES_ACTIONstate.ATTEMPT p2: Payment Intentp2transitions fromREQUIRES_ACTIONtoPROCESSING.
Part 2: Additional Commands
1. UPDATE <payment_intent_id> <new_amount>
- Updates the monetary amount of an existing Payment Intent in the
REQUIRES_ACTIONstate. - 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
PROCESSINGstate, 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
COMPLETEDstate. - 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
COMPLETEDstate, 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.

