[Stripe] 2025 Start – 14 Dec OA

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 to PROCESSING.
  • 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.

4. SUCCEED <payment_intent_id>

  • Transitions a Payment Intent from PROCESSING to COMPLETED.
  • 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.

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:

  1. INIT m1 0: Merchant m1 is initialized with a starting balance of 0.
  2. INIT m2 10: Merchant m2 is initialized with a starting balance of 10.
  3. CREATE p1 m1 50: Payment Intent p1 is created for merchant m1 with an amount of 50 in the REQUIRES_ACTION state.
  4. ATTEMPT p1: Payment Intent p1 transitions from REQUIRES_ACTION to PROCESSING.
  5. SUCCEED p1: Payment Intent p1 transitions from PROCESSING to COMPLETED, adding 50 to m1's balance.
  6. CREATE p2 m2 100: Payment Intent p2 is created for merchant m2 with an amount of 100 in the REQUIRES_ACTION state.
  7. ATTEMPT p2: Payment Intent p2 transitions from REQUIRES_ACTION to PROCESSING.

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.

Part 3: Advanced Commands

1. FAIL <payment_intent_id>

  • Fails a Payment Intent in the PROCESSING state, transitioning it back to REQUIRES_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.

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.

我们长期稳定承接各大科技公司如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.

Leave a Reply

Your email address will not be published. Required fields are marked *