Hi there,
I'm developing a payment plugin and I'm implementing this method
public PaymentTransactionInfoPlugin purchasePayment(UUID kbAccountId, UUID kbPaymentId, UUID kbTransactionId,
UUID kbPaymentMethodId, BigDecimal amount, Currency currency, Iterable<PluginProperty> properties,
CallContext context) throws PaymentPluginApiException
My plugin gets an error when calling the payment gateway so I send back the PaymentTransactionInfoPlugin object like this:
return new PaymentTransactionInfoPluginImpl(
kbPaymentId, kbTransactionId,
TransactionType.PURCHASE, scaledAmount, currency,
PaymentPluginStatus.ERROR,
e.getErrorMessage(),String.valueOf(e.getStatusCode()),
null, null,
new DateTime(), null,
ImmutableList.copyOf(properties));
however the caller doesn't handle that at all.Here's my caller code:
final Payment payment = accountApi.processPayment(invoice.getAccountId(),
paymentTransaction,
paymentMethod.getPaymentMethodId(),
NULL_PLUGIN_NAMES,
properties,
requestOptions);
And here's a snip of the stack trace:
Caused by: com.fasterxml.jackson.core.JsonParseException: Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')
at [Source: (ByteArrayInputStream); line: 1, column: 2]
at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1804)
at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:693)
at com.fasterxml.jackson.core.base.ParserMinimalBase._reportUnexpectedChar(ParserMinimalBase.java:591)
at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._handleUnexpectedValue(UTF8StreamJsonParser.java:2630)
at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._nextTokenNotInObject(UTF8StreamJsonParser.java:832)
at com.fasterxml.jackson.core.json.UTF8StreamJsonParser.nextToken(UTF8StreamJsonParser.java:729)
at com.fasterxml.jackson.databind.ObjectMapper._initForReading(ObjectMapper.java:4141)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4000)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3070)
at org.killbill.billing.client.KillBillHttpClient.unmarshalResponse(KillBillHttpClient.java:480)
You can see the problem happens down in the Killbill client. It is failing to unpack the returned message. Can you suggest how I can do this better?I really want to catch an error when my application calls the KillBill API, but I was hoping an error detected in my plugin would propagate up so I could handle it properly.
Thanks