/**
  * @param Payment $payment
  * 
  * @return array
  */
 private function convertPaymentToArray(Payment $payment)
 {
     return array('amount' => $payment->getAmount(), 'currency' => $payment->getCurrency(), 'ipn_url' => $payment->getIpnUrl(), 'return_url' => $payment->getReturnUrl(), 'cancel_url' => $payment->getCancelUrl(), 'email' => $payment->getEmail(), 'first_name' => $payment->getFirstName(), 'last_name' => $payment->getLastName(), 'customer' => $payment->getCustomer(), 'order' => $payment->getOrder(), 'custom_data' => $payment->getCustomData(), 'origin' => $payment->getOrigin());
 }
    /**
     * @param \Alcalyn\PayplugBundle\Model\Payment $payment
     * @param boolean $test whether it is a test payment
     * 
     * @return string
     */
    private function getCodeToGeneratePayment(Payment $payment, $test)
    {
        $code = <<<'CODE'
    $payment = new Payment();

    $payment

CODE;
        $code .= '        ->setAmount(' . $payment->getAmount() . ')' . PHP_EOL;
        $attributes = array('Currency', 'FirstName', 'LastName', 'Email', 'ReturnUrl', 'CancelUrl', 'Customer', 'Customer', 'Order', 'CustomData', 'Origin');
        foreach ($attributes as $attribute) {
            if (null !== $payment->{'get' . $attribute}()) {
                $code .= '        ->set' . $attribute . '(\'' . $payment->{'get' . $attribute}() . '\')' . PHP_EOL;
            }
        }
        $code .= '    ;' . PHP_EOL . PHP_EOL;
        $code .= '    // Get Payplug ' . ($test ? 'test ' : '') . 'payment service' . PHP_EOL;
        $code .= '    $payplugPayment = $this->get(\'payplug.payment' . ($test ? '.test' : '') . '\');' . PHP_EOL . PHP_EOL;
        $code .= '    // Generate payment url' . PHP_EOL;
        $code .= '    $paymentUrl = $payplugPayment->generateUrl($payment);' . PHP_EOL;
        return $code;
    }