thephpleague / omnipay-paypal

PayPal driver for the Omnipay PHP payment processing library
MIT License
295 stars 174 forks source link

Payee account is invalid. #PAYEE_ACCOUNT_INVALID #254

Open tbz-mikaels opened 2 years ago

tbz-mikaels commented 2 years ago

Hi, I am trying to implement PayPal Credit card functionality on laravel for Rest Api. I am receiving the "PAYEE_ACCOUNT_INVALID" error. Any idea what am I doing wrong? Any help would be really appreciated. Thanks.

This is my code snippet.

public function payment()
    {
        $gateway = Omnipay::create('PayPal_Rest');

        // Initialise the gateway
        $gateway->initialize(array(
            'clientId' => env('PAYPAL_SANDBOX_CLIENT_ID'),
            'secret' => env('PAYPAL_SANDBOX_CLIENT_SECRET'),
            'testMode' => true,
        ));

        #### Direct Credit Card Payment

        // Create a credit card object
        // DO NOT USE THESE CARD VALUES -- substitute your own
        // see the documentation in the class header.
        $card = new CreditCard([
            'firstName' => 'Example',
            'lastName' => 'User',
            'number' => '4111111111111111',
            'expiryMonth' => '01',
            'expiryYear' => '2027',
            'cvv' => '123',
        ]);

        // Do a purchase transaction on the gateway
        try {
            $transaction = $gateway->purchase([
                'amount' => '1.00',
                'currency' => 'AUD',
                'description' => 'This is a test purchase transaction.',
                'card' => $card,
            ]);

            $response = $transaction->send();
            $data = $response->getData();
            echo "Gateway purchase response data == " . print_r($data, true) . "\n";

            if ($response->isSuccessful()) {
                echo "Purchase transaction was successful!\n";
            }
        } catch (Exception $e) {
            echo "Exception caught while attempting authorize.\n";
            echo "Exception type == " . get_class($e) . "\n";
            echo "Message == " . $e->getMessage() . "\n";
        }
    }
francoisjacquet commented 1 year ago

Same error here. I have tried with various REST API apps (sandbox), and thus different Business sandbox accounts, client IDs and secrets. But always ends up with the 400 "Payee account is invalid." error. The documentation does not help much https://developer.paypal.com/docs/api/payments/v1/#error-PAYEE_ACCOUNT_INVALID I have revised the sandbox merchant accounts are indeed both Business and Verified (they are by default).

@tbz-mikaels did you find a solution to this?

Anyone?

Note that I am on localhost if that does matter.

francoisjacquet commented 1 year ago

One can read at https://developer.paypal.com/docs/api/payments/v1/

Important: The use of the PayPal REST /payments APIs to accept credit card payments is restricted. Instead, you can accept credit card payments with Braintree Direct.