必须定义参数

时间:2017-01-05 14:33:15

标签: symfony

我将键条带存储在parameters.yml.dist文件中,我有以下错误信息:必须定义参数“public_key”。

public function paiementAction(Request $request)
{
    if ($request->isMethod('POST')) {
        $token = $request->get('stripeToken');

        \Stripe\Stripe::setApiKey($this->getParameter("private_key"));

        \Stripe\Charge::create(array(
            "amount" => 1000,
            "currency" => "eur",
            "source" => $token,
            "description" => "First test charge!"
        ));

        $request->getSession()->getFlashBag()->add('info', 'Paiement accepté');
    }

    return $this->render('saya25LouvreBundle:Ticket:paiement.html.twig', array(
        'public_key' =>  $this->getParameter("public_key"),
    ));
}

Vue:

<form action="{{ path('saya25_louvre_paiement') }}" method="POST">
        <script
                src="https://checkout.stripe.com/checkout.js" class="stripe-button"
                data-key="{{ public_key }}"
                data-amount="1000"
                data-name="paiement"
                data-description="test"
                data-image="http://www.france-hotel-guide.com/fr/blog/wp-content/uploads/2014/09/musee-louvre.jpg"
                data-locale="auto"
                data-zip-code="true">
        </script>
    </form>

enter image description here

1 个答案:

答案 0 :(得分:0)

检查public_keyparameters.yml.dist是否已正确配置,以及您是否已从CLI启动composer install命令(因此文件parameters.yml将更新):

>composer install

希望这个帮助