作者热门文章
- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我有测试代码,但如何配置它以使用 paypal 付款?
这是测试代码,但如果我想用 paypal 做呢?我应该怎么做?
$cardInput = [
'number' => '4444333322221111',
'firstName' => 'MR. WALTER WHITE',
'expiryMonth' => '03',
'expiryYear' => '16',
'cvv' => '333',
];
$card = Omnipay::creditCard($cardInput);
$response = Omnipay::purchase([
'amount' => '100.00',
'returnUrl' => 'http://bobjones.com/payment/return',
'cancelUrl' => 'http://bobjones.com/payment/cancel',
'card' => $cardInput
])->send();
dd($response->getMessage());
这是文档:https://github.com/ignited/laravel-omnipay
谢谢
最佳答案
我建议您查看 OmniPay docs对于这样的问题,因为它会为您提供如何为不同提供商创建付款的引用点。
请务必注意,除非您在美国,否则您的用户将被重定向到 PayPal 以输入他们的信用卡详细信息等。
但作为示例,它看起来像这样:
public function postPayment()
{
$params = array(
'cancelUrl' => 'http://localhost/cancel_order',
'returnUrl' => 'http://localhost/payment_success',
'name' => //Fetch product name,
'description' => //Fetch product description,
'amount' => //Fetch product price,
'currency' => //Fetch the currency
);
Session::put('params', $params);
Session::save();
$gateway = Omnipay::create('PayPal_Express');
$gateway->setUsername('paypal account');
$gateway->setPassword('paypal password');
$gateway->setSignature('paypal-signature');
$gateway->setTestMode(true);
$response = $gateway->purchase($params)->send();
从那里您只需使用响应来确定如何处理付款。
虽然是为 Laravel 4.2 编写的,this guide可能有助于指导您学习如何使用 OmniPay。
关于php - 如何在 Laravel 5 中使用 Omnipay?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34242128/
我是一名优秀的程序员,十分优秀!