Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

PayPal create_order_error cannot read properties of null

I’ve integrated PayPal into my .NET 6 (Blazor) application. I followed the PayPal docs here to add the button. In test mode all worked fine. Now that I’ve changed the clientid to live I get an error:

create_order_error Cannot read properties of null

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I can see the token is null, but I’m not sure what to do about it?

The code I’m using to create the order is here:

paypal.Buttons({
    // Style the button
    style: {
      ...
    },

    // Called when the button is clicked
    onClick: function (data, actions) {
      ...
    },

    // Sets up the transaction when a payment button is clicked
    createOrder: function (data, actions) {
      return actions.order.create({
        purchase_units: [{
          amount: {
            value: document.getElementById('p-amount').value,
          }
        }]
      });
    },

    // Finalize the transaction after payer approval
    onApprove: function (data, actions) {
      ...
    },

    onError: function () {
      ...
    }
  }).render('#paypal-button-container');

I have searched for this error but it didn’t generate any results. Any help on how to resolve this is much appreciated.

>Solution :

document.getElementById(‘p-amount’)

Is null. Make it be something that’s not null.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading