Problems with checkout through Paypal API (Sandbox) [Angular, Typescript]

ThatKidMike
Contributor
Contributor

I've implemented group of buttons provided by Paypal API. First of all - the basic "Paypal button" - doesn't seem to work properly. It opens a new window but it takes so much time to load and still at the end it shows me most of the time "Something went wrong" info with a button "Try again" - but trying again gives nothing (or sometimes it's: "Things don't appear to be working at the moment. Please try again later"). Along with all that in the console it shows errors regarding the "Content Security Policy and script inline („script-src)" - but these two are showing when I'm trying to actually access payment with debit or credits card in the Paypal window. Most of the time when I try to access it for the first time it just loads for a long time, shows some timeout info in console and gives me "Something went wrong".

The second weird thing happening is payment option with debit/credit card. I've tried to create two seperate apps in the Paypal developer account - got two different client ids for the API - and first payments went through without a problem but every single next one was usually returning "Order could not be captured" error in the console from typescript. Sometimes it ends up with information that they couldn't go through with the payment without any specifics.

I'm not sure what I am doing wrong - it's just basic usage of the API.

This line in the index.html file:

<script src="https://www.paypal.com/sdk/js?client-id=my_client_api_here_from_paypal_dev_account"></script>

Here's the payment.ts file with included paypal API usage:

import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';declare var paypal;

@Component({  selector: 'app-payment',  templateUrl: './payment.component.html',  styleUrls: ['./payment.component.css']
})
export class PaymentComponent implements OnInit {
  @ViewChild('paypal', { static: true }) paypalElement: ElementRef;  product = {    price: 7.7,    description: 'ticket payment'
  };  paidFor = false;

  constructor() { }  ngOnInit() {    paypal
          .Buttons({            createOrder: (data, actions) => {
              return actions.order.create({                purchase_units: [
                  {                    description: this.product.description,                    amount: {                      currency_code: 'USD',                      value: this.product.price
                    }
                  }
                ]

              });
            },            onApprove: async (data, actions) => {
              const order = await actions.order.capture();
              this.paidFor = true;              console.log(order);
            },            onError: err => {              console.log(err); <- here appears the "Order could not be captured"
            }
          })
          .render(this.paypalElement.nativeElement);
  }
Login to Me Too
4 REPLIES 4

ThatKidMike
Contributor
Contributor

Moreover, there's a new issue and it happend just by itself. When I click any button, including "Debit or Credit Card" - wich was at least working sometimes, I am getting the "Error: "/v2/checkout/orders returned status: 400 (Corr ID: xxxxxx)" The whole object with error looks like this:

update_client_config_error
{…}

env: "sandbox"

err: "/v2/checkout/orders returned status: 400 (Corr ID: 58170548fb331)\na/<@https://www.sandbox.paypal.com/smart/buttons?style.layout=vertical&style.color=gold&style.shape=rect... API id here}&sessionID=162c186e48_mte6ntc6mzi&buttonSessionID=4dec79f400_mti6mta6mdg&env=sandbox&fundingEligibility=eyJwYXlwYWwiOnsiZWxpZ2libGUiOnRydWV9LCJjYXJkIjp7ImVsaWdpYmxlIjp0cnVlLCJicmFuZGVkIjp0cnVlLCJ2ZW5kb3JzIjp7InZpc2EiOnsiZWxpZ2libGUiOnRydWV9LCJtYXN0ZXJjYXJkIjp7ImVsaWdpYmxlIjp0cnVlfSwiYW1leCI6eyJlbGlnaWJsZSI6dHJ1ZX0sImRpc2NvdmVyIjp7ImVsaWdpYmxlIjpmYWxzZX0sImhpcGVyIjp7ImVsaWdpYmxlIjpmYWxzZX0sImVsbyI6eyJlbGlnaWJsZSI6ZmFsc2V9LCJqY2IiOnsiZWxpZ2libGUiOmZhbHNlfX19LCJ2ZW5tbyI6eyJlbGlnaWJsZSI6ZmFsc2V9LCJpdGF1Ijp7ImVsaWdpYmxlIjpmYWxzZX0sImNyZWRpdCI6eyJlbGlnaWJsZSI6ZmFsc2V9LCJzZXBhIjp7ImVsaWdpYmxlIjpmYWxzZX0sImlkZWFsIjp7ImVsaWdpYmxlIjpmYWxzZX0sImJhbmNvbnRhY3QiOnsiZWxpZ2libGUiOmZhbHNlfSwiZ2lyb3BheSI6eyJlbGlnaWJsZSI6ZmFsc2V9LCJlcHMiOnsiZWxpZ2libGUiOmZhbHNlfSwic29mb3J0Ijp7ImVsaWdpYmxlIjpmYWxzZX0sIm15YmFuayI6eyJlbGlnaWJsZSI6ZmFsc2V9LCJwMjQiOnsiZWxpZ2libGUiOnRydWV9LCJ6aW1wbGVyIjp7ImVsaWdpYmxlIjpmYWxzZX0sIndlY2hhdHBheSI6eyJlbGlnaWJsZSI6ZmFsc2V9LCJwYXl1Ijp7ImVsaWdpYmxlIjpmYWxzZX0sImJsaWsiOnsiZWxpZ2libGUiOmZhbHNlfSwidHJ1c3RseSI6eyJlbGlnaWJsZSI6ZmFsc2V9LCJveHhvIjp7ImVsaWdpYmxlIjpmYWxzZX0sIm1heGltYSI6eyJlbGlnaWJsZSI6ZmFsc2V9LCJib2xldG8iOnsiZWxpZ2libGUiOmZhbHNlfX0=&platform=desktop&currency=USD&intent=capture&commit=true:1138:46183\nwindow.spb</d</n.dispatch@https://www.sandbox.paypal.com/smart/buttons?style.layout=vertical&style.color=gold&style.shape=rect... API id here}:1:51710\nOr/</<@https://www.paypal.com/sdk/js?client-id={my API id here}:1:58879\nOr/<@https://www.paypal.com/sdk/js?client-id={my API id here}:1:58738\nOr@https://www.paypal.com/sdk/js?client-id={my API id here}:1:58891\nDr/u<@https://www.paypal.com/sdk/js?client-id=AZe8oi8BkyhoGpBS0jqcsZANi0JK9bqm8pz_rwO5HWToFw4z3acuYdmsevWF... API id here}:1:68898\n\n\nhr[cr.ERROR]@https://www.paypal.com/sdk/js?client-id=AZe8oi8BkyhoGpBS0jqcsZANi0JK9bqm8pz_rwO5HWToFw4z3acuYdmsevWF... API id here}:1:58738\nOr@https://www.paypal.com/sdk/js?client-id=AZe8oi8BkyhoGpBS0jqcsZANi0JK9bqm8pz_rwO5HWToFw4z3acuYdmsevWF... API id here}:1:63918\nDr@https://www.paypal.com/sdk/js?client-id=AZe8oi8BkyhoGpBS0jqcsZANi0JK9bqm8pz_rwO5HWToFw4z3acuYdmsevWF... API id here}:1:68854\nZr/</<@https://www.paypal.com/sdk/js?client-id=AZe8oi8BkyhoGpBS0jqcsZANi0JK9bqm8pz_rwO5HWToFw4z3acuYdmsevWF..."
referer: "www.sandbox.paypal.com"
timestamp: "1575547811276"
uid: "162c186e48_mte6ntc6mzi"
<prototype>: Object { … }
buttons:1138:26537

Login to Me Too

ThatKidMike
Contributor
Contributor

Moreover I'm getting next error since yesterday - even though i've changed nothing: Error: "/v2/checkout/orders returned status: 400 (Corr ID: 58170548fb331)"

 

It has to do something with SDK error while trying to reach my API key.

 

 

Login to Me Too

precision8428
Contributor
Contributor

we are encountering the same issue. the sandbox env used to work  ok

. any solution for this problem

Login to Me Too

friendz-ch
New Community Member

Same problem here. Last test was made the 19th of December and it was working properly.

No changes were made to the codebase.

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.