How to create and manage billing plans with PayPal?
<p>I have a test function <code>createBillingPlan()</code> to create a billing plan that seems to work since <code>billingPlan.create(apiContext);</code> returns a <code>Plan</code> object with an ID set and no exceptions are being thrown.</p>

<p>However, I have no idea where I can see the overview of all my billing plans. I actually don't even understand why I cannot create such billing plans on <a href="http://www.paypal.com" rel="nofollow">http://www.paypal.com</a> directly.</p>

<p>Does this mean that I have to write <strong>my own</strong> PayPal client here? Looking at the API I don't see a way to create such billing plans using the web interface or am I just looking at the wrong place?</p>

<p>I thought it would be more like .. creating an app, then get a web interface provided from PayPal that would allow me to create all these things by hand. But from the looks of it I come to the conclusion that I'd have to write this all myself. </p>

<pre class="lang-java prettyprint-override"><code>public void createBillingPlan() throws PayPalRESTException {

    int frequencyInterval = 1;

    // Charge models

    List&lt;ChargeModels&gt; chargeModelsList = new ArrayList&lt;&gt;();

    ChargeModels chargeModels = new ChargeModels("TAX", new Currency("EUR", "7.48"));

    chargeModelsList.add(chargeModels);

    // Payment definition

    List&lt;PaymentDefinition&gt; paymentDefinitionList = new ArrayList&lt;&gt;();

    PaymentDefinition paymentDefinition = new PaymentDefinition();
    paymentDefinition.setId("paymentDefinitionId");
    paymentDefinition.setName("paymentDefinitionName");
    paymentDefinition.setType("REGULAR");
    paymentDefinition.setFrequencyInterval("" + frequencyInterval);
    paymentDefinition.setFrequency("MONTH");
    paymentDefinition.setCycles("0");
    paymentDefinition.setAmount(new Currency("EUR", "29.90"));
    paymentDefinition.setChargeModels(chargeModelsList);

    paymentDefinitionList.add(paymentDefinition);

    // Merchant preferences

    MerchantPreferences merchantPreferences = new MerchantPreferences();
    merchantPreferences.setSetupFee(new Currency("EUR", "0.0"));
    merchantPreferences.setCancelUrl("http://mz.life/cancel");
    merchantPreferences.setReturnUrl("http://mz.life/return");
    //merchantPreferences.setNotifyUrl("http://mz.life/notify");
    merchantPreferences.setMaxFailAttempts("2");
    merchantPreferences.setAutoBillAmount("YES");
    //merchantPreferences.setAcceptedPaymentType(acceptedPaymentType)
    //merchantPreferences.setCharSet("UTF-8");

    // Create the billing plan

    Plan billingPlan = new Plan("name", "description", "INFINITE");
    billingPlan.setPaymentDefinitions(paymentDefinitionList);
    billingPlan.setMerchantPreferences(merchantPreferences);

    APIContext apiContext = GenerateAccessToken.getApiContext();

    try {
        Plan createdBillingPlan = billingPlan.create(apiContext);

        LOGGER.info("New plan: " + createdBillingPlan.getId());
        LOGGER.info("");
    } catch (PayPalRESTException e) {
        LOGGER.error("", e);
        throw e;
    }
}
</code></pre>