gpt4 book ai didi

php - 如何在 Laravel 5 中使用 Omnipay?

转载 作者:搜寻专家 更新时间:2023-10-31 21:04:54 32 4
gpt4 key购买 nike

我有测试代码,但如何配置它以使用 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/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com