anchor.diff:  
   If the payment gateway does not process a payment synchronously, the corresponding plugin method (`purchasePayment`, `capturePayment`, etc.) should return a *PENDING* status (Refer to the <<payment_plugin_status, Payment Plugin Status>> section). This sets the `transactionstatus` to *PENDING* in the Kill Bill database. This can subsequently be converted to the *PAYMENT_SUCCESS*/*PAYMENT_FAILURE* status in one of the following ways:
   
  -* *Explicitly by the plugin* - Once the plugin receives a notification from the payment gateway about the payment being processed, it can explicitly invoke the https://github.com/killbill/killbill-api/blob/4ae1c343a593de937415e21feecb9f5405037fa3/src/main/java/org/killbill/billing/payment/api/PaymentApi.java#L402[`PaymentApi#notifyPendingTransactionOfStateChanged`] method. You can take a look at how this is done in the https://github.com/killbill/killbill-adyen-plugin/blob/5bb6ad36a868bab15a4123af32a8c453f383e3b7/src/main/java/org/killbill/billing/plugin/adyen/core/KillbillAdyenNotificationHandler.java#L350[_Adyen plugin_]. 
  +* *Explicitly by the plugin* - Once the plugin receives a notification from the payment gateway about the payment being processed, it can explicitly invoke the https://github.com/killbill/killbill-api/blob/4ae1c343a593de937415e21feecb9f5405037fa3/src/main/java/org/killbill/billing/payment/api/PaymentApi.java#L402[`PaymentApi#notifyPendingTransactionOfStateChanged`] method. You can take a look at how this is done in the https://github.com/killbill/killbill-adyen-plugin/blob/5bb6ad36a868bab15a4123af32a8c453f383e3b7/src/main/java/org/killbill/billing/plugin/adyen/core/KillbillAdyenNotificationHandler.java#L350[Adyen plugin]. 
   +
   Some Important Pointers:
   +
  -** In order to ensure that the invoice balance is adjusted after updating the payment status, you need to make sure the payment goes through the internal payment control state machine. If you are using the https://github.com/killbill/killbill-plugin-framework-java[_Kill Bill plugin framework_], you can use the  https://github.com/killbill/killbill-plugin-framework-java/blob/870ae40ab476a3cc2d85b89eb2d920e4504e2784/src/main/java/org/killbill/billing/plugin/api/core/PaymentApiWrapper.java#L74-L94[`PaymentApiWrapper#transitionPendingTransaction`] method, which does this for you.
  +** In order to ensure that the invoice balance is adjusted after updating the payment status, you need to make sure the payment goes through the internal payment control state machine. If you are using the https://github.com/killbill/killbill-plugin-framework-java[Kill Bill Plugin framework], you can use the  https://github.com/killbill/killbill-plugin-framework-java/blob/870ae40ab476a3cc2d85b89eb2d920e4504e2784/src/main/java/org/killbill/billing/plugin/api/core/PaymentApiWrapper.java#L74-L94[`PaymentApiWrapper#transitionPendingTransaction`] method, which does this for you.
   +
  -** Kill Bill also provides a https://killbill.github.io/slate/#payment-transaction-mark-a-pending-payment-transaction-as-succeeded-or-failed[_Mark a pending payment transaction as succeeded or failed_] endpoint. This internally invokes the https://github.com/killbill/killbill-api/blob/4ae1c343a593de937415e21feecb9f5405037fa3/src/main/java/org/killbill/billing/payment/api/PaymentApi.java#L402[`PaymentApi#notifyPendingTransactionOfStateChanged`] method and can also be used.
  -
  -* *Via the Janitor* - As explained earlier, the https://docs.killbill.io/latest/userguide_payment.html#_janitor[__Kill Bill Janitor__] attempts to to fix *PENDING* and *UNKNOWN* payment states by querying the <<getPaymentInfo, `getPaymentInfo`>> method. Thus, once the plugin receives a notification from the payment gateway about the payment being processed, the `getPaymentInfo` should return the correct payment status.
  +** Kill Bill also provides a https://killbill.github.io/slate/#payment-transaction-mark-a-pending-payment-transaction-as-succeeded-or-failed[Mark a pending payment transaction as succeeded or failed] endpoint. This internally invokes the https://github.com/killbill/killbill-api/blob/4ae1c343a593de937415e21feecb9f5405037fa3/src/main/java/org/killbill/billing/payment/api/PaymentApi.java#L402[`PaymentApi#notifyPendingTransactionOfStateChanged`] method and can also be used.
  +
  +* *Via the Janitor* - As explained earlier, the https://docs.killbill.io/latest/userguide_payment.html#_janitor[Kill Bill Janitor] attempts to to fix *PENDING* and *UNKNOWN* payment states by querying the <<getPaymentInfo, `getPaymentInfo`>> method. Thus, once the plugin receives a notification from the payment gateway about the payment being processed, the `getPaymentInfo` should return the correct payment status.
   
   [NOTE]  
  -*Note*: The https://docs.killbill.io/latest/userguide_payment.html#_janitor_notification_queue[Notification Queue Janitor] runs automatically per a configured schedule. If you would like to run the Janitor immediately, you can trigger the https://docs.killbill.io/latest/userguide_payment.html#_on_the_fly_janitor[__on-the-fly janitor__] by invoking the https://github.com/killbill/killbill-api/blob/4ae1c343a593de937415e21feecb9f5405037fa3/src/main/java/org/killbill/billing/payment/api/PaymentApi.java#L439[`PaymentApi#getPayment`] method. 
  +*Note*: The https://docs.killbill.io/latest/userguide_payment.html#_janitor_notification_queue[Notification Queue Janitor] runs automatically per a configured schedule. If you would like to run the Janitor immediately, you can trigger the https://docs.killbill.io/latest/userguide_payment.html#_on_the_fly_janitor[on-the-fly janitor] by invoking the https://github.com/killbill/killbill-api/blob/4ae1c343a593de937415e21feecb9f5405037fa3/src/main/java/org/killbill/billing/payment/api/PaymentApi.java#L439[`PaymentApi#getPayment`] method. 
   
   *Other Notes*
   
  
positive.code: 
  ==== Step 5 - Implementing GoCardlessPaymentPluginApi#addPaymentMethod
  
  The `addPaymentMethod` method is typically used to add a https://docs.killbill.io/latest/Kill-Bill-Glossary.html#payment_method[_payment method_] in Kill Bill corresponding to a https://docs.killbill.io/latest/Kill-Bill-Glossary.html#account[_customer/account_]. Most plugins use this method to create the payment method in the gateway and store payment method specific data in the plugin tables). This tutorial uses it to *complete* the *redirect flow*. Thus, it is implemented as follows (See https://github.com/killbill/killbill-gocardless-example-plugin/blob/9522498ecde5849c940574c598ceb5ce088d32a7/src/main/java/org/killbill/billing/plugin/gocardless/GoCardlessPaymentPluginApi.java#L223[`GoCardlessPaymentPluginApi#addPaymentMethod`]):
  
  [source,java,linenums]
  ----
  
negative.code: |Method Name | Method Description
  
  |authorizePayment/ capturePayment
  |Should trigger an https://en.wikipedia.org/wiki/Authorization_hold[authorization] and capture respectfully (applies to credit cards only)
  |purchasePayment
  |Should trigger a generic payment (authorization with auto-capture for credit cards, ACH/SEPA, etc.)
  |voidPayment
  