# Additional setup for trial prepayments

> STEP 2 extra

If you charge a trial prepayment, you need an additional Shopify Flow.

When a trial item is sent back, Shopify creates a return and treats the prepayment as refundable too. This Flow therefore adds the prepayment to the order as a custom item, so that it is counted as an amount that has been paid and does not need to be refunded.

1. [Creating the Flow (importing the file)](#1-creating-the-flow-importing-the-file)
2. [Checking that the Flow works](#2-checking-that-the-flow-works)

## 1. Creating the Flow (importing the file)

Instead of building this Flow by hand, you can create it by importing a Flow file.

1. [Download the Flow file](/files/tbyb/flow_prepaid_trial_return.flow)
2. In the Shopify Flow workflow list, choose **Import** and load the `.flow` file you downloaded
3. Click the edit button on the imported Flow
4. Open the Condition and replace the Selling Plan ID with your own ID

    ![The Flow editor. The Condition under Order paid is outlined in red: Selling plan selling plan id contains gid://shopify/SellingPlan/replace this with your own ID, AND Tags equals 前払金追加済み (prepayment added).](images/02k_condition-selling-plan.png)

    ※If you do not know your Selling Plan ID, contact your account manager

5. Open Send Admin API request (1) and change the prepayment amount (`amount`) and currency (`currencyCode`) to the values you set in [Trial policy settings](./trial-settings.html)

    > **注意: Always check the amount, currency, and quantity**
    >
    > The Flow file ships with default values (3000 / JPY). Change them to your own prepayment amount and currency.
    >
    > This Flow also adds the prepayment `quantity` times for each returned line. If you set a fixed amount in your trial policy, fix `quantity` to `1` in Send Admin API request (1) so that it is added only once per order. If you use a percentage, a fixed amount cannot express the correct prepayment, so please consult your account manager.

    ![The Send Admin API request (1) action (which runs orderEditAddCustomItem), opened. In the mutation input JSON, the amount value (3000 by default) is outlined in red.](images/02k_custom-item-amount.png)

## 2. Checking that the Flow works

1. Place a test trial order
2. Submit a return request and choose "Return" as the preferred resolution
3. Open the order in order management and click **Capture payment**

    ![The Recustomer order detail screen. The Capture payment button below Authorized in the transaction details is outlined in red.](images/02k_capture-payment.png)

4. Check that Shopify Flow runs and adds a "前払金" (prepayment) custom item to the original order

    **Before the Flow runs**: the prepayment is treated as refundable and the order shows that a refund is due to the customer

    ![The Shopify order screen before the Flow runs. A banner says that a refund of ¥3,000 is due to the customer because the order was edited.](images/02k_flow-before.png)

    **After the Flow runs**: a "前払金" (prepayment) custom item is added to the order and the refund notice disappears

    ![The Shopify order screen after the Flow runs. A custom item, 前払金 (prepayment) ¥3,000 × 1, has been added to the unfulfilled section and is outlined in red.](images/02k_flow-after.png)
