在Omnipay中使用Paypal Pro [英] Using Paypal Pro in Omnipay

查看:192
本文介绍了在Omnipay中使用Paypal Pro的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已成功将PayPal Express集成到我的网站中.现在,我想使用PayPal Pro,以便用户可以在网站上输入他们的卡号.我的沙盒可以接受PayPal Pro付款,但过程似乎有所不同.

在PayPal Express中,我使用purchase()将用户重定向到PayPal进行付款.他们回来后,我会使用completePurchase()从他们那里实际拿走钱.

PayPal Pro有什么区别?查看ProGateway.php文件,没有可用的completePurchase()方法.看起来就像在那个地方(与ExpressGateway.phpcapture.php相比,当我打电话时它告诉我The transactionReference parameter is required.因此,不确定那是我应该打电话的内容

以下是整个ProGateway.php文件,任何可以告诉我使用哪种方法的人.

public function getDefaultParameters()
{
    return array(
        'username' => '',
        'password' => '',
        'signature' => '',
        'testMode' => false,
    );
}

public function getUsername()
{
    return $this->getParameter('username');
}

public function setUsername($value)
{
    return $this->setParameter('username', $value);
}

public function getPassword()
{
    return $this->getParameter('password');
}

public function setPassword($value)
{
    return $this->setParameter('password', $value);
}

public function getSignature()
{
    return $this->getParameter('signature');
}

public function setSignature($value)
{
    return $this->setParameter('signature', $value);
}

public function authorize(array $parameters = array())
{
    return $this->createRequest('\Omnipay\PayPal\Message\ProAuthorizeRequest', $parameters);
}

public function purchase(array $parameters = array())
{
    return $this->createRequest('\Omnipay\PayPal\Message\ProPurchaseRequest', $parameters);
}

public function capture(array $parameters = array())
{
    return $this->createRequest('\Omnipay\PayPal\Message\CaptureRequest', $parameters);
}

public function refund(array $parameters = array())
{
    return $this->createRequest('\Omnipay\PayPal\Message\RefundRequest', $parameters);
}

public function fetchTransaction(array $parameters = array())
{
    return $this->createRequest('\Omnipay\PayPal\Message\FetchTransactionRequest', $parameters);
}

} `

解决方案

首先,我将指向您自己的omnipay-paypal网关的分支:

在PayPal Pro(原始网关或REST)中,您无需致电completePurchase即可收取他们的钱,而buy()调用将做到这一点.

还有另一种方法是authorize(),执行此操作后,您可以使用capture().那是您要在某个时候获取某人的卡详细信息的地方,然后在以后的某个时刻(可能是当订单完成时),调用capture()完成销售并取走他们的钱.在我的仓库中,我添加了更多的API注释和代码示例,以便您了解其工作原理.

也可以在我的回购协议中(在accept-paypal-pays分支上,不合并到主要的全能支付帐户中),您可以给人们选择通过信用卡或使用其Paypal帐户付款的选项.在这种情况下,您只需不提供信用卡号或令牌,然后就可以将客户重定向到PayPal网站,以其PayPal登录ID和密码进行登录.根据Express Gateway,您需要为PayPal提供回调API端点,以便在购买成功(或失败)后将客户重定向到.

我还应该指出,仅在英国和美国支持在您自己的站点上接受信用卡详细信息,然后转发到PayPal(PayPal称为直接信用卡付款").如果您不在这两个国家/地区中,那么这将在沙箱中正常运行,但在生产环境中将无法正常工作.

I have successfully integrated PayPal express into my website. Now, I want to use PayPal Pro so users can input their card number on the site. I have my sandbox to accept PayPal Pro payments but the process seems different.

In PayPal Express I use purchase() to redirect the user to PayPal to make the payment. Once they return I use completePurchase() to actually take the money from them.

What's the difference in PayPal Pro? Looking at the ProGateway.php file there is no completePurchase() method available. Looks like in it's place (compared to ExpressGateway.php is capture.php and when I call that it's telling me the The transactionReference parameter is required. So, not sure if that's what I should be calling

Here is the entire ProGateway.php file for anyone that may can tell me which methods I use.

public function getDefaultParameters()
{
    return array(
        'username' => '',
        'password' => '',
        'signature' => '',
        'testMode' => false,
    );
}

public function getUsername()
{
    return $this->getParameter('username');
}

public function setUsername($value)
{
    return $this->setParameter('username', $value);
}

public function getPassword()
{
    return $this->getParameter('password');
}

public function setPassword($value)
{
    return $this->setParameter('password', $value);
}

public function getSignature()
{
    return $this->getParameter('signature');
}

public function setSignature($value)
{
    return $this->setParameter('signature', $value);
}

public function authorize(array $parameters = array())
{
    return $this->createRequest('\Omnipay\PayPal\Message\ProAuthorizeRequest', $parameters);
}

public function purchase(array $parameters = array())
{
    return $this->createRequest('\Omnipay\PayPal\Message\ProPurchaseRequest', $parameters);
}

public function capture(array $parameters = array())
{
    return $this->createRequest('\Omnipay\PayPal\Message\CaptureRequest', $parameters);
}

public function refund(array $parameters = array())
{
    return $this->createRequest('\Omnipay\PayPal\Message\RefundRequest', $parameters);
}

public function fetchTransaction(array $parameters = array())
{
    return $this->createRequest('\Omnipay\PayPal\Message\FetchTransactionRequest', $parameters);
}

} `

解决方案

First I will point you at my own fork of the omnipay-paypal gateway: https://github.com/delatbabel/omnipay-paypal -- there are 2 branches on that fork which I have submitted as PRs to the main phpleague branch but they haven't been merged yet. You might want to take a look at the code in the accept-paypal-payments branch.

By "integrate PayPal Pro" I think you mean to use the REST gateway which has pretty much superseded the original PayPal PRO API. So you should be looking at using the RestGateway class not the ProGateway class. That is the best way to allow customers to enter their card details on the site.

In PayPal Pro (original gateway or REST) you do not need to call completePurchase to take their money -- the purchase() call will do that.

There is one additional method being authorize(), and after doing that you can use a capture(). That is where you want to take someone's card details at some point, and at a later point (perhaps when the order is complete), call capture() to complete the sale and take their money. In my repo I have added more extensive API comments and code examples so you can see how this works.

Also in my repo (on the accept-paypal-payments branch, not merged into the main omnipay one) you can give people the option of paying via credit card or using their paypal account. In that case you simply don't provide a credit card number or token, and the customer can then be redirected to the PayPal web site to log in with their PayPal login id and password for payment. As per the Express Gateway you need to provide callback API endpoints for PayPal to redirect your customer to once the purchase succeeds (or fails).

I should also point out that accepting credit card details on your own site and then forwarding to PayPal (what PayPal refer to as "Direct credit card payment") are only supported in the UK and the USA. If you're outside those two countries then this will work fine in sandbox but not in production.

这篇关于在Omnipay中使用Paypal Pro的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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