voucherifyio / voucherify-java-sdk

Java SDK for Voucherify - coupons, vouchers, promo codes
www.voucherify.io
MIT License
23 stars 12 forks source link

Add custom error messages in VoucherValidationResponse #129

Closed tcalvoarroyo closed 1 year ago

tcalvoarroyo commented 1 year ago

In order to use the custom error message using validation rules with vouchers, the field error.description is missing in the VoucherValidationResponse object.

It would be very useful to have it

Thanks image

akaliszuk commented 1 year ago

I'm pretty sure, and also consulted it with my team that there is no description property in the validation response. This is my example response:

{
    "valid": false,
    "reason": "quantity exceeded",
    "error": {
        "code": 400,
        "key": "quantity_exceeded",
        "message": "quantity exceeded",
        "details": "KY4KRtMl",
        "request_id": "v-0d732b0e259690f253"
    },
    "code": "KY4KRtMl",
    "metadata": {
        "mandatory_v": "6"
    }
}

Or in stackable API (which will be soon in JAVA SDK)

{
    "valid": false,
    "redeemables": [
        {
            "status": "INAPPLICABLE",
            "id": "test123",
            "object": "voucher",
            "result": {
                "error": {
                    "code": 400,
                    "key": "redemption_rules_violated",
                    "message": "redemption does not match validation rules",
                    "details": "Discount Coupon cannot be redeemed because of violated validation rules: val_ILSjGmeGaIAJ",
                    "request_id": "v-0d730de0808fca80bf",
                    "error": {
                        "message": "You can only use it once"
                    }
                }
            },
            "metadata": {}
        }
    ],
    "tracking_id": "track_eRI03lU38AY="
}

I added missing fields in PR which will be released soon. But if You still need description in response please tell me and give me an example with it.

mario-martinez-se commented 1 year ago

@jkaliszuk Any idea when this fix will be released? Me and my team are currently working on voucherify integration and without this, we would need to change quite a few things. So I'd like to understand if it's worth it waiting for this to be released or just change how we do the integration.

akaliszuk commented 1 year ago

@mario-martinez-se @tcalvoarroyo we've just released 11.1.6 version with this particular update. Should be soon available in maven/gradle repository.

mario-martinez-se commented 1 year ago

Thank you very much @jkaliszuk , that has saved me quite a piece of work ❤️