paypal angular sandbox, receiving not approved order ,when Capture even OnApprove is triggered

porsha_app
Contributor
Contributor
 
Trying to test sandbox business accound Albania.
 Receiving "Payer has not yet approved the Order for payment" Order is created correctly.

 

angular code

 

 

 

try {
      this.paypal = await loadScript({ clientId : clientId  });
    } catch (error) {
        console.error("failed to load the PayPal JS SDK script", error,HttpStatusCode);
    }
    
    if (this.paypal) {
        try {
            await this.paypal.Buttons({
              
              style: {
                layout: 'vertical',
                color: 'gold',
              },
              createOrder : this.createOrderPaypal(),
              onApprove : (data: any, actions: any) => {
                //actions.order.capture().then(this.approveOrderPaypal())
                this.approveOrderPaypal()
              },


            }).render("#buttonPaypal");
        } catch (error) {
            console.error("failed to render the PayPal Buttons", error);
        }
    }

 

 

 dotnet code:

 

 

 

private async Task<dynamic> _CreateOrder(PayPalOrder newOrder,string _paypalClientId, string _paypalClientSecret, string _base)
            {
                  var accessToken = await GenerateAccessToken(_paypalClientId,_paypalClientSecret,_base);
                  var url = $"{_base}/v2/checkout/orders";
                  var payload = new
                  {
                        intent = "CAPTURE",
                        
                        purchase_units = new[]
                        {
                              new
                              {
                                    description = newOrder.Description,
                                    amount = new
                                    {
                                          currency_code = newOrder.CurrencyCode,
                                          value = newOrder.Value
                                    }
                              }
                        }
                  };

                  .....

                  var response = await client.SendAsync(request);
                  return await HandleResponse(response);
            }

            private async Task<dynamic> _CaptureOrder(string orderID, string _paypalClientId, string _paypalClientSecret, string _base)
            {
                  var accessToken = await GenerateAccessToken(_paypalClientId,_paypalClientSecret,_base);
                  var url = $"{_base}/v2/checkout/orders/{orderID}/capture";

                  .....

                  var response = await client.SendAsync(request);
                  return await HandleResponse(response);
            }

 

 

 

Login to Me Too
0 REPLIES 0

Haven't Found your Answer?

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