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

# Using EDD and UK DD for Recurring Billing

To implement AutoBill-based recurring billing for European Direct Debit (EDD) or United Kingdom Direct Debit (UK DD), construct and populate a `PaymentMethod` object and set it on the `paymentMethod` attribute of the `AutoBill` object and specify Direct Debit as the `paymentMethodType (value = DirectDebit)`. If you do not specify a `paymentMethod` attribute, Subscribe uses the first payment method in the sort order on the associated Account object.

The following example constructs an EDD-based `paymentMethod` object, and sets it as the payment method for an `AutoBill` object. The example then creates the `AutoBill` object on the Vindicia server by calling `update()` on `AutoBill` with payment method validation turned on. (Note that this example shows a recurring transaction with a full rebill amount.)

To construct a UK DD-based `PaymentMethod` object, substitute the appropriate country code and currency type. Because EDD and UK DD are both direct debit payment methods, routing is determined by country code and currency type. With country code GB and currency GBP, the payment will route to UK DD. With one of the European country codes and the euro or a local currency, payment will route to EDD.

```

 // Create a payment method object to make the call
 $edd_pm = new PaymentMethod();
  
 $edd_pm->setType('DirectDebit');
  
 $dd = new DirectDebit();
 $dd->setAccount('8888888888');
 $dd->setBankSortCode('12345678');
 $dd->setCountryCode('DE');
  
 $edd_pm->setDirectDebit($dd);
  
 $bill_addr = new Address();
 $bill_addr->setName('Lutz Haff');
 $bill_addr->setAddr1('Leonrodstrasse 57');
 $bill_addr->setCity('Munchen');
 $bill_addr->setPostalCode('D-80636');
 $bill_addr->setCountry('DE');
  
 $edd_pm->setBillingAddress($bill_addr);
 $edd_pm->setAccountHolderName('Lutz Haff');
 $edd_pm->setCustomerSpecifiedType('EDD');
 $edd_pm->setMerchantPaymentMethodId('pmid-edd-342123');
  
 // Create a payment method object to make the call
 $autobill = new AutoBill();
  
 $autobill->setPaymentMethod($edd_pm);
  
 // Populate other AutoBill attributes here
 …
  
 // Create the autobill while validating the payment method
  
 $autobill->setCurrency('EUR');
 // If you are enabling mandate storage for this AutoBill, 
 // as discussed later in this document, include the 
 // IP address from which the customer purchased this subscription.
 // In some countries, the IP address is part of the 
 // signature on the mandate.
  
 $autobill->setSourceIp('198.209.56.17');
  
 $validate = true;
 $fraudScore = 100 ; // do not want to do risk screening
  
 $response = 
    $autobill->update('SucceedIgnore', $validate, $fraudScore);
  
 if($['response['data']->refunds['returnCode'] == 200 
       && $response['created'] ){
    print "AutoBill created with VID " . 
       $response['data']->autobill->getVID() . "\n";
 }
```

Once the `AutoBill` object is in place, the recurring EDD or UK DD-based transactions it generates determine its status and the entitlements it grants to the associated `Account` object, as follows:

1. Subscribe validates (the payment method for) a recurring transaction before submitting it to the payment processor for capture. (For more information, see the `AutoBill.``validate` method in the **Subscribe API Guide**.)
   * If the validation fails, Subscribe sets the `AutoBill` status to `Hard Error`. This rarely happens if you validate the EDD or UK DD payment method when creating an `AutoBill` object or when updating its payment method.
   * If the transaction passes the validation, Subscribe submits it to the payment processor. The processor checks the account number and bank routing number for the EDD or UK DD payment method against a negative file. If the transaction passes, Subscribe considers the transaction `Authorized`, and the funds withdrawal process begins. Subscribe sets the `AutoBill` status to `Good Standing` (or retains that status), and `AutoBill` grants (or continues to grant) the customer entitlements.
2. During the funds deposit process:
   * If the processor receives a *decline* return code (a soft error due to insufficient funds, for example), the retry process starts. The payment processor triggers this process according to the retry schedule defined by the merchant. A retry does not affect the `AutoBill` status, which remains `Good Standing`. The rebill `Transaction` moves to the `DepositRetryPending` status, which is internal to Subscribe. The customer continues to have the entitlements granted by the `AutoBill` object.
   * If the processor receives a *reject* return code, (a hard error because, for example, the customer bank account has been closed), and you have not provided a retry schedule to the processor, the rebill transaction fails. Subscribe sets the transaction status to `Cancelled` and the corresponding `AutoBill` status to `Hard Error`.
   * If Subscribe receives *no response* from the processor for four banking days, Subscribe sets the `Transaction` status to `Captured`. The `AutoBill` object retains its `Good Standing` status until the beginning of the next billing period, and the customer’s entitlements remain valid until the next billing date.

* **[Understanding Mandates for Recurring Billing with EDD](../topics/Understanding_Mandates_f)**

* **[Understanding Mandates for Recurring Billing with UK DD](../topics/Understanding_Mandates_f_1)**

**Parent topic:**[Working with AutoBills](../topics/ProgGuide_AutoBills)


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