0

Using Braintree with js, But getting below error

Uncaught Error: Could not stringify event: JSON.stringify is not a function

I have added div in form(jsp page)

<div id="paypal-container">   <input type="submit" name="btnSub" value="Pay" id="btnSub"/>
</div>

And in js Calling ajax to receive client token from api and the

  braintree.setup(""+clientToken+"", "dropin", {
                     id: 'paypal-container',
                      paypal: {
                        container: "paypal-container",
                        onSuccess: function (nonce, email) {
                            console.log("email"+nonce+"\t "+email);
                              }
                      },
                      hostedFields: {
                          number: {
                            selector: "**** ****  1111 1111"
                          },
                          cvv: {
                            selector: "***"
                          },
                          expirationMonth: {
                            selector: "12"
                          },
                          expirationYear: {
                            selector: "2018"
                          }
                        },

                      onPaymentMethodReceived: function (obj) {
                          console.log(obj);
                          alert('onPaymentMethodReceived');
                        },
                        onError :function(obj){
                            alert('onError');

                       }
                    });

I run this on jquery load but getting above exception Please help.

Kamini
  • 690
  • 2
  • 13
  • 36
  • You should replace "dropin" with "custom" if you are intending to use stand-alone PayPal and [Hosted Fields](https://developers.braintreepayments.com/guides/hosted-fields/setup-and-integration/javascript/v2#braintree.setup). Further, the `onSuccess` callback of your PayPal setup is [deprecated](https://developers.braintreepayments.com/reference/client-reference/javascript/v2/paypal#options). – pblesi May 24 '16 at 14:23
  • @pblesi I added custom abd removed onSuccess still getting above error – Kamini May 25 '16 at 05:59
  • I am still not able to reproduce your error, however you should follow [this Hosted Fields example](https://developers.braintreepayments.com/guides/hosted-fields/setup-and-integration/javascript/v2#basic-integration). Specifically you should create a form and pass a css selector to the selector attribute of each form field of your Hosted Fields configuration – pblesi May 25 '16 at 19:42

0 Answers0