killbill-client-js icon indicating copy to clipboard operation
killbill-client-js copied to clipboard

Issue in registerPushNotification

Open reshmabidikar opened this issue 2 years ago • 4 comments

The registerPushNotificationCallback code does not work.

On invoking this code as follows:

const api: killbill.TenantApi = new killbill.TenantApi(config);
const cb = 'http://demo/callmeback';
api.registerPushNotificationCallback('created-by', cb, 'reason', 'comment')

The following error is shown in the Kill Bill logs:

2023-08-11T06:15:35,983+0000 lvl='WARN', log='WebComponent', th='http-nio-8080-exec-6', xff='', rId='', tok='', aRId='', tRId='1', A servlet request to the URI http://localhost:8080/1.0/kb/tenants/registerNotificationCallback?cb=http%3A%2F%2Fdemo%2Fcallmeback contains form parameters in the request body but the request body has been consumed by the servlet or a servlet filter accessing the request parameters. Only resource methods using @FormParam will work as expected. Resource methods consuming the request body by other means will not work as expected.
2023-08-11T06:15:35,985+0000 lvl='INFO', log='LoggingFeature', th='http-nio-8080-exec-6', xff='', rId='', tok='', aRId='', tRId='1', 15 * Server has received a request on thread http-nio-8080-exec-6
15 > POST http://localhost:8080/1.0/kb/tenants/registerNotificationCallback?cb=http%3A%2F%2Fdemo%2Fcallmeback
15 > accept: application/json, text/plain, */*
15 > accept-encoding: gzip, compress, deflate, br
15 > authorization: **********
15 > connection: close
15 > content-length: 0
15 > content-type: application/x-www-form-urlencoded
15 > host: localhost:8080
15 > user-agent: axios/1.4.0
15 > x-killbill-apikey: bob
15 > x-killbill-apisecret: *****
15 > x-killbill-comment: comment
15 > x-killbill-createdby: created-by
15 > x-killbill-reason: reason

2023-08-11T06:15:35,986+0000 lvl='INFO', log='LoggingFeature', th='http-nio-8080-exec-6', xff='', rId='', tok='', aRId='', tRId='1', 15 * Server responded with a response on thread http-nio-8080-exec-6
15 < 415
15 < Content-Type: application/json

There is no record inserted in the tenant_kvs table corresponding to the push notification.

On investigating this further, I think this is due to the content-type: application/x-www-form-urlencoded header sent by the javascript client.

reshmabidikar avatar Aug 11 '23 06:08 reshmabidikar

It appears that PUT calls are not working with JS client :

const api: killbill.AccountApi = new killbill.AccountApi(config);   

    api.setDefaultPaymentMethod(
      'put account id here',
      'put payment method id here,
      'KB'
    );

The calls do not fail, they show success but the intended updates do not happen.

const api: killbill.AccountApi = new killbill.AccountApi(config);

    /* const response: AxiosResponse<void, any> = await api.transferChildCreditToParent(
      '1874ab74-df29-4409-b665-2012b1c2803c',
      'KB'
    );
    console.log(response.data); */

    api.transferChildCreditToParent('1874ab74-df29-4409-b665-2012b1c2803c', 'KB');

KBbitsP avatar Aug 15 '23 17:08 KBbitsP

Found similar issue with Bundle API :

  1. https://killbill.github.io/slate/bundle.html#update-a-bundle-external-key
    const bundleApi: killbill.BundleApi = new killbill.BundleApi(config);
    const bundleBody: killbill.Bundle = { accountId: 'd869f861-0c60-4086-a3fc-49ad855d48c0', externalKey: 'newExternalKey2' };
    const bundleID = 'd1067966-c34f-4e93-abf7-7285582e0691';
    bundleApi.renameExternalKey(bundleBody, bundleID, 'created_by');
  1. https://killbill.github.io/slate/bundle.html#transfer-a-bundle-to-another-account

     const bundleApi: killbill.BundleApi = new killbill.BundleApi(config);
     const bundleBody: killbill.Bundle = {  accountId: '3e5e2f75-728f-4fc4-a8fc-066e7420bd69'   };
     const bundleID = 'd1067966-c34f-4e93-abf7-7285582e0691';
     bundleApi.transferBundle(bundleBody, bundleID, 'created_by');
    
  2. https://killbill.github.io/slate/bundle.html#pause-a-bundle


const bundleID = '7f5b6b8e-0936-4d6b-ab05-820632f385b0';

bundleApi.pauseBundle(bundleID, 'created_by');
  1. https://killbill.github.io/slate/bundle.html#resume-a-bundle

const bundleID = 'd1067966-c34f-4e93-abf7-7285582e0691'; 

bundleApi.resumeBundle(bundleID, 'created_by');

KBbitsP avatar Sep 13 '23 17:09 KBbitsP

A similar issue occurs for the following endpoints:

  1. Trigger invoice run
  2. Commit Invoice
  3. Void Invoice
  4. Trigger Invoice Group Run

reshmabidikar avatar Sep 21 '23 11:09 reshmabidikar

Found the issue with below endpoint : https://killbill.github.io/slate/payment.html#remove-tags-from-a-payment

const paymentApi: killbill.PaymentApi = new killbill.PaymentApi(config);

const paymentId = 'bfc12b3c-0042-48c5-b233-2d8e015f49f6';

const tagDefIds = ['5071f544-c29f-47f5-a2ab-a6092c5bba74'];

paymentApi.deletePaymentTags(paymentId,'created_by',tagDefIds);

KBbitsP avatar Sep 29 '23 16:09 KBbitsP