Articles in this section

Multi-Field Value Mapping Error in the Shopify Integration App

Error Message:  'Could not call method “indexOf” of null'

Issue:

We would like to add Amazon Pay and Apple Pay to our Payment Method mapping in NetSuite. The current setting maps the “payment_details.credit_card_company” field in Shopify to Payment Method in NetSuite. This is so the credit card name, e.g., VISA, MasterCard, will appear in the Payment Method field in NetSuite, which we do not want to be changed. However, the “payment_details” field does not appear in Shopify when customers use Amazon Pay as the payment method. Nevertheless, we can capture this by using the “gateway” field or the “payment_gateway_names” field in Shopify. On the other hand, “payment_gateway_names” in Shopify also shows “cyber_source” (same as when using regular credit cards) when the customer uses Apple Pay as the payment method but shows “unknown” in the “payment_details.credit_card_company” field in Shopify.  We decided to use Multi-field value settings for the mapping.

Below is the code we used for mapping the Payment Method:

{{#compare $.payment_gateway_names  "===" “amazon_payments"}} 18

{{else}}

   {{#compare $.payment_details.credit_card_company "===" "unknown"}} 19

   {{else}}

      {{#compare $.payment_details.credit_card_company "===" "American Express"}} 6

      {{else}}

         {{#compare $.payment_details.credit_card_company "===" "Visa"}} 5

         {{else}}

            {{#compare $.payment_details.credit_card_company "===" "MasterCard"}} 4

            {{else}}

               {{#compare $.payment_details.credit_card_company "===" "Discover"}} 3

               {{/compare}}

            {{/compare}}

         {{/compare}}

      {{/compare}}

   {{/compare}}

{{/compare}}

 

The numeric values are the Internal IDs for each payment method. However, this gives an error message stating: “Could not call method “indexOf” of null” when we test it.

In summary, we would like to see the credit card company if the order was paid using a regular credit card (VISA, MasterCard, etc.) and Amazon Pay or Apple Pay if the order was paid via these methods.

  

Resolution:
 
Since payment_gateway_names node is an array, use 
 
{{#compare $.payment_gateway_names.[0] "===" "amazon_payments"}} 18
 
instead of 
 
{{#compare $.payment_gateway_names  "===" “amazon_payments"}} 18
Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.