> ## 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.

# Changing the Billing Plan for an AutoBill

The following example demonstrates how to use the AutoBill.modify call to change the Billing Plan on an AutoBill, replacing the existing with a new Billing Plan.

Note that changing the Billing Plan for an AutoBill does not cancel or recalculate the minimum commitment period set on the AutoBill.

```

$abill = new AutoBill();
$abill->setMerchantAutoBillId('TEST-AB-2'); 
   // this is ID of the AutoBill you want to modify

$newBp = new BillingPlan();
$newBp->setMerchantBillingPlanId('monthly'); 
   // The ID of the Billing Plan you want change the AutoBill to. 

$abmr = $abill->modify( 
      true, // bill prorated period 
      'today', // make the change effective immediately 
      $newBp, // changing the billing plan
      null, // no product modifications
      false // no dry run
      ); 
if ($abmr->getReturnCode() == 200) {
   // We got a 200 response code back
   // The modification may result a net refund or net charge to the customer 
   $refunds = $abmr->getRefunds();
   $tx = $abmr->getTransaction();
   if ($refunds != null and $refunds->length > 0 ) {
      // Modification resulted in a net refund.
      // In most cases there should be only one refund.
      $the_refund = $refunds[0];
      print('Total refund amount due to modification: '
         . $the_refund->getAmount() . '
         . See break down below: '); 

   // To give the customer a break down of how we reached the refund 
   // amount, we must parse the $0 transaction that accompanies this.
   if ($tx != null ) {
      printTxDetails($tx);
      }
   }
   else {
      // Refund is null, so there must be net cost to the customer
      if ($tx != null ) {
         print('Total charge processed during modification: $'
          . $tx->getAmount()
          . ' - see break down below:');
         printTxDetails(tx);
       }
    }
 } 
```

**Parent topic:**[Modifying AutoBills](../topics/Modifying_AutoBills)


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