Beispiel #1
0
<?php

include "include.php";
if (!FastSpring_Helper::is_subscribed($_SESSION["user_id"])) {
    header("Location: billing.php");
    exit;
}
$subscription_ref = FastSpring_Helper::get_subscription_ref($_SESSION["user_id"]);
if (isset($_POST["cancel"])) {
    try {
        $cancelSub = $fastspring->cancelSubscription($subscription_ref);
    } catch (FsprgException $cancelEx) {
        // die($cancelEx);
    }
} elseif (isset($_POST["renew"])) {
    try {
        $fastspring->renewSubscription($subscription_ref);
    } catch (FsprgException $renewEx) {
        // Error can be handled here
    }
} elseif (isset($_POST["update"])) {
    $update = new FsprgSubscriptionUpdate($subscription_ref);
    if (isset($_POST["productPath"])) {
        $update->productPath = $_POST["productPath"];
    }
    if (isset($_POST["tags"])) {
        $update->tags = $_POST["tags"];
    }
    if (isset($_POST["quantity"])) {
        $update->quantity = $_POST["quantity"];
    }