1

我正在 Symfony2 中设置带有 Stripe 扩展的 PayumBundle。

这是我的 prepareAction :

public function prepareAction() {
    $paymentName = 'stripe_pay';

    $storage = $this->get('payum')->getStorage('XXX\XXXBundle\Entity\ClientOrder');

    $order = $storage->create();
    $order->setNumber(uniqid());
    $order->setCurrencyCode('USD');
    $order->setTotalAmount(123000); // 1.23 EUR
    $order->setDescription('A description');
    $order->setClientId($this->getUser()->getId());
    $order->setClientEmail($this->getUser()->getEmail());

    $storage->update($order);

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

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

这是我的 doneAction :

 /**
 * @Security("has_role('ROLE_ADVERTISER')")
 */
public function doneAction(Request $request) {
    $token = $this->get('payum.security.http_request_verifier')->verify($request);

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

    $status = new GetHumanStatus($token);

    $payment->execute($status);
    $order = $status->getFirstModel();


    return new JsonResponse(array(
       // 'real_status' => $real_status,
        'status' => $status->getValue(),

        'order' => array(
            'total_amount' => $order->getTotalAmount() / 100,
            'currency_code' => $order->getCurrencyCode(),
            'details' => $order->getDetails(),
        ),
    ));
}

这是付款完成后我从 done 操作中得到的 JSon 输出:

 {"status":"pending","order":{"total_amount":1230,"currency_code":"EUR","details":{"amount":123000,"currency":"eur","description":"A description","card":"tok_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","id":"ch_15hxxxxxxxxxxxxxxxxxxxxxx","object":"charge","created":1426756349,"livemode":false,"paid":true,"status":"succeeded","refunded":false,"source":{"id":"card_xxxxxxxxxxxxxxx","object":"card","last4":"5100","brand":"MasterCard","funding":"prepaid","exp_month":10,"exp_year":2022,"fingerprint":"56yrnAJxxxxxx","country":"US","name":null,"address_line1":null,"address_line2":null,"address_city":null,"address_state":null,"address_zip":null,"address_country":null,"cvc_check":"pass","address_line1_check":null,"address_zip_check":null,"dynamic_last4":null,"metadata":[],"customer":null},"captured":true,"balance_transaction":"txn_xxxxxxxIGtQu9Nu5urh","failure_message":null,"failure_code":null,"amount_refunded":0,"customer":null,"invoice":null,"dispute":null,"metadata":[],"statement_descriptor":null,"fraud_details":[],"receipt_email":null,"receipt_number":null,"shipping":null,"refunds":{"object":"list","total_count":0,"has_more":false,"url":"\/v1\/charges\/ch_15xxxxxxxxxUlgFtoii\/refunds","data":[]}}}}

如您所见,捆绑 $status->getValue() 在事务成功时返回待处理。我不知道为什么捆绑包不返回成功的值。

我是否错过了最后一步,我应该编写一些可以更新此状态的代码?我迷路了

4

1 回答 1

1

这是捆绑包的问题,​​请在此处检查修复: https ://github.com/Payum/Payum/pull/331

尝试升级payum/payum

于 2015-03-24T11:29:02.597 回答