voucherifyio / voucherify-nodejs-sdk

[Deprecated] Node.js SDK for Voucherify - coupons, vouchers, promo codes
http://www.voucherify.io
MIT License
27 stars 16 forks source link

Order items | source_id #98

Closed rizaldirnm closed 5 years ago

rizaldirnm commented 5 years ago

Hi, I dont konw its my problem or not. this is my code:

clientVoucher.validations.validate(code, { customer: { source_id: userdata.id }, order: { items:[ { product_id: product_id, quantity: 1, price: parseInt(amount)*100, source_id: productCode } ] } })

and my response is: { code: 400, message: 'Invalid Order', details: 'Property items should be an array', key: 'invalid_order', toString: [Function] }

BUT if I comment source_id its work fine. if source_id not work its hard for my system to request data product only for get product_id. Help me.

frakti commented 5 years ago

@Rizaldinurm thanks for reporting your issue.

You've wrongly mixed two ways of defining order item. As you can find in official docs you can:

1) define product_id OR 2) define source_id and related_object = "product"

Second option has higher precedence that's why it didn't work for you, you missed related_object so we couldn't know if given source_id is a product or sku.

Regarding the message, truly it is misleading and we will fix API response soon.

rizaldirnm commented 5 years ago

AHH! thankyou so much.