polar icon indicating copy to clipboard operation
polar copied to clipboard

Polar SDK sets currency as default attribute and it's failing for percentage discounts

Open psincraian opened this issue 4 months ago • 2 comments
trafficstars

Description

I noticed that it throws error on updating a percentage discount. Making a test with a simple fetch the code is working. It seems that sdk automatically adds currency field in the payload, that is not required for percentage discount.

Current Behavior

The fetch works as expected but the SDK call it doesn't.

const result = await fetch(`https://sandbox-api.polar.sh/v1/discounts/${fileId}`, {
    method: 'PATCH',
    headers: {
        'Authorization': 'Bearer ' + settings?.token,
        'Content-Type': 'application/json',
    },
    body: JSON.stringify({
        "name": "Test",
        "code": "MYCODE",
        "type": "percentage",                    
    })
})

const result2 = await polar.discounts.update({
    id: fileId,
    discountUpdate: {
        "name": "Test",
        "code": "MYCODE",
        "type": "percentage",
    }
});

Expected Behavior

The SDK should work as exppected for percentage discounts

Environment:

  • polar-sdk/js

psincraian avatar Jul 11 '25 14:07 psincraian