Payum Bundle发送空付款 - 和paypal接受它:) :(

时间:2014-01-22 08:15:14

标签: php symfony paypal payum

我从此示例http://payum.forma-dev.com/documentation/0.8/PayumBundle/simple_purchase_examples/paypal_express_checkout

配置Bundle

当我进入/付款时,我被重定向到PayPal网站 - 但没有任何相关信息。

enter image description here

有信息 - 您可以看到详细信息 - 但事实并非如此 - 我接受付款(不知道价格和解决方案 - 以及付款成功!?

这个Bundle可以使用还是工作阶段?

配置:

payum:
    security:
        token_storage:
            ed\partnerBundle\Entity\PayumSecurityToken:
                doctrine:
                    driver: orm
    contexts:
        frei_payment:
            paypal_express_checkout_nvp:
              api:
                  options:
                      username:  'myusername'
                      password:  'mypass'
                      signature: 'mysing'
                      sandbox: false
            storages:
                ed\partnerBundle\Entity\PaymentDetails:
                    doctrine:
                        driver: orm

路由:

payment_start:
    pattern:  /payment
    defaults: { _controller: edpartnerBundle:Payment:preparePaypalExpressCheckoutPayment }

edpartner_payment_done:
    pattern:  /payment/done
    defaults: { _controller: edpartnerBundle:Payment:done }
支付控制器中的

操作:

  public function doneAction(){

        $request = $this->getRequest();

        $token = $this->get('payum.security.http_request_verifier')->verify($request);

        $payment = $this->get('payum')->getPayment($token->getPaymentName());

        $status = new BinaryMaskStatusRequest($token);
        $payment->execute($status);

        if ($status->isSuccess()) {
            $this->getUser()->addCredits(100);
            $this->getRequest()->getSession()->getFlashBag()->set(
                'notice',
                'Payment success. Credits were added'
            );
        } else if ($status->isPending()) {
            $this->getRequest()->getSession()->getFlashBag()->set(
                'notice',
                'Payment is still pending. Credits were not added'
            );
        } else {
            $this->getRequest()->getSession()->getFlashBag()->set('error', 'Payment failed');
        }

        return $this->redirect('homepage');



    }

    /**
     */
    public function preparePaypalExpressCheckoutPaymentAction(){

        $paymentName = 'my_payment';

        $storage = $this->get('payum')->getStorageForClass(
            'ed\partnerBundle\Entity\PaymentDetails',
            $paymentName
        );

        /** @var \ed\partnerBundle\Entity\PaymentDetails $paymentDetails */
        $paymentDetails = $storage->createModel();
        $paymentDetails['PAYMENTREQUEST_0_CURRENCYCODE'] = 'USD';
        $paymentDetails['PAYMENTREQUEST_0_AMT'] = 1.23;
        $storage->updateModel($paymentDetails);

        $captureToken = $this->get('payum.security.token_factory')->createCaptureToken(
            $paymentName,
            $paymentDetails,
            'edpartner_payment_done' // the route to redirect after capture;
        );

        $paymentDetails['INVNUM'] = $paymentDetails->getId();
        $paymentDetails['RETURNURL'] = $captureToken->getTargetUrl();
        $paymentDetails['CANCELURL'] = $captureToken->getTargetUrl();
        $storage->updateModel($paymentDetails);


        return $this->redirect($captureToken->getTargetUrl());



    }

1 个答案:

答案 0 :(得分:3)

您描述的行为是可能的,这里有任何问题。要查看付款详细信息,您必须配置其他字段。 sandbox

中有一个例子