Search code examples
paypal

PayPal Checkout UNPROCESSABLE_ENTITY: COMPLIANCE_VIOLATION


I'm trying to integrate PayPal checkout in my angular website. the integration seems to be fine but I always have an error when creating an order. Below you will find all the code I used.

index.html

<head>
    ...
    <script src="https://www.paypal.com/sdk/js?client-id=MY-APP-SANDBOX-ID"></script>
</head>

donation.component.ts

declare var paypal;
...
export class DonationComponent implements OnInit{
    ...
    ngOnInit(): void {
        ...
         paypal.Buttons({
             createOrder: (data, actions) => {
                 return actions.order.create({
                     purchase_units: [{
                         description: "Donation For Al-Darb Platform.",
                         amount: {
                             currency_code: 'USD',
                             value: this.value
                         }
                     }]
                 });
             },
             onApprove: async (data, actions) => {
                  const order = await actions.order.capture();
                  console.log(order);
             },
             onError: err => {
                 console.log(err);
             }
         }).render(this.paypalElement.nativeElement);
    }
}

donation.component.html

...
<div #paypal></div>

After executing everything works fine only on checkout (after log in to Paypal and validating the payment). I always got the following error HTTP 400:

{
    ack: "contingency",
    contingency: "UNPROCESSABLE_ENTITY"
    data: {name: "UNPROCESSABLE_ENTITY", details: [{ issue: "COMPLIANCE_VIOLATION" ...}],
    ...
}

Solution

  • COMPLIANCE_VIOLATION

    There should be more information like a debug_id you can share, but since it's Algeria I'm sure the issue is the account needing an automatic transfer method set up in order to receive payments.

    You can read the PayPal Receive Funds and Automatic Transfer Agreement for Algeria (country code dz) here (other applicable countries on its list have their own URL but agreement text is likely the same)

    As detailed there, possible automatic transfer methods include an international bank account, or a local Visa card that is able to withdraw funds (not all cards can do so).

    Once you have this set up on the account, you'll be able to receive payments. For a live account it may be possible to configure automatic transfers via https://www.sandbox.paypal.com/mep/fundsmanagement/money . Or contact PayPal's support for any further assistance, as it's not a technical issue for Stack Overflow.

    If this were a sandbox mode account