Payum Stripe data flow with Symfony
<p>I am trying to create a checkout that allows a user to create an account for a fee (premium accounts, if you will). A user will create an account (marked as unpaid), the user will pay, and then on a successful payment the account is marked as paid. I can create an account, and I can make a charge. My problem is linking the two things together. I'm not sure how to reference the created account from the successful charge. Here is what I have so far.</p>

<p>Payment.php</p>

<pre><code>&lt;?php
namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Payum\Core\Model\ArrayObject;

/**
 * @ORM\Table
 * @ORM\Entity
 */
class Payment extends ArrayObject
{
    /**
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     *
     * @var integer $id
     */
    protected $id;

    /**
     * Get id
     *
     * @return integer
     */
    public function getId()
    {
        return $this-&gt;id;
    }
}
</code></pre>

<p>CreateProfileController.php
CreateAction</p>

<pre><code>public function createASquareAction(Request $request, $coupon)
{
    $newUser = new User();
    $registrationForm = $this-&gt;getRegistrationForm($newUser);

    $registrationForm-&gt;handleRequest($request);

    if ($registrationForm-&gt;isSubmitted() &amp;&amp; $registrationForm-&gt;isValid()) {
        $newSquare = new Square();
        $newSquare-&gt;setProduct($registrationForm-&gt;get('product')-&gt;getData());
        $newUser-&gt;addSquare($newSquare);

        $cost = $this-&gt;getTotal($newSquare-&gt;getProduct(), $registrationForm-&gt;get('coupon')-&gt;getData());
        $noPayment = $this-&gt;isAdmin() || $cost == 0;

        $em = $this-&gt;getDoctrine()-&gt;getManager();
        $em-&gt;persist($newUser);
        $em-&gt;flush();

        if ($noPayment) {
            $newSquare-&gt;setVerified(true);
            $em-&gt;persist($newSquare);
            $em-&gt;flush();

            return $this-&gt;redirectToRoute('edit', array(
                'id' =&gt; $newSquare-&gt;getMsid()
            ));
        } else {
            $gatewayName = 'stripe_checkout_test';
            $storage = $this-&gt;get('payum')-&gt;getStorage('AppBundle\Entity\Payment');
            $payment = $storage-&gt;create();
            $payment["amount"] = $cost;
            $payment["currency"] = 'USD';
            $payment["description"] = "Memorysquare";
            $storage-&gt;update($payment);

            $captureToken = $this-&gt;get('payum')-&gt;getTokenFactory()-&gt;createCaptureToken(
                $gatewayName,
                $payment,
                'test_payment_done' // the route to redirect after capture;
            );
            return $this-&gt;redirect($captureToken-&gt;getTargetUrl());
        }

    }

    return $this-&gt;render('create-a-square/create-a-square.html.twig', [
        'registrationForm' =&gt; $registrationForm-&gt;createView(),
        'coupon' =&gt; $coupon,
    ]);
}
</code></pre>

<p>Payment Complete Action</p>

<pre><code>public function testPaymentDoneAction(Request $request)
{
    $token = $this-&gt;get('payum')-&gt;getHttpRequestVerifier()-&gt;verify($request);

    $identity = $token-&gt;getDetails();
    $model = $this-&gt;get('payum')-&gt;getStorage($identity-&gt;getClass())-&gt;find($identity);

    $gateway = $this-&gt;get('payum')-&gt;getGateway($token-&gt;getGatewayName());

    // or Payum can fetch the model for you while executing a request (Preferred).
    $gateway-&gt;execute($status = new GetHumanStatus($token));
    $details = $status-&gt;getFirstModel();

    return new JsonResponse(array(
        'status' =&gt; $status-&gt;getValue(),
        'details' =&gt; iterator_to_array($details),
    ));
}
</code></pre>

<p>Any help to get me on track would be greatly appreciated.</p>