Omnipay paypal integration with laravel 4(Omnipay paypal 与 laravel 4 的集成)
问题描述
我想在 laravel 4
中集成 Omnipay paypal.我经历过,但我无法理解如何去做.我没有找到任何文档.我已经通过这个,这个 和这个.我已经使用 Composer 安装了它.现在我对以下问题感到困惑.
$gateway = Omnipay::create('PayPal_Express');$gateway->setUsername('XXXXX');$gateway->setPassword('XXXX');$gateway->setSignature('XXXXX');
这里将提供谁的凭据?正在购买的人或将向其转移资金的人.我是否会提供其他人的凭据?
用户将如何进行交易?它的购买和购买功能我看过,但无法理解.在正常的 Paypal 集成中,我们通常将用户重定向到 Paypal,在那里他或她完成交易然后返回.我怎么能在这里做到这一点?
有人可以指导我完整的文档,我可以在其中阅读其整个流程吗?
根据你的观点
1-) 在这里,您将提供收款人的凭据.买家将在 PayPal 网站上提供他的凭据,他将被重定向.
2-) 拥有网关对象并设置凭据后,您将调用 omnipay 的 purchase()
方法,如下所示
$response = $gateway->purchase(大批('cancelUrl' =>'www.xyz.com/cancelurl','returnUrl' =>'www.xyz.com/returnurl','金额' =>25,'货币' =>'美元'))-> 发送();$response->redirect();
这会将用户重定向到贝宝网站,他将在那里提供他的凭据并进行交易.在 paypal 交易成功后,用户将被重定向到您在 returnurl
中指定的 URL.在 returnurl 中,您将创建与上面相同的 gateway
对象,如下所述.
$gateway = Omnipay::create('PayPal_Express');$gateway->setUsername('XXXXX');$gateway->setPassword('XXXX');$gateway->setSignature('XXXXX');$response = $gateway->completePurchase(大批('cancelUrl' =>'www.xyz.com/cancelurl','cancelUrl' =>'www.xyz.com/cancelurl','returnUrl' =>'www.xyz.com/returnurl','金额' =>25,'货币' =>'美元'))-> 发送();$data = $response->getData();//这是原始响应对象echo '';打印_r($数据);
completePurchase
方法将完成交易,您将在数组中获得响应.
注意 当用户被重定向到返回 url 时,该 URL 还包含 transaction_id 和 payer_id.:-) 我希望它很简单.
I want to integrate Omnipay paypal in laravel 4
. I have gone through but I was unable to understand how to do it. I didn't find any documentation. I have gone through this, this and this.
I have installed it using Composer. Now I am confused in following questions.
$gateway = Omnipay::create('PayPal_Express');
$gateway->setUsername('XXXXX');
$gateway->setPassword('XXXX');
$gateway->setSignature('XXXXX');
Whose credentials will be given here? The one who is buying or the one to whom money will be transferred. I either case where other's credentials will be given?
How user will do transactions? I have seen its purchase and purchasecomplete functions but couldn't be able to understand it. In normal Paypal integration, we usually redirect users to Paypal where he or she completes the transaction and then comes back. How can I do this here?
Can someone direct me the complete documentation where I can read its whole flow?
As per your points
1-) Here you will give credentials of one to whome money will be transferred. And buyer will give his credentials on PayPal site he will be redirected.
2-) After having gateway object and setting credentials you will call the purchase()
method of omnipay as follow
$response = $gateway->purchase(
array(
'cancelUrl' => 'www.xyz.com/cancelurl',
'returnUrl' => 'www.xyz.com/returnurl',
'amount' => 25,
'currency' => 'USD'
)
)->send();
$response->redirect();
This will redirect User to paypal site where he will give his credentials and do a transaction. After successful transaction at paypal user will be redirect to the URL that you have specified in returnurl
. And at returnurl you will create same gateway
object as you did above as stated below.
$gateway = Omnipay::create('PayPal_Express');
$gateway->setUsername('XXXXX');
$gateway->setPassword('XXXX');
$gateway->setSignature('XXXXX');
$response = $gateway->completePurchase(
array(
'cancelUrl' => 'www.xyz.com/cancelurl',
'cancelUrl' => 'www.xyz.com/cancelurl',
'returnUrl' => 'www.xyz.com/returnurl',
'amount' => 25,
'currency' => 'USD'
)
)->send();
$data = $response->getData(); // this is the raw response object
echo '<pre>';
print_r($data);
The completePurchase
method will complete the transaction and you will get response in array.
NOTE when user is redirected on return url, the URL also contains transaction_id and payer_id. :-) I hope it is quite simple.
这篇关于Omnipay paypal 与 laravel 4 的集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Omnipay paypal 与 laravel 4 的集成
基础教程推荐
- Doctrine 2 - 在多对多关系中记录更改 2022-01-01
- phpmyadmin 错误“#1062 - 密钥 1 的重复条目‘1’" 2022-01-01
- PHP 守护进程/worker 环境 2022-01-01
- 在 CakePHP 2.0 中使用 Html Helper 时未定义的变量 2021-01-01
- 如何在 Symfony 和 Doctrine 中实现多对多和一对多? 2022-01-01
- 在 yii2 中迁移时出现异常“找不到驱动程序" 2022-01-01
- 如何在 XAMPP 上启用 mysqli? 2021-01-01
- HTTP 与 FTP 上传 2021-01-01
- 找不到类“AppHttpControllersDB",我也无法使用新模型 2022-01-01
- 使用 PDO 转义列名 2021-01-01