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

Closed
theresa-de-ocampo opened this issue Dec 11, 2024 · 1 comment · Fixed by #400
Closed

Assertion Fails when Retrieving a Single Chargeback Payment #395

theresa-de-ocampo opened this issue Dec 11, 2024 · 1 comment · Fixed by #400
Labels
bug Unexpected behaviour.

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

@janpaepke
Copy link
Collaborator

Thank you for the very well written issue.

I agree with your assessment and proposed fix.
Would you care to create a pr?

@janpaepke janpaepke added the bug Unexpected behaviour. label Jan 21, 2025
This was referenced Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected behaviour.
Projects
None yet
2 participants