$taxRate = new Cart66TaxRate(); $session_token = Cart66Session::get('PayPalProToken'); // Look for the Express Checkout token $token = Cart66Common::postVal('token'); if (empty($token)) { $token = Cart66Common::getVal('token'); } if ($session_token == $token) { $username = Cart66Setting::getValue('paypalpro_api_username'); $password = Cart66Setting::getValue('paypalpro_api_password'); $signature = Cart66Setting::getValue('paypalpro_api_signature'); // Get details about the buyer $pp = new Cart66PayPalExpressCheckout(); if (CART66_PRO) { $pp = new Cart66PayPalPro(); } $details = $pp->GetExpressCheckoutDetails($token); $account = false; if (Cart66Session::get('Cart66Cart')->hasSubscriptionProducts() || Cart66Session::get('Cart66Cart')->hasMembershipProducts()) { // Set up a new Cart66Account and start by pre-populating the data or load the logged in account if ($accountId = Cart66Common::isLoggedIn()) { $account = new Cart66Account($accountId); } else { $account = new Cart66Account(); $account->firstName = $details['FIRSTNAME']; $account->lastName = $details['LASTNAME']; $account->email = $details['EMAIL']; if (isset($_POST['account'])) { $acctData = $_POST['account']; Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] New Account Data: " . print_r($acctData, true));
public function cancelPayPalSubscription($attrs) { $link = ''; if (Cart66Common::isLoggedIn()) { $account = new Cart66Account(Cart66Session::get('Cart66AccountId')); if ($account->isPayPalAccount()) { // Look for account cancelation request if (isset($_GET['cart66-task']) && $_GET['cart66-task'] == 'CancelRecurringPaymentsProfile') { Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Caught task: CancelPaymentsProfileStatus"); $sub = new Cart66AccountSubscription($account->getCurrentAccountSubscriptionId()); $profileId = $sub->paypalBillingProfileId; $note = "Your subscription has been canceled per your request."; $action = "Cancel"; $pp = new Cart66PayPalPro(); $pp->ManageRecurringPaymentsProfileStatus($profileId, $action, $note); $url = str_replace('cart66-task=CancelRecurringPaymentsProfile', '', Cart66Common::getCurrentPageUrl()); $link = "We sent a cancelation request to PayPal. It may take a minute or two for the cancelation process to complete and for your account status to be changed."; } elseif ($subId = $account->getCurrentAccountSubscriptionId()) { $sub = new Cart66AccountSubscription($subId); if ($sub->status == 'active') { $url = $sub->getSubscriptionManagementLink(); $text = isset($attrs['text']) ? $attrs['text'] : 'Cancel your subscription'; $link = "<a id='Cart66CancelPayPalSubscription' href=\"{$url}\">{$text}</a>"; } else { $link = "Your account is {$sub->status} but will remain active until " . date(get_option('date_format'), strtotime($sub->activeUntil)); } } } } Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Cancel paypal account link for logged in user: {$link}"); return $link; }
/** * Cancel remote PayPal subscription and set local status to canceled. * If expire is set to true, also change the active until date to today. * * @param string $note The note to send to PayPal describing the reason for cancelation * @param boolean $expire If true, change the active_until date to today */ public function cancelPayPalSubscription($note = 'Your subscription has been canceled per your request.', $expire = false) { if ($this->id > 0) { $pp = new Cart66PayPalPro(); $profileId = $this->paypalBillingProfileId; $pp->ManageRecurringPaymentsProfileStatus($profileId, 'Cancel', $note); $this->active = 0; $this->status = 'canceled'; if ($expire) { $this->activeUntil = date('Y-m-d 00:00:00', Cart66Common::localTs()); } $this->save(); } }