Omnipay PayPal Express中是否存在信用卡功能?还是仅在PayPal Pro中? [英] Does the creditCard function exist in Omnipay PayPal Express? Or only in PayPal Pro?

查看:96
本文介绍了Omnipay PayPal Express中是否存在信用卡功能?还是仅在PayPal Pro中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题可能类似于

This question is maybe similar to THIS and THIS but I'm not entirely sure.

我制作了一个购物车,用于在结帐时将产品详细信息和数量/总金额发送给Paypal.我正在使用Laravel 4和Omnipay Paypal插件(Paypal_Express).我可以使用"setItems"功能很好地发送产品详细信息,现在我希望使用我的用户详细信息在贝宝"摘要页面上的信用卡字段中预先填充.

I've made a shopping cart that sends the product details and quantity/total amount to Paypal on checking out. I'm using Laravel 4 and the Omnipay Paypal plugin (Paypal_Express). I can send product details fine using the 'setItems' function and am now looking to pre-populate the credit card field on the Paypal summary page with my User's details.

我在其他SO线程中看到过,例如其他人使用creditCard功能将详细信息传递到Paypal摘要信用卡信息页面.

I have seen in other SO threads such as THIS that other people use the creditCard function to pass details to the Paypal summary credit card info page.

我的问题:1)您需要使用Paypal_Pro来使信用卡功能工作吗? 我尝试(call_user_func_array() expects parameter 1 to be a valid callback, class 'Omnipay\Common\GatewayFactory' does not have a method 'creditCard')时收到此错误.

My question: 1) Do you need to be using Paypal_Pro for the creditCard function to worK? I get this error when I try (call_user_func_array() expects parameter 1 to be a valid callback, class 'Omnipay\Common\GatewayFactory' does not have a method 'creditCard').

我不想输入所有信用卡详细信息-只需输入用户名,地址等来加快整个过程...

I don't want to enter all the credit card details - Just speed the process up by entering the User's Name, Adress etc...

我也尝试更改为Paypal_Pro,但没有成功. (与上述错误相同)我更改了付款控制器中的config plus网关.

Also I tried changing to Paypal_Pro and it didn't work. (same error as above) I changed config plus gateways in my payment controller.

2)如何将PayPal_Express更改为PayPay_Pro?

2)How do you change PayPal_Express to PayPay_Pro?

我的代码:

 public function postPayment() { 


        $cart = Session::get('cart'); 

        $allProducts = [];

        foreach($cart->aContents as $productID=>$quantity){

            $product = Product::find($productID);

            // get the product id
            // load the product from the id
            // store data in the allProduct array
            $allProducts[] = array('name' => $product->name, 'quantity' => $quantity, 'price'=> $product->price);
        }

        $cardInput = array(

            'first_name' => Input::get('first_name'),
            'last_name' => Input::get('last_name'),
            'address1' => Input::get('address1'),
            'city' => Input::get('city'),
            'zip' => Input::get('zip'),
            'email' => Input::get('email')

            );

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

        $params = array( 
            'cancelUrl' => \URL::to('cancel_order'), 
            'returnUrl' => \URL::to('payment_success'), 
            'amount' => Input::get('price'), 
            'currency' => Input::get('currency'), 
            'card' => $card,    

            ); 

            Session::put('params', $params); 

            Session::save(); 

            $gateway = Omnipay::create('PayPal_Express'); 

            $gateway->setUsername('tjmusicmanagement-facilitator_api1.gmail.com'); 

            $gateway->setPassword('K2LWQVP2L8472BPY'); 

            $gateway->setSignature('AwTOuAJWzCkdc5PldYeiz.l3iy5UAwOucYW6EFLLA9zUQqXaWyEGbebq'); 

            $gateway->setTestMode(true); 

            $gateway->setLogoImageUrl(URL::to('images/logoSmall.png'));


            $response = $gateway->purchase($params)->setItems($allProducts)->send(); 

            if ($response->isSuccessful()) { 
            // payment was successful: update database
                 print_r($response); 

                }  elseif ($response->isRedirect()) { 

                // redirect to offsite payment gateway 
                    $response->redirect(); 

                } else { 

                    // payment failed: display message to customer 
                    echo $response->getMessage();

                 } 

            } 

并且被点燃的\ laravel-omnipay \ config.php也没有更改(尽管我确实尝试过更改驱动程序)

And also the ignited\laravel-omnipay\config.php is unchanged (though I did try changing the driver)

返回数组(

// The default gateway to use
'default' => 'paypal',

// Add in each gateway here
'gateways' => array(
    'paypal' => array(
        'driver' => 'PayPal_Express',
        'options' => array(
            'solutionType' => '',
            'landingPage' => '',
            'headerImageUrl' => ''
        )
    )
)

);

感谢您的光临!

这是我的getSuccessPayment函数,希望可以从其中获得用户的贝宝详细信息(包括姓名和地址等).但是我该如何指定呢?

Here is my getSuccessPayment function where I can hopefully get the users paypal details (just name and address etc) from paypal. But how and where do I specify this?

    public function getSuccessPayment() 
            {   
                $gateway = Omnipay::create('PayPal_Express');
                $gateway->setUsername('lillyloverofwar-facilitator_api1.gmail.com'); 
                $gateway->setPassword('U6LM3SG2MNCA3QE2'); 
                $gateway->setSignature('AJVP9tUtdotIeVt82RpcG7n9ld-tAdCG1Ramb1u8yZECHhSpiXc0BO04'); 
                $gateway->setTestMode(true); 

                $params = Session::get('params'); 

                $response = $gateway->completePurchase($params)->send(); 
                $paypalResponse = $response->getData(); // this is the raw response object 

                if(isset($paypalResponse['PAYMENTINFO_0_ACK']) && $paypalResponse['PAYMENTINFO_0_ACK'] === 'Success') {

                    // return View::make('successfulPayment')->with($params); 
                 //     Session::flush();
                 // Response 
                 // print_r($paypalResponse); 
                 } else { 
                 //Failed transaction 
                 } 
                 // FLUSHING SESSION HERE GETS AN ERROR
                 // Session::flush();
                 return View::make('successfulPayment'); 


                } 

推荐答案

1)我尝试时遇到此错误(call_user_func_array()期望参数1为有效的回调,类'Omnipay \ Common \ GatewayFactory'没有方法'creditCard').

1) I get this error when I try (call_user_func_array() expects parameter 1 to be a valid callback, class 'Omnipay\Common\GatewayFactory' does not have a method 'creditCard').

您不能仅在Pro或REST上在PayPal Express网关上使用信用卡.我建议您使用REST网关而不是Pro网关(REST取代Pro并具有更多功能).

You can't use credit cards on the PayPal Express gateway, only on Pro or REST. I recommend that you use the REST gateway not the Pro gateway (REST supersedes Pro and has more features).

我不想输入所有信用卡详细信息-只需输入用户名,地址等来加快整个过程...

I don't want to enter all the credit card details - Just speed the process up by entering the User's Name, Adress etc...

无论如何,如果您使用的是PayPal Express,则无需这样做,因为在用户完成PayPal登录过程并授权交易后,PayPal会为您提供必要的详细信息.

There is no need to do that if you are using PayPal Express anyway, because PayPal will provide you the necessary details after the user has gone through the PayPal login process and authorized the transaction.

我也尝试更改为Paypal_Pro,但没有成功. (与上述错误相同)我更改了付款控制器中的config plus网关.

Also I tried changing to Paypal_Pro and it didn't work. (same error as above) I changed config plus gateways in my payment controller.

2)如何将PayPal_Express更改为PayPay_Pro?

2)How do you change PayPal_Express to PayPay_Pro?

我建议您看看我的omnipay-paypal网关的分支, https://github.com. com/delatbabel/omnipay-paypal -在accept-paypal-payments分支上,还有其他提交(作为PR发送到主存储库,但尚未合并)和其他功能,例如使用REST网关购买信用卡或PayPal,以及其他API文档,包括有关如何使用REST网关的代码示例.

I suggest you have a look at my fork of the omnipay-paypal gateway, https://github.com/delatbabel/omnipay-paypal -- on the accept-paypal-payments branch there are additional commits (sent as a PR to the main repository but not merged yet) with additional features such as using the REST gateway for either Credit Card or PayPal purchases, and additional API documentation including code examples on how to use the REST gateway.

以下是使用Rest网关进行信用卡购买交易的代码示例:

Here is the code example for using the Rest gateway for a purchase transaction with a credit card:

// Create a gateway for the PayPal RestGateway
// (routes to GatewayFactory::create)
$gateway = Omnipay::create('RestGateway');

// Initialise the gateway
$gateway->initialize(array(
    'clientId' => 'MyPayPalClientId',
    'secret'   => 'MyPayPalSecret',
    'testMode' => true, // Or false when you are ready for live transactions
));

// Create a credit card object
// DO NOT USE THESE CARD VALUES -- substitute your own
// see the documentation in the class header.
$card = new CreditCard(array(
            'firstName' => 'Example',
            'lastName' => 'User',
            'number' => '4111111111111111',
            'expiryMonth'           => '01',
            'expiryYear'            => '2020',
            'cvv'                   => '123',
            'billingAddress1'       => '1 Scrubby Creek Road',
            'billingCountry'        => 'AU',
            'billingCity'           => 'Scrubby Creek',
            'billingPostcode'       => '4999',
            'billingState'          => 'QLD',
));

// Do a purchase transaction on the gateway
$transaction = $gateway->purchase(array(
    'amount'        => '10.00',
    'currency'      => 'AUD',
    'description'   => 'This is a test purchase transaction.',
    'card'          => $card,
));
$response = $transaction->send();
if ($response->isSuccessful()) {
    echo "Purchase transaction was successful!\n";
    $sale_id = $response->getTransactionReference();
    echo "Transaction reference = " . $sale_id . "\n";
}

这篇关于Omnipay PayPal Express中是否存在信用卡功能?还是仅在PayPal Pro中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆