条纹 - 错误500 - 无法访问付款响应

时间:2016-05-16 08:06:18

标签: php symfony stripe-payments

我目前正在开发我的网站的“付款”,我使用Symfony2和Stripe。当我使用“有效”地图付款时一切顺利,但当我测试付款错误时,我收到错误500.我想访问付款订单的回复以决定继续流程但我不知道无法这样做。 Symfony用他的错误500阻止我,尽管所有可行的var_dump我都无法调试应用程序......

有人能帮帮我吗?提前谢谢!

这是我的代码:

   /**
 * @Route("/confirm/{offerId}", name="order_confirm")
 * @Template()
 */
public function chargeAction(Request $request, $offerId)
{
    $em = $this->getDoctrine()->getManager();
    $offer = $em->getRepository("CoreBundle:Offer")->findOneById($offerId);

    $stripe = array(
        'secret_key'      => '**********',
        'publishable_key' => '*****'
    );

    $apiKey = new Stripe();
    $apiKey->setApiKey($stripe['secret_key']);

    $order = new MemberOrder();
    $form = $this->createForm(new MemberOrderType(),$order);

    $order->setDate(new \DateTime("now"));
    $order->setState("created");

    if ($request->getMethod() == 'POST') {

        $form->getData();
        $order->setAmount($offer->getPriceDisplayed());
        $token  = $_POST['stripeToken'];


        $customer = \Stripe\Customer::create(array(
            'email' => $this->getUser()->getEmail(),
            'source'  => $token
        ));

        try {

            $charge = \Stripe\Charge::create(array(
                'customer' => $customer->id,
                'currency' => 'eur',
                'amount'   => $offer->getPrice()
            ));

            var_dump($charge);die();

        } catch(\Stripe\Error\Card $e) {
            // Since it's a decline, \Stripe\Error\Card will be caught
            $body = $e->getJsonBody();
            $err  = $body['error'];

            print('Status is:' . $e->getHttpStatus() . "\n");
            print('Type is:' . $err['type'] . "\n");
            print('Code is:' . $err['code'] . "\n");
            // param is '' in this case
            print('Param is:' . $err['param'] . "\n");
            print('Message is:' . $err['message'] . "\n");
        } catch (\Stripe\Error\RateLimit $e) {
            // Too many requests made to the API too quickly
        } catch (\Stripe\Error\InvalidRequest $e) {
            // Invalid parameters were supplied to Stripe's API
        } catch (\Stripe\Error\Authentication $e) {
            // Authentication with Stripe's API failed
            // (maybe you changed API keys recently)
        } catch (\Stripe\Error\ApiConnection $e) {
            // Network communication with Stripe failed
        } catch (\Stripe\Error\Base $e) {
            // Display a very generic error to the user, and maybe send
            // yourself an email
        } catch (Exception $e) {
            // Something else happened, completely unrelated to Stripe
        }

    }

    return $this->render('OrderBundle:Order:charge.html.twig', array(
        'title_controller'      => "contact",
        'title_action'          => "Validez votre paiement",
        'form'                  => $form->createView(),
        'offer'                 => $offer
    ));


}

Symfony页面项目的答案:

Symfony

Erreur 500 您的信用卡遭到拒绝。 Retouràl'acueil

0 个答案:

没有答案