function subscribeWithCurrentCart() { global $messages; $userEmail = $_SESSION['userEmail']; $pmId = $_REQUEST['pmId']; $subRes = SubscriptionManager::subscribeWithCart($userEmail, $pmId, $_SESSION['cart']); if ($subRes == 'DUPLICATE_EMAIL') { addErrors(null, "This email address is already in use. Please choose another and re-submit."); return; } if ($subRes == 'INVALID_PMID') { addErrors(null, "There was an error processing this transaction. Please try again."); return; } $partnerLogin = false; $loginRes = LoginManager::loginAttempt($userEmail, $partnerLogin); $messages = $subRes; }
function test_SubscriptionManager_subscribeWithCurrentCart() { global $NEW_PAYMENT_METHOD; printResultStart(__FUNCTION__); $messages = array(); //Retrieve a productRatePlanId from the catalog $prpid; try { $catalog = Catalog::readCache(); $prp = $catalog[0]->products[0]->ratePlans[0]; echo "Using Product Rate Plan '" . $prp->Name . "' on Product '" . $prp->productName . "' <br>"; $prpid = $prp->Id; } catch (Exception $e) { array_push($messages, $e->getMessage()); printResultEnd($messages); return; } //Create a cart with one item $newCart = new Cart(); $newCart->addCartItem($prpid, null); //Test try { //Get Active Rate Plans //Pass in a unique username and a Payment method that has been created but NOT attached to an account. $subRes = SubscriptionManager::subscribeWithCart(time() . '@zillatest.com', $NEW_PAYMENT_METHOD, $newCart); //Report print_r_html($subRes); echo "Note: A successful response from this test requires an unattached Payment Method ID generated through HPM.<br>"; } catch (Exception $e) { array_push($messages, "Exception: " . $e->getMessage()); } //Report printResultEnd($messages); }