When using the Payments API, the first thing you'll do is create an invoice representing the customer's details and what subscription plan they are subscribing to. Note: the subscriber does not have to exist in Spreedly already - they will be created for you automatically if necessary.
[ ~ ] $ curl -u 28068fe710ed67dd38de8bcd48b0544cbabcfb03:X \
-H 'Content-Type: application/xml' \
-d '
<invoice>
<subscription-plan-id>3</subscription-plan-id>
<subscriber>
<customer-id>44</customer-id>
<screen-name>joe</screen-name>
<email>joe@example.com</email>
</subscriber>
</invoice>' \
https://spreedly.com/api/v4/meresheep/invoices.xml
Here is the response:
<?xml version="1.0" encoding="UTF-8"?>
<invoice>
<closed type="boolean">false</closed>
<created-at type="datetime">2009-07-02T18:56:22Z</created-at>
<token>6a54b2f6c6c6ce4d3128eef5929054badc646929</token>
<updated-at type="datetime">2009-07-02T18:56:22Z</updated-at>
<subscriber-store-credit>$0.00</subscriber-store-credit>
<price>$24.00</price>
<amount type="decimal">24.0</amount>
<currency-code>USD</currency-code>
<line-items type="array">
<line-item>
<amount type="decimal">24.0</amount>
<currency-code>USD</currency-code>
<description>3 months</description>
<price>$24.00</price>
</line-item>
</line-items>
<subscriber>
<active-until type="datetime" nil="true"></active-until>
<billing-first-name nil="true"></billing-first-name>
<billing-last-name nil="true"></billing-last-name>
<created-at type="datetime">2009-07-02T17:27:26Z</created-at>
<customer-id>44</customer-id>
<eligible-for-free-trial type="boolean">true</eligible-for-free-trial>
<email nil="true"></email>
<lifetime-subscription type="boolean">false</lifetime-subscription>
<screen-name>joe</screen-name>
<store-credit type="decimal">0.0</store-credit>
<store-credit-currency-code>USD</store-credit-currency-code>
<token>f3feb1b75abcc2b31ed509ebbc23f0a8c73caa09</token>
<updated-at type="datetime">2009-07-02T17:27:26Z</updated-at>
<recurring type="boolean">false</recurring>
<card-expires-before-next-auto-renew type="boolean">false</card-expires-before-next-auto-renew>
<subscription-plan-name></subscription-plan-name>
<active type="boolean">false</active>
<on-trial type="boolean">false</on-trial>
<feature-level type="string"></feature-level>
</subscriber>
</invoice>
If successful, a 201 (Created) status code is returned.
The xml of the invoice is returned in the response body.
A 404 (Not Found) status code is returned if there is no subscription plan with the ID you specified.
A 422 (Unprocessable Entity) is returned if the subscriber info you pass is invalid or the request is malformed. Spreedly will additionally return an XML array of error information.
A 403 (Forbidden) is returned if the subscription plan is disabled.