square / square-nodejs-sdk

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Inconsistence types for `createCard` api ?

rawatnaresh opened this issue · comments

The Card type that is used in CreateCardRequest has customerId marked as optional but it should be required as calling createCard without customerId throws an error

  • Throws Error
await cardsApi.createCard({
    idempotencyKey: 'unique_key',
    sourceId: 'nonce',
    card: { }, // throws error although card.customerId is marked as optional
 });
  • Works fine
await cardsApi.createCard({
    idempotencyKey: 'unique_key',
    sourceId: 'nonce',
    card: { customerId: 'customer_id' }, // customerId should be passed although its marked a optional
 });

@rawatnaresh sorry about the confusion around this. The docs are correct, though they could be more clear. I've reached out to the respective team about adding more clarity around this.