我已经实现了一个 Omnipay 网关,现在我想在使用 1.3、1.0payum
和payum-bundle
1.0的 Sylius 中使用它omnipay-bridge
。
我已经在以下位置配置了网关(它是一个显示单独付款页面的重定向网关,一旦付款完成,将调用returnUrl
,并且不涉及信用卡)app/config/config.yml
:
payum:
gateways:
my_gateway:
omnipay_offsite:
type: MyOmnipayGateway
options:
gatewayOption: 1
anotherOption: 2
actions:
- sylius.payum.my_gateway.action.convert_payment
我也将网关添加到sylius_payment
部分
sylius_payment:
gateways:
my_gateway: My Payment Service
我添加了一个将付款转换为的操作vendor/sylius/sylius/src/Sylius/Bundle/PayumBundle/Resources/config/services.xml
:
<service id="sylius.payum.my_gateway.action.convert_payment" class="Sylius\Bundle\PayumBundle\Action\ConvertPaymentToMyGatewayAction">
<tag name="payum.action" context="my_gateway" />
</service>
并实现了ConvertPaymentToMyGatewayAction
现在将请求有效负载转换为预期格式(用作ConvertPaymentToPaypalExpressAction
参考)的类。
我还添加MyOmnipayGateway
到网关列表中vendor/omnipay/common/composer.json
以获取过去的错误,即不支持网关。
现在,当我完成订单时,我成功地重定向到我的实际支付站点,一旦支付完成,就会返回到returnUrl
查询字符串中提供的预期参数。然而,这里执行返回OffsiteCaptureAction
并purchase
使用与最初调用相同的参数进行调用,我一次又一次地重定向到支付站点。
当前问题:
如何避免在
vendor
文件夹下添加配置选项 - 即提到services.xml
的和 Omnipay 的composer.json
?在哪里处理付款响应?我需要检查
returnUrl
查询字符串参数(在我的网关中实现completePurchase
)。
谢谢!
编辑:我错过了$details
在我的转换操作中进行的初始化,每次都$details = $payment->getDetails();
导致错误,因此在循环中执行。我现在可以正确处理付款,即。问题 2 几乎可以通过上面的配置和这个处理程序解决_completeCaptureRequired
purchase
<?php
namespace Sylius\Bundle\PayumBundle\Action;
use Payum\Core\Action\ActionInterface;
use Payum\Core\Exception\RequestNotSupportedException;
use Payum\Core\Request\Convert;
use Sylius\Component\Core\Model\PaymentInterface;
class ConvertPaymentToMyGatewayAction implements ActionInterface
{
public function execute($request)
{
RequestNotSupportedException::assertSupports($this, $request);
/** @var PaymentInterface $payment */
$payment = $request->getSource();
$order = $payment->getOrder();
$details = $payment->getDetails();
// Fill the correct parameters here
$request->setResult($details);
}
public function supports($request)
{
return
$request instanceof Convert &&
$request->getSource() instanceof PaymentInterface &&
$request->getTo() === 'array'
;
}
}