> ## Documentation Index
> Fetch the complete documentation index at: https://docs.slm.m1amdocs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Creating a Billing Plan with an early cancellation fee

You can create a billing plan that offers a special value but requires a minimum commitment, with an option to charge a fee if the customer cancels the subscription before the commitment is fulfilled. The commitment period is the number of billing cycles required before the customer can cancel the subscription free of charge. You can waive fees, prorate them or collect them in full.

When creating the `BillingPlan`, set the `minimumCommitment` to the number of billing cycles the customer must complete without incurring a cancellation fee, and set the `cancelFees` amount and currency type. Note however that since most subscriptions are paid at the beginning of each cycle, a three-month billing plan, starting on January 1 and canceled on March 3, will not trigger a penalty fee, as the payment for the third month of the commitment period will already have been paid on March 1.

**Note:** Beginning in release 25.0 you can no longer set the `minimumCommitment` in the AutoBill.

When canceling a subscription during the commitment period, set a `cancelFeePolicy` to specify whether to prorate the fee, or to refund the full amount or waive the fee altogether (the default). Be sure also to set *disentitle* to `True` to stop entitlements, and set *settle* to `True` to have Subscribe calculate a settlement. And since the subscription is still within the commitment period, you must set *force* to `True` to have the penalty fee calculated as defined in the `cancelFeePolicy` field.

To have Subscribe return just the calculated settlement amount, set *amountOnly* to `True` in `AutoBill.settlementQuote`. When set to `false` (the default), full `Transaction` and `Refund` settlement details are generated.

## Create a Billing Plan with a minimum commitment

In the following example, a billing plan specifies two billing periods. One billing period is monthly with one cycle and is free; the other billing period is yearly and has 12 one-month cycles, two currencies, and is open ended (`cycles => 0`).

The subscription requires a minimum commitment of two cycles (the first free, the second billed), and comes with an early cancellation fee that will be applied if the subscription is canceled before the second payment is billed.

Billing plan with early cancel fee:

```

// Create a new BillingPlan
$bp = new BillingPlan();
$bp->setMerchantBillingPlanId('1MF1995Y');
$bp->setDescription(
    '1 Free Month followed by $19.95(USD),
    $22.40(CAD) per year');
 
$bp->periods[0]=(
    new BillingPlanPeriod(
        type => 'Month',
        quantity => 1,
        cycles => 1, //Just once
        prices => [
            new BillingPlanPrices(
                'amount' => 0,
                'currency' => 'USD'
            ),
            new BillingPlanPrices(
                'amount' => 0,
                'currency' => 'CAD'
            )
        ]
    )
);
$bp->periods[1]=(
    new BillingPlanPeriod(
        type => 'Year',
        quantity => 1,
        cycles => 0, //Repeat infinitely
        prices => [
            new BillingPlanPrices(
                'amount' => 19.95,
                'currency' => 'USD'
            ),
            new BillingPlanPrices(
                'amount' => 22.40,
                'currency' => 'CAD'
            )
        ]
    )
);
 
// Early Cancel Fee will be applicable for 2 billing cycles.
// 1, the free month period
// 2, the yearly period
$bp-minimumCommitment(2);
 
$bp->cancelFees[0]=(
    new BillingPlanCancelFee(
        'amount' => 4.45,
        'currency' => 'CAN'
    ),
);
$bp->cancelFees[1]=(
    new BillingPlanCancelFee(
        'amount' => 3.95,
        'currency' => 'USD'
    ),
);
$bp->merchantEntitlementIds[0] = (
    new MerchantEntitlementId (
        id => 'Standard',
        description => 'Standard subscription access'
    )
);
$response = $bp->update();
if($response['returnCode'] == 200) {
    print "ok\n";
    $bpVid = $bp->getVID();
    //capture the billing plan VID for later use
}
```

**Parent topic:**[Creating Billing Plans](../topics/Creating_Billing_Plans)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.