如何通过 Omnipay 将 YooMoney 连接到 PHP
How to connect YooMoney to PHP via Omnipay
网站需要添加与 YooMoney 的集成,即通过此网站添加支付方式。目前,该网站有通过 PayPal 和银行卡支付的方式,它们都是通过 Omnipay 支付网关实现的,必须通过它添加 YooMoney。问题是我从未分别使用过支付网关或 Omnipay。也许有人已经完成了与 YooMoney 的集成,并且能够逐点详细解释如何以及做什么,最好是使用代码示例。你的帮助会很有帮助:)
P.S。 YooMoney 的驱动程序已经存在:https://github.com/leonardjke/omnipay-yoomoney
/** @var YooMoneyGateway $gateway */
$gateway = Omnipay::create('Yoomoney');
$gateway->setReceiver(config('gateways.yoomoney_receiver'));
$gateway->setSecret(config('gateways.yoomoney_secret'));
$gateway->setQuickpayForm('shop');
$response = $gateway->purchase([
'amount' => $payment->price,
'transactionId' => $transactionId,
'description' => $payment->description,
'currency' => 'RUB',
])->send();
$url = $response->getRedirectUrl() . '?' . http_build_query($response->getRedirectData());
return redirect($url);
网站需要添加与 YooMoney 的集成,即通过此网站添加支付方式。目前,该网站有通过 PayPal 和银行卡支付的方式,它们都是通过 Omnipay 支付网关实现的,必须通过它添加 YooMoney。问题是我从未分别使用过支付网关或 Omnipay。也许有人已经完成了与 YooMoney 的集成,并且能够逐点详细解释如何以及做什么,最好是使用代码示例。你的帮助会很有帮助:)
P.S。 YooMoney 的驱动程序已经存在:https://github.com/leonardjke/omnipay-yoomoney
/** @var YooMoneyGateway $gateway */
$gateway = Omnipay::create('Yoomoney');
$gateway->setReceiver(config('gateways.yoomoney_receiver'));
$gateway->setSecret(config('gateways.yoomoney_secret'));
$gateway->setQuickpayForm('shop');
$response = $gateway->purchase([
'amount' => $payment->price,
'transactionId' => $transactionId,
'description' => $payment->description,
'currency' => 'RUB',
])->send();
$url = $response->getRedirectUrl() . '?' . http_build_query($response->getRedirectData());
return redirect($url);