Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assertion Fails when Retrieving a Single Chargeback Payment #395

Open
theresa-de-ocampo opened this issue Dec 11, 2024 · 0 comments
Open

Comments

@theresa-de-ocampo
Copy link

Reproduction Steps

  1. Use @mollie/api-client version 4.1.0.
  2. Run the following code.
const dotenv = require("dotenv").config();
const { createMollieClient } = require("@mollie/api-client");
const mollieClient = createMollieClient({ apiKey: process.env.MOLLIE_API_KEY });

async function run() {
  if (dotenv.error) {
    throw dotenv.error;
  }

  try {
    const chargeback = await mollieClient.paymentChargebacks.get('chb_seinif', {
      paymentId: 'tr_jv3c9soPN6'
    });
    console.dir(chargeback, { depth: null });
  } catch (error) {
    console.dir(error, { depth: null });
  }
}

run();
  1. Check the logged errors.
ApiError: The refund id appears invalid: chb_seinif (unexpected format)
    at assertWellFormedId (C:\mollie-demo\node_modules\@mollie\api-client\dist\mollie.cjs.js:1933:11)       
    at PaymentChargebacksBinder.get (C:\mollie-demo\node_modules\@mollie\api-client\dist\mollie.cjs.js:3499:5)

Additional Context

  1. I think the resource value passed to assertWellFormedId is incorrectly set to refund instead of chargeback.

image

  1. When checkId is called, it will return false since prefixes[resource] gets evaluated to re_, but the value that was passed starts with chb_ causing assertWellFormedId to throw an error.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant