Q:

Stripe: How to set up recurring payments without plan?

First time working with Stripe API. Implementing it on WordPress using PHP and JS.
Working on a donation form. Donor should be able to choose a suggested amount (radio buttons-25,50,75,100) or pay as he/she wishes (text field after selecting 'other'). I was able to get this working.
There is a check box to set the amount up as a recurring payment. I created recurring payment plans for the fixed options like 25, 50, 100 etc. 
How do I set up a recurring payment if the donor chooses a custom amount? Can't find the relevant API. Please help.

A:

Another approach that Stripe suggests is to setup a plan with a recurring amount of $1 (or $0.01 for more flexibility) and then vary the quantity as needed.
e.g. Using the $0.01 plan approach, if I wanted to charge 12.50/month I could adjust the quantity like so:
$customer->subscriptions->create(array("plan" => "basic", "quantity" => "1250"));

Stripe Support

How can I create plans that don't have a fixed price?
Subscription Quantities

A:

First, you'll need to create a new customer.
On submit, you could use the custom amount to create a new plan:
$current_time = time();
$plan_name = strval( $current_time );

Stripe_Plan::create(array(
        "amount" => $_POST['custom-amount'],
        "interval" => "month",
        "name" => "Some Plan Name " . $_POST['customer-name'],
        "currency" => "usd",
        "id" => $plan_name
    )
);

Keep in mind that the 'id' needs to be unique. You could use the customer's name, a time stamp, or some other random method to ensure that this is always the case.
You'd then just create the subscription on the newly-added customer:
$customer = Stripe_Customer::retrieve($customer_just_created);
$customer->subscriptions->create(array("plan" => $plan_name));

You probably will be able to omit the first line above, as you should already have a customer variable assigned from when the customer was actually created.

