Can Customer Payment Methods ever return an empty array

I have an app that will (via private proxy app using the shopify rails app) send an email to the logged in customer to update the customers payment method (useful for customers who have had their card change, roll over or have new expiration date). It works.

However, can the response sometimes include an empty array for payment methods (looking to exception handle)::

"paymentMethods"=>{"edges"=>[{"node"=>{"id"=>"gid://shopify/CustomerPaymentMethod/abcde123etc"}}]}}}

If I need to exception handle that’s fine, I can’t see any info where the payment method could be an empty array if say the card was declined repeatedly, or if the card was canceled, etc. Just trying to cover the bases here as this is a background job.

Hi @fwallace ,

The Customer.paymentMethods connection returns a non-nullable array, which would be expected to be empty if the customer has no associated CustomerPaymentMethods.

If you are querying every customer as they log in then I would definitely recommend handling empty arrays.

Hope that helps!

  • James