Use Paypal Pro instead of Paypal Express - Omnipay for Laravel

眉间皱痕 提交于 2020-01-06 13:56:52

问题


I have a shopping cart that currently is redirecting users to paypal directly to make their payment. I am wanting to allow customers to input their credit card on the site and paypal to process it. I have Paypal Pro account but I am having trouble using it. I am not sure how I can use the Paypal Pro package via Omnipay. In my vendors folder I have a ExpressGateway.php and a Progateway.php but not sure how to call the Progateway.php page. The only way I can see to set it is by using Omnipay::getway('paypal') which I currently do for express. What is the process i need to use in order to use Paypal Pro?

        $gateway = Omnipay::gateway('paypal');

        if(Auth::user() != NULL && Auth::user()->super_user == 1) {

            //sandbox

            $gateway->setUsername('#######');
            $gateway->setPassword('#######');
            $gateway->setSignature('#######');

            $gateway->setTestMode('true');
        } else {

            //production

            $gateway->setUsername('#######');
            $gateway->setPassword('#######');
            $gateway->setSignature('######');
        }

        $cardInput = array(
            'firstName' => $info['first_name_bill'],
            'lastName' => $info['last_name_bill'],
            'billingAddress1' => $info['street_address_1_bill'],
            'billingAddress2' => $info['street_address_2_bill'],
            'billingPhone' => $info['phone_bill'],
            'billingCity' => $info['city_bill'],
            'billingState' => $info['state_bill'],
            'billingPostCode' => $info['zip_bill'],
            'shippingAddress1' => $info['street_address_1_ship'],
            'shippingAddress2' => $info['street_address_2_ship'],
            'shippingPhone' => $info['phone_ship'],
            'shippingCity' => $info['city_ship'],
            'shippingState' => $info['state_ship'],
            'shippingPostCode' => $info['zip_ship'],
        );

        $card = Omnipay::creditCard($cardInput);

        $response = Omnipay::purchase(
            array(
                'cancelUrl' => URL::to('cart'),
                'returnUrl' => URL::action('CartController@getSuccessPayment', array('id' =>$invoice->id)),
                'amount' => Input::get('total'),
                'currency' => 'USD',
                'card' => $card,
                'description' => '#####'
            )
        )->send();`

回答1:


Set the gateway this way:

$gateway = Omnipay::gateway('Paypal_Pro');


来源:https://stackoverflow.com/questions/27490438/use-paypal-pro-instead-of-paypal-express-omnipay-for-laravel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!