Search code examples
symfonystripe-paymentspayum

PayumBundle with stripe always return Pending even if payment succeeded


I am setuping PayumBundle with Stripe extension in Symfony2.

Here is my 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());
}

And here is my 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(),
        ),
    ));
}

And this is the JSon output i get from my done action when a payment is done :

 {"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":[]}}}}

As you see the bundle $status->getValue() return pending while the transaction succeded. I have no idea of why the bundle don't return a succeeded value.

Does i miss a last step where i should code something that will update this status ? I'm lost


Solution

  • It was an issue with the bundle, check fixing it here: https://github.com/Payum/Payum/pull/331

    Try to upgrade payum/payum