Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Symfony2中的贝宝_Symfony_Paypal_Paypal Sandbox - Fatal编程技术网

Symfony2中的贝宝

Symfony2中的贝宝,symfony,paypal,paypal-sandbox,Symfony,Paypal,Paypal Sandbox,我试图将JMSPaymentCoreBundle与JMSPaymentPaypalBundle一起使用,但我在任何地方都找不到一个明确的例子来说明如何使用它 我已经完成了文档中指定的所有步骤,但无法使其正常工作。有人能帮我吗?创建付款指令的默认方式是通过jms\u choose\u payment\u method表单: $form = $this->getFormFactory()->create('jms_choose_payment_method', null, array(

我试图将
JMSPaymentCoreBundle
JMSPaymentPaypalBundle
一起使用,但我在任何地方都找不到一个明确的例子来说明如何使用它


我已经完成了文档中指定的所有步骤,但无法使其正常工作。有人能帮我吗?

创建付款指令的默认方式是通过jms\u choose\u payment\u method表单:

$form = $this->getFormFactory()->create('jms_choose_payment_method', null, array(
        'amount'   => 12.99,
        'currency' => 'EUR',
        'default_method' => 'payment_paypal', // Optional
        'predefined_data' => array(
            'paypal_express_checkout' => array(
                'return_url' => $this->get('router')->generate('payment_complete', array(
                    'number' => $order->getOrderNumber(),
                ), true),
                'cancel_url' => $this->get('router')->generate('payment_cancel', array(
                    'number' => $order->getOrderNumber(),
                ), true)
            ),
        ),
    ));
您还可以手动创建付款指令:

        use JMS\Payment\CoreBundle\Entity\ExtendedData;
        use JMS\Payment\CoreBundle\Entity\Payment;
        use JMS\Payment\CoreBundle\PluginController\Result;
        use JMS\Payment\CoreBundle\Plugin\Exception\ActionRequiredException;
        use JMS\Payment\CoreBundle\Plugin\Exception\Action\VisitUrl;
        use JMS\Payment\CoreBundle\Entity\PaymentInstruction;


        $extendedData = new ExtendedData();
        $extendedData->set('return_url', $this->get('router')->generate('payment_complete', array(
                'number' => $order->getOrderNumber(),
            ), true));

        $extendedData->set('cancel_url', $this->get('router')->generate('payment_cancel', array(
                'number' => $order->getOrderNumber(),
            ), true));

        $instruction = new PaymentInstruction((float)$order->getCharge() > 0 ? $order->getCharge() : $order->getAmount(), 'EUR', 'paypal_express_checkout', $extendedData);
        $this->get('payment.plugin_controller')->createPaymentInstruction($instruction);

        $order->setPaymentInstruction($instruction);
        $em = $this->get('doctrine.orm.entity_manager');
        $em->persist($order);
        $em->flush();
我的付款路线如下所示:

public function completeAction(Booking $order)
{
    $instruction = $order->getPaymentInstruction();
    if (($instruction->getAmount() - $instruction->getDepositedAmount()) > 0) {
        if (null === $pendingTransaction = $instruction->getPendingTransaction()) {
            $payment = $this->get('payment.plugin_controller')->createPayment($instruction->getId(), $instruction->getAmount() - $instruction->getDepositedAmount());
        } else {
            $payment = $pendingTransaction->getPayment();
        }

        $result = $this->get('payment.plugin_controller')->approveAndDeposit($payment->getId(), $payment->getTargetAmount());
        if (Result::STATUS_PENDING === $result->getStatus()) {
            $ex = $result->getPluginException();

            if ($ex instanceof ActionRequiredException) {
                $action = $ex->getAction();

                if ($action instanceof VisitUrl) {
                    return new RedirectResponse($action->getUrl());
                }

                throw $ex;
            }
        } else if (Result::STATUS_SUCCESS !== $result->getStatus()) {
            throw new \RuntimeException('Transaction was not successful: '.$result->getReasonCode());
        }
    }

    $order->setTransactionAmount((float)$order->getAmount());
    $creditPurchased = (float)$order->getCharge() > (float)$order->getAmount() ? (float)$order->getCharge() - (float)$order->getAmount() : 0;
    $em->persist($order);
    $em->flush();
我已经通过运行它了

支持通过网络进行jms支付。这些链接介绍了如何开始

使用该捆绑包有以下几个优点:

  • 安全捕获行动
  • 有信用卡表格,可以向用户索要信用卡
  • 能够轻松设置IPN。通知操作也是安全的
  • 内置支持所有omnipay网关(25+、jms插件(+10)和payum本机LIB
  • Payum paypal lib支持定期付款和开箱即用的数字商品
  • 存储集成到支付过程中,因此您不必担心可能丢失的数据
  • 域名友好。的确,Payum提供了一些模型,但并不限制您使用它们
  • 它已经支持PSR-0记录器。在dev中,它记录执行的payum操作,以便于调试(访问symfony profile logs选项卡)
  • 可以设置多个付款(例如,一个paypal帐户用于欧盟,一个用于美国)
  • 非常可定制。添加自定义payum操作、扩展或存储
  • 有一个symfony沙盒(|)可以帮助您开始

另外,它不是功能的完整列表。

你说不工作是什么意思?你走了多远?我只需要一个表格,你可以说你想支付的金额和一个“立即支付”按钮D我想我不太明白所有这些支付包的数据流到底是什么。为什么付款指令与订单不同??这是正确的吗?1-使用输入呈现表单以写入金额(创建和刷新订单)。2-使用“选择付款方式”表单呈现(在上一个表单中)付款详情路线,提交post数据和订单号。3-更新订单实体并刷新所有其他内容。