1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

PayPal receiving order not approved even onApprove function triggered

Discussão em 'Angular' iniciado por Andi Malaj, Setembro 12, 2024.

  1. Andi Malaj

    Andi Malaj Guest

    Trying to test sandbox createOrder Capture Order with angular 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);
    }
    }


    backend 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);
    }


    Receiving "Payer has not yet approved the Order for payment" Order is created correctly.

    Continue reading...

Compartilhe esta Página