Heegner Points and Binary Quadratic Forms

I've been trying to read Gross' paper on Heegner points on $X_0(N)$ and I am stuck on a few details. The definition he is working with is that a heegner points is a pair $y=(E,E')$, where $E$ and $E'$ are elliptic curves admitting an isogeny that has cyclic kernel of order $N$ and where $E$ and $E'$ both have complex multiplication by the order $\mathcal{O}$ of discriminant $D$ in a quadratic imaginary field $K$. Gross goes on to explain that we may assume the lattice for $E$ is a fractional ideal $\mathfrak{a}$ and the lattice for $E'$ is $\mathfrak{b}$ such that the ideal $\mathfrak{n}=\mathfrak{a}\mathfrak{b}^{-1}$ is proper ideal of $\mathcal{O}$ such that the quotient $\mathcal{O}/\mathfrak{n}$ is cyclic of order $N$. It is the next line that I don't understand:

"Such an ideal will exist if and only if there is a primitive binary quadratic form of discriminant $D$ which properly represents $N$...". The line goes on, but this is one of the things I'm stuck on. I've tried googling some notes/papers on binary quadratic forms, but I can't find anything that helps me understand what a binary quadratic form representing $N$ has to say about an order admitting a cyclic quotient. An explanation or a good reference would be much appreciated.

The second and, I think, more important part of my confusion is a bit later on in the same section: Gross goes on to explain that if we have such an $\mathfrak{n}$, we can construct a heegner point as follows. Let $\mathfrak{a}$ be an invertible $\mathcal{O}$-submodule of $K$ and let $[\mathfrak{a}]$ denotes its class in $Pic(\mathcal{O})$. Let $\mathfrak{n}$ be a proper $\mathcal{O}$-ideal with cyclic quotient of order $N$, put $E=\mathbf{C}/\mathfrak{a}$, $E'=\mathbf{C}/\mathfrak{a}\mathfrak{n}^{-1}$. They are related by an obvious isogeny and thus determine a Heegner point, denoted $(\mathcal{O},\mathfrak{n},[\mathfrak{a}])$.

Next, given $y=(\mathcal{O},\mathfrak{n},[\mathfrak{a}])$, we can find the image of it in the upper-half plane by picking an oriented basis $\langle\omega_1,\omega_2\rangle$ of $\mathfrak{a}$ such that $\mathfrak{a}\mathfrak{n}^{-1}=\langle\omega_1,\omega_2/N\rangle$. Then $y$ corresponds to the orbit of $\omega_1/\omega_2$ under $\Gamma_0(N)$. Lastly, since $\tau\in K$ it follows that it satisfies $A\tau^2+b\tau+C=0$ for some integers $A,B,C$ such that $gcd(A,B,C)=1$.

Finally, what I don't understand is that Gross claims that $D=B^2-4AC, A=NA'$ from some $A'$ and $gcd(A',B,NC)$. I don't see what the $\tau$ we cooked up has to do with the discriminant of our order. I have read a paper that defined a Heegner point to be a quadratic imaginary point in the half-plane such that $\Delta(\tau)=\Delta(N\tau)$. I have seen how this would help with part of the claim above, but I don't see why in this situation, $\Delta(\tau)=\Delta(N\tau)$. In fact, it seems that everything I'm confused about here is the fact that it seems to be the case that $$D=\Delta(\tau)=\Delta(NT),$$ where $\Delta$ denotes discriminant.

Any insight into these two questions would very appreciated.

I think the following facts, which you can find in Cox's book Primes of the Form $x^2+ny^2$, will alleviate your confusion. First off, if ${\mathfrak a}=[\alpha,\beta]$ is a proper ideal of ${\mathcal O}$ then one can show that $$f(x,y) := \frac{N(\alpha x-\beta y)}{N{\mathfrak a}}$$ is a primitive binary quadratic form of discriminant $D = {\rm disc}(\mathcal O)$. Moreover, the map that associates such an ${\mathfrak a}$ to such an $f(x,y)$ induces an isomorphism from the class group ${\rm Pic } ({\mathcal O})$ onto the form class group $C(D)$. The inverse of this map is given by $$f(x,y) := ax^2+bxy+cy^2 \mapsto [a,(-b+\sqrt{D})/2] = [a,a\tau],$$ where $\tau$ is the unique point in the upper-half plane such that $f(\tau,1)=0$. It's not hard to show that we'll have ${\mathcal O} = [1,a\tau]$ for all such $\tau$ (see Addendum below). In particular, we see that ${\mathcal O}/[a,a\tau] \cong {\mathbb Z}/a{\mathbb Z}$ is cyclic.
The last piece of the puzzle is this: a positive integer $N$ is represented by a form $f(x,y)$ in $C(D)$ if and only if $N$ is the norm of some ideal in the corresponding ideal class in ${\rm Pic}({\mathcal O})$ (loc. cit., Theorem 7.7(iii)). On the other hand, $N$ is properly represented by such an $f(x,y)$ if and only if $f(x,y)$ is properly equivalent to $Nx^2+bxy+cy^2$ for some $b,c \in {\mathbb Z}$. Now the results mentioned in the preceding paragraph will take you home.
Addendum: Given a proper ideal $\mathfrak a$ of $\mathcal O$, we can recover $\mathcal O$ as the set ${\mathfrak a}^\vee = \{x \in K \mid x\mathfrak a \subset \mathfrak a \}$. This last set is easy to compute in the following special case. Let $K=\mathbb Q(\tau)$ be quadratic and suppose that $ax^2+bx+c$ is the minimal polynomial of $\tau$, where $a,b,c$ are coprime integers. Then $[1,\tau]^\vee = [1,a\tau]$ (loc. cit., Lemma 7.5).
By applying this to Gross's $\mathfrak a = [\omega_1, \omega_2] = \omega_2 [\tau, 1]$, which is a proper ideal in some order $\mathcal O$, we find that $\mathcal O = [A\tau, 1]$. Consequently,$$D = {\rm disc}({\mathcal O}) = \det \begin{pmatrix}1 & A\tau \\ 1 & A\bar{\tau} \end{pmatrix}^2 = B^2 - 4AC.$$ The assertion about $A$ can be gotten in a similar manner.