无法使用 Symfony 向 PayPal 付款 [英] Not able to send payment to PayPal using Symfony

查看:64
本文介绍了无法使用 Symfony 向 PayPal 付款的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Symfony 并尝试使用 PayumBundle 将付款详细信息发送到 PayPal,我配置了 PayumBundle我让它工作,直到被重定向到贝宝,但没有发送付款详细信息,所以我在线搜索并遇到 this 问题,这是我看到的确切空白信息屏幕.

I am using Symfony and trying to send payment details to PayPal using PayumBundle, I got PayumBundle configured and I got it to work until getting redirected to paypal but no payment details were being sent so I searched on line and came across this question in SO and this is the exact blank information screen I am seeing.

查看答案指向的文档,我想出了以下代码段,但是当我尝试访问调用以下 prepare 操作的路由时.我遇到了错误

Looking at the documentation that answer is pointing to I came up with the following piece of code but when I try to access to route that is calling the following prepare Action. I run into an error

public function prepareAction(Request $request)
{
    $paymentName = 'paypal';

    $storage = $this->getPayum()->getStorage('ClickTeck\featuresBundle\Entity\Orders');

    /** @var \ClickTeck\featuresBundle\Entity\Orders $paymentDetails */
    $paymentDetails = $storage->create();
    $paymentDetails['PAYMENTREQUEST_0_CURRENCYCODE'] = 'USD';
    $paymentDetails['PAYMENTREQUEST_0_AMT'] = 1500;
    $storage->update($paymentDetails);

    $notifyToken = $this->getTokenFactory()->createNotifyToken($paymentName, $paymentDetails);
    $captureToken = $this->getTokenFactory()->createCaptureToken(
        $paymentName,
        $paymentDetails,
        'payment_done'
    );

    $paymentDetails['PAYMENTREQUEST_0_NOTIFYURL'] = $notifyToken->getTargetUrl();
    $paymentDetails['INVNUM'] = $paymentDetails->getId();
    $storage->update($paymentDetails);
    return $this->redirect($captureToken->getTargetUrl());

}

错误:无法使用 ClickTeck\featuresBundle\Entity\Orders 类型的对象作为数组

然后我尝试使用以下方法,但这导致 paypal 端出现另一个错误

I then tried using the following but that leads to another error at paypal end

$paymentDetails->PAYMENTREQUEST_0_CURRENCYCODE = 'USD';
$paymentDetails->PAYMENTREQUEST_0_AMT = 1500;

This transaction cannot be processed. The amount to be charged is zero

这就是我的 Order 实体的样子

This is how my Order Entity looks like

<?php

namespace ClickTeck\featuresBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Payum\Core\Model\Order as BaseOrder;


/**
 * Orders
 */
class Orders extends BaseOrder
{
    /**
     * @var integer
     */
    protected $id;


    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }
}

有人可以帮我看看这是怎么回事吗?2 天了,我一直在努力让 PayumBundle 发挥作用.

Can someone please help me find out what is this happening? Its been 2 days I am trying to make the PayumBundle work.

我将非常感谢这方面的任何帮助.如何将付款详细信息发送到 PayPal?

I will really appreciate any help in this. How do I send payment details to PayPal?

推荐答案

一点理论:

您搞砸了使用 Payum 的不同方式.第一个是完全自定义的(换句话说,付款特定格式).在这种情况下,您可以使用实现 \ArrayAccess 接口的任何内容.字段名称及其值看起来与 Paypal 文档中的相同.

You messed to different ways of using Payum. First one is completely custom (other words payment specific format). In this case you can use whatever that implements \ArrayAccess interface. The fields names and their values looks same as they are in Paypal docs.

另一种方式是在第一个上薄层增加统一性.在这里,您必须使用 Order 模型并使用可用的 setter 填充它.您仍然可以使用 setDetails 方法添加一些特定字段.

The other way is a thin layer over first one which adds unification. Here you have to use Order model and fill it using available setters. You can still add some specific fields using setDetails method.

还有第三种方法:使用您自己的模型(您命名的订单\发票\付款)并在 Payum 中提供集成.

There is a third method: Use your own model (Order\Invoice\Payment you name it) and provide an integration inside Payum.

现在答案:

这个 \ClickTeck\featuresBundle\Entity\Orders 模型是什么样的?您是实现 OrderInterface 还是从 Payum 扩展 ArrayObject?我猜第一个.如果您想使用完全自定义的解决方案,请扩展 ArrayObject 并将其用作数组.如果您需要统一的变体(您以后要其他付款),请使用订单

How does this \ClickTeck\featuresBundle\Entity\Orders model look like? Do you implement OrderInterface or extend ArrayObject from Payum? I guess the first one. If you want to use completely custom solution extend ArrayObject and use it as array. If you need unified variant (you are going to other payment in future) go with Order

这篇关于无法使用 Symfony 向 PayPal 付款的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆