|
| 1 | +Wise Payouts |
| 2 | +============ |
| 3 | + |
| 4 | +This section explains how the `PromoterPayoutService` handles sending payouts via Wise to eligible promoters. |
| 5 | + |
| 6 | +1. Sending Wise Payouts |
| 7 | +------------------------ |
| 8 | + |
| 9 | +The `send_wise_csv_for_promoters_payouts` method is responsible for generating a CSV file for Wise payouts and processing payouts for eligible promoters. It checks which promoters have a balance that meets or exceeds their minimum withdrawal amount and creates payouts for those promoters. |
| 10 | + |
| 11 | +- **Method**: `send_wise_csv_for_promoters_payouts` |
| 12 | + |
| 13 | +.. code-block:: python |
| 14 | +
|
| 15 | + promoter_payout_service.send_wise_csv_for_promoters_payouts() |
| 16 | +
|
| 17 | +### Example |
| 18 | + |
| 19 | +Assume a promoter has a balance of $100, which meets or exceeds their minimum withdrawal balance of $50. The system will generate a Wise payout for that promoter and include the following data in the CSV file: |
| 20 | + |
| 21 | +.. code-block:: csv |
| 22 | +
|
| 23 | + name,recipientEmail,amount,sourceCurrency,targetCurrency,amountCurrency,type |
| 24 | + John Doe,[email protected],100.00,USD,USD,target,EMAIL |
| 25 | +
|
| 26 | +### Key Points: |
| 27 | + |
| 28 | +- **Payout Method**: The `payout_method` for these payouts is set to `'wise'`, and the `EMAIL` type is used, meaning payouts are processed based on the recipient’s email address. |
| 29 | +- **Currency**: The payout currency is set to USD by default, but it can be changed by passing additional arguments to the method. |
| 30 | +- **Balance Check**: Only promoters with a balance greater than or equal to their `min_withdrawal_balance` will be included in the payout. |
| 31 | + |
| 32 | +2. CSV Generation |
| 33 | +------------------ |
| 34 | + |
| 35 | +The method generates the CSV data for Wise using a pandas DataFrame. The resulting CSV string can be sent to Wise for processing. |
| 36 | + |
| 37 | +### Example CSV Data |
| 38 | + |
| 39 | +.. code-block:: csv |
| 40 | +
|
| 41 | + name,recipientEmail,amount,sourceCurrency,targetCurrency,amountCurrency,type |
| 42 | + Jane Smith,[email protected],150.00,USD,USD,target,EMAIL |
| 43 | + John Doe,[email protected],100.00,USD,USD,target,EMAIL |
| 44 | +
|
| 45 | +This CSV file contains all the necessary information to process payouts through Wise, ensuring that the correct amount is paid to the corresponding recipient via email. |
| 46 | + |
| 47 | +3. Payout Creation |
| 48 | +------------------- |
| 49 | + |
| 50 | +After generating the payout data, the service automatically creates a payout record for each eligible promoter and marks their pending commissions as paid. |
| 51 | + |
| 52 | +- **Method**: `create_payout` |
| 53 | + |
| 54 | +.. code-block:: python |
| 55 | +
|
| 56 | + promoter_payout_service.create_payout( |
| 57 | + promoter=promoter_instance, |
| 58 | + amount=promoter_instance.current_balance, |
| 59 | + payout_method='wise' |
| 60 | + ) |
| 61 | +
|
| 62 | +This method saves a `PromoterPayout` record for each promoter, and any commissions marked as "pending" are updated to "paid". |
| 63 | + |
| 64 | +.. note:: |
| 65 | + |
| 66 | + Ensure that the promoters have a valid payout method (Wise) and that their balance meets the minimum withdrawal requirement to process payouts. The system will skip promoters who do not meet these conditions. |
0 commit comments