1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

Implementing payapl on a angular application [duplicate]

Discussão em 'Angular' iniciado por Bakir, Setembro 11, 2024 às 12:52.

  1. Bakir

    Bakir Guest

    I've been trying to get a sandbox enviorment app from paypal to work on my Angular App. I keep getting the error 422, no clue why. Everything works smoothly, I login on the test account, but I keep getting the 422 erorr. Yes my user id is correct

    I've added the paypal reposne at the bottom.

    I am from Bosnia.





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

    declare var paypal: any;

    @Component({
    selector: 'app-paypal',
    templateUrl: './paypal.component.html',
    styleUrls: ['./paypal.component.css']
    })
    export class PaypalComponent implements OnInit {
    @ViewChild('paypal', { static: true }) paypalElement!: ElementRef;

    product = {
    price: 1,
    description: 'Used Couch, decent condition',
    };

    paidfor = false;

    ngOnInit() {
    paypal
    .Buttons({
    createOrder: (data: any, actions: any) => {
    return actions.order.create({
    purchase_units: [
    {
    description: this.product.description,
    amount: {
    currency_code: 'USD', // Changed currency code to EUR
    value: this.product.price.toString(), // Ensure price is a string
    },
    },
    ],
    });
    },
    onApprove: async (data: any, actions: any) => {
    try {
    const order = await actions.order.capture();
    this.paidfor = true;
    console.log(order);
    } catch (error) {
    console.error('Error capturing order:', error);
    }
    },
    onError: (err: any) => {
    console.error('PayPal error:', err);
    }
    })
    .render(this.paypalElement.nativeElement);
    }
    }


    <script src="https://www.sandbox.paypal.com/sdk/js?client-id=USER_ID&currency=USD&debug=true"></script>




    // Here is the json paypal response:

    {
    "additional_properties": {},
    "body": {
    "name": "UNPROCESSABLE_ENTITY",
    "details": [
    {
    "issue": "COMPLIANCE_VIOLATION",
    "description": "Transaction cannot be processed due to a possible compliance violation. To get more information about the transaction, call Customer Support."
    }
    ],
    "message": "The requested action could not be performed, semantically incorrect, or failed business validation.",
    "debug_id": "f1358601be5d7",
    "links": [
    {
    "href": "https://developer.paypal.com/docs/api/orders/v2/#error-COMPLIANCE_VIOLATION",
    "rel": "information_link",
    "method": "GET"
    }
    ]
    },
    "duration_time": "xxxxxx",
    "header": {
    "APPLICATION_ID": "APP-80W284485P519543T",
    "Access-Control-Expose-Headers": "xxxxxx",
    "BORDER-IP": "xxxxxx",
    "CALLER_ACCT_NUM": "SYFYX283TNPKN",
    "Date": "Wed, 11 Sep 2024 15:01:51 GMT",
    "Keep-Alive": "xxxxxx",
    "PROCESSING-IP": "xxxxxx",
    "SERVER_INFO": "xxxxxx",
    "Server-Timing": "xxxxxx",
    "paypal-debug-id": "f1358601be5d7"
    },
    "status": 422
    }

    Continue reading...

Compartilhe esta Página