anchor.diff:  
   . The client application invokes the `GoCardlessPlugin#buildFormDescriptor` method with a *success page URL*
   
  -. The `GoCarldessPlugin#buildFormDescriptor` method initiates the GoCardless redirect flow as explained https://developer.gocardless.com/getting-started/api/adding-your-first-customer/[here] and obtains the *redirect URL* which is returned to the client application
  +. The `GoCarldessPlugin#buildFormDescriptor` method *initiates* the *GoCardless redirect flow* as explained https://developer.gocardless.com/getting-started/api/adding-your-first-customer/#setting-up-direct-debit-mandates-using-hosted-payment-pages[here] and obtains the *redirect URL* which is returned to the client application
   
   . The client application redirects the user to this URL and the user sets up the mandate manually on this page
   
   . GoCardless redirects the user to the *success page*. This invokes the `GoCarldessPlugin#addPaymentMethod`
   
  -. The `GoCarldessPlugin#addPaymentMethod` completes the redirect flow as explained https://developer.gocardless.com/getting-started/api/adding-your-first-customer/[here] and obtains the *mandate id* which is saved in the Kill Bill database
  +. The `GoCarldessPlugin#addPaymentMethod` *completes* the *redirect flow* as explained https://developer.gocardless.com/getting-started/api/adding-your-first-customer/#setting-up-direct-debit-mandates-using-hosted-payment-pages[here] and obtains the *mandate id* which is saved in the Kill Bill database
   
   . The client application can then invoke `GoCarldessPlugin#purchasePayment`. This charges the customer against the saved *mandate id*  as explained https://developer.gocardless.com/getting-started/api/taking-your-first-payment/[here]
   
  
positive.code: |===
  
  
  Kill Bill has a https://docs.killbill.io/latest/userguide_payment.html#_janitor[Janitor] system in place that attempts to fix *PENDING* and *UNKNOWN* states . It polls the plugin via `PaymentPluginApi#getPaymentInfo` method. If the plugin subsequently returns *PROCESSED*, the Janitor updates the internal payment state as well as invoice balance, etc.) accordingly
  
  The Janitor matches the internal transactions against plugin transactions via the *transaction id*: make sure `PaymentTransactionInfoPlugin#getKbTransactionPaymentId` is correctly implemented.
  
  You should try to avoid *UNDEFINED* as much as possible, because it is the only case where Kill Bill cannot retry payments (since the payment may or may not have happened).
  
  
  == GoCardless Plugin Tutorial
  
  In order to demonstrate creating a Payment plugin, we will be creating a Kill Bill payment plugin for https://gocardless.com/[GoCardless]. GoCardless allows direct debit from customer's bank accounts. It requires a customer to set up a mandate the first time after which it directly collects payments against the mandates. 
  
  GoCardless provides a https://developer.gocardless.com/getting-started/api/making-your-first-request/#setting-up-your-client-library[client library]. We will be using this library to integrate GoCardless with Kill Bill. For the sake of simplicity, we will be creating a very basic plugin that can only process payments. 
  
  The complete code for this tutorial is available at https://github.com/killbill/killbill-gocardless-example-plugin[Github]
  
  === How GoCardless works
  
  The first step in GoCardless would be adding a customer and setting up the payment mandate. GoCardless supports three ways to do this as explained https://developer.gocardless.com/getting-started/api/adding-your-first-customer/[here]. In this tutorial, we will be using the *hosted payment page* approach.  This includes the following steps as explained https://developer.gocardless.com/getting-started/api/adding-your-first-customer/#setting-up-direct-debit-mandates-using-hosted-payment-pages[here]:
  
  . A client application  *initiates* the *GoCardless Redirect flow* with the *customer details*  (optional) and a *success page URL*.
  
  
negative.code: 
  * It then invokes the `GoCardlessPlugin#buildFormDescriptor` method
  
  ==== Step 9 - Deployment
  
  The GoCardless plugin can be built and deployed as per the instructions specified https://docs.killbill.io/latest/plugin_development.html#_development[here]
  