anchor.diff:  
   *  The `currency` object passed in is of type `org.killbill.billing.catalog.api.Currency`. This is then converted to a *GoCardless Currency object* (of type `com.gocardless.services.PaymentService.PaymentCreateRequest.Currency`). Most payment plugins have code similar to this to convert Kill Bill objects to compatible objects in the plugin's client library.
   
  -* Finally, the `client.payments().create()` is invoked with the `idempotencyKey`,`amount` and `currency` values. This returns a `Payment` object which contains a `paymentId`
  +* Finally, the `client.payments().create()` is invoked with the `idempotencyKey`,`amount` and `currency` values. This returns a `Payment` object which contains a `paymentId`. Additionally, the `kbPaymentId` and `kbTransactionId` are sent as *metadata* to GoCardless in this call. GoCardless *metadata* allows an application to send custom key value pairs to GoCardless. These can then be retrieved later on as required.  In our case, the `kbPaymentId` and `kbTransactionId` are required for the `getPaymentInfo` call which will be explained further. 
   
   * The `purchasePayment` method returns a `PaymentTransactionInfoPlugin` object.  The <<PaymentTransactionInfoPlugin>> section above explaind this interface in detail. We have already created a https://github.com/killbill/killbill-gocardless-example-plugin/blob/9522498ecde5849c940574c598ceb5ce088d32a7/src/main/java/org/killbill/billing/plugin/gocardless/GoCardlessPaymentTransactionInfoPlugin.java[GoCardlessPaymentTransactionInfoPlugin] class above.
   
  
positive.code: 
  ==== Step 7 - Implementing https://github.com/killbill/killbill-gocardless-example-plugin/blob/9522498ecde5849c940574c598ceb5ce088d32a7/src/main/java/org/killbill/billing/plugin/gocardless/GoCardlessPaymentPluginApi.java#L211[GoCardlessPaymentPluginApi#getPaymentInfo]
  
  As explained earlier, the Kill Bill Janitor system attempts to fix *PENDING* and *UNKNOWN* states by  polling the plugin via `PaymentPluginApi#getPaymentInfo` method. So, this method needs to be implemented as follows:
  [source,java]
  public List<PaymentTransactionInfoPlugin> getPaymentInfo(UUID kbAccountId, UUID kbPaymentId,
  		Iterable<PluginProperty> properties, TenantContext context) throws PaymentPluginApiException {
  	String paymentId = PluginProperties.findPluginPropertyValue("payment_id", properties);
  	Payment payment = client.payments().get(paymentId).execute();
  	Currency killBillCurrency = convertGoCardlessCurrencyToKillBillCurrency(payment.getCurrency());
  	PaymentPluginStatus status = convertGoCardlessToKillBillStatus(payment.getStatus());
  	GoCardlessPaymentTransactionInfoPlugin paymentTransactionInfoPlugin = new GoCardlessPaymentTransactionInfoPlugin(
  			kbPaymentId, null, TransactionType.PURCHASE, new BigDecimal(payment.getAmount()), killBillCurrency,
  			status, null, null, String.valueOf(payment.getId()), null, new DateTime(),
  			new DateTime(payment.getCreatedAt()), null); // TODO: passing null for output properties and kbTransactionId
  	List<PaymentTransactionInfoPlugin> paymentTransactionInfoPluginList = new ArrayList<>();
  	paymentTransactionInfoPluginList.add(paymentTransactionInfoPlugin);
  	return paymentTransactionInfoPluginList;
  }
  
  * Like the other methods, the `getPaymentInfo` method accepts  `Iterable<PluginProperty> properties` as a parameter.  
  
  * The code first retrieves the `paymentId`, sent by the Janitor system from the properties passed in. 
  
  * Next, the `payments().get()` is invoked with the `paymentId`. This returns a `Payment` object with additional details about the payment as specified https://developer.gocardless.com/api-reference/#payments-get-a-single-payment[here].
  
  * The code then retrieves the GoCardless currency(object of type `com.gocardless.resources.Payment.Currency`) from the `payment` object and converts it to Kill Bill currency (object of type `org.killbill.billing.catalog.api.Currency`).
  
  * Next, the code retrieves the GoCardless status (object of type `com.gocardless.resources.Payment.Status`) from the `payment` object and converts it to a `org.killbill.billing.payment.plugin.api.PaymentPluginStatus` object.
  
  * Finally, it builds the `GoCardlessPaymentTransactionInfoPlugin` object using these parameters, adds it to a List and returns it.
  
  * Depending on the status in the `GoCardlessPaymentTransactionInfoPlugin` object, the Janitor updates the internal payment state as well as invoice balance, etc.
  
  
  ==== Step 8 - Creating https://github.com/killbill/killbill-gocardless-example-plugin/blob/9522498ecde5849c940574c598ceb5ce088d32a7/src/main/java/org/killbill/billing/plugin/gocardless/GoCardlessActivator.java[GoCardlessActivator]
  
negative.code: 
  [source,java,linenums]
  public PaymentTransactionInfoPlugin purchasePayment(UUID kbAccountId, UUID kbPaymentId, UUID kbTransactionId,
  		UUID kbPaymentMethodId, BigDecimal amount, Currency currency, Iterable<PluginProperty> properties,
  		CallContext context) throws PaymentPluginApiException {
  	logger.info("purchasePayment, kbAccountId=" + kbAccountId);
  	PaymentTransactionInfoPlugin paymentTransactionInfoPlugin;
  	String mandate = getMandateId(kbAccountId, context); // retrieve mandateId from Kill Bill tables
  	logger.info("MandateId="+mandate);
  	if (mandate != null) {
  		logger.info("Processing payment");
  		try {
  			String idempotencyKey = PluginProperties.findPluginPropertyValue("idempotencykey", properties);
  			com.gocardless.services.PaymentService.PaymentCreateRequest.Currency goCardlessCurrency = convertKillBillCurrencyToGoCardlessCurrency(
  					currency);
  			Payment payment = client.payments().create()
  					.withAmount(Math.toIntExact(KillBillMoney.toMinorUnits(currency.toString(), amount)))
  					.withCurrency(goCardlessCurrency).withLinksMandate(mandate).withIdempotencyKey(idempotencyKey)
  					.withMetadata("kbPaymentId", kbPaymentId.toString()).withMetadata("kbTransactionId", kbTransactionId.toString()) //added for getPaymentInfo
  					.execute();
  			List<PluginProperty> outputProperties = new ArrayList<PluginProperty>();
  			outputProperties.add(new PluginProperty("paymentId", payment.getId(), false));
  			paymentTransactionInfoPlugin = new GoCardlessPaymentTransactionInfoPlugin(kbPaymentId, kbTransactionId,
  					TransactionType.PURCHASE, amount, currency, PaymentPluginStatus.PROCESSED, null, null,
  					String.valueOf(payment.getId()), null, new DateTime(), new DateTime(payment.getCreatedAt()),
  					outputProperties);
  			logger.info("Payment processed, PaymentId="+payment.getId());
  		} catch (GoCardlessApiException e) {
  			paymentTransactionInfoPlugin = new GoCardlessPaymentTransactionInfoPlugin(kbPaymentId, kbTransactionId,
  					TransactionType.PURCHASE, amount, currency, PaymentPluginStatus.ERROR, e.getErrorMessage(),
  					String.valueOf(e.getCode()), null, null, new DateTime(), null, null);
  			logger.warn("Error occured in purchasePayment", e.getType(), e);
  		}
  	} else {
  		logger.warn("Unable to fetch mandate, so cannot process payment");
  		paymentTransactionInfoPlugin = new GoCardlessPaymentTransactionInfoPlugin(kbPaymentId, kbTransactionId,
  				TransactionType.PURCHASE, amount, currency, PaymentPluginStatus.CANCELED, null, 
  				null, null, null, new DateTime(), null, null);
  	}
  	return paymentTransactionInfoPlugin;
  }
  