Simon_Weaver
Simon_Weaver

Reputation: 146170

GooglePay DEVELOPER_ERROR "PaymentDataRequest.merchantId does not exist"

After getting approval for a Google Pay merchantId I am getting the following error when trying to open the payment sheet.

{ statusCode: "DEVELOPER_ERROR", errorCode: 2, 
  statusMessage: "PaymentDataRequest.merchantId does not exist." }

I am using Braintree Payments, but that's not relevant to the end message.

   var paymentDataRequest = googlePaymentInstance.createPaymentDataRequest({

            merchantId: environment.payment.googlePayMerchantId,

            merchantInfo: {
                merchantId: environment.payment.googlePayMerchantId
            },

            transactionInfo: {
                currencyCode: 'USD',
                totalPriceStatus: 'ESTIMATED',
                totalPrice: this.priceEstimate.toFixed(2)
            },

            shippingAddressRequired: true,

            emailRequired: true,

            shippingAddressParameters: {
                allowedCountryCodes: data.countryCodes.map(c => c.code)
            }

            // cardRequirements: {
            //   // We recommend collecting billing address information, at minimum
            //   // billing postal code, and passing that billing postal code with all
            //   // Google Pay transactions as a best practice.
            //   billingAddressRequired: true
            // }
        });

Google is telling me everything looks OK their end.

Upvotes: 2

Views: 2858

Answers (1)

Simon_Weaver
Simon_Weaver

Reputation: 146170

Turns out that passing an extra merchantId parameter in addition to merchantInfo can cause this.

So the fix was just this:

  // merchantId: environment.payment.googlePayMerchantId

However it also turns out that merchantInfo in createPaymentDataRequest is not needed if you've properly supplied merchantId when you first created the Braintree client in braintree.googlePayment.create(...).

So the final fix in the above code is to remove both merchantId and merchantInfo.

I don't recall if this was just a mistake or an obsolete parameter from an older version of the API. In either case it's a very misleading error because the error says it's missing but it's actually an extra parameter.

Upvotes: 4

Related Questions