Example #1
0
     $account->save();
 }
 // Create Recurring Payment Profile if a subscription has been sold
 $profileResponse = array('ACK' => 'SKIPPED');
 if ($cartItem = Cart66Session::get('Cart66Cart')->getPayPalSubscriptionItem()) {
     $planIndex = Cart66Session::get('Cart66Cart')->getPayPalSubscriptionIndex();
     $plan = new Cart66PayPalSubscription($cartItem->getPayPalSubscriptionId());
     $profileResponse = $pp->CreateRecurringPaymentsProfile($token, $cartItem, $planIndex);
     if ('FAILURE' != strtoupper($profileResponse['ACK'])) {
         $paypalPaymentProfileId = $profileResponse['PROFILEID'];
         if (Cart66Common::isLoggedIn() && $account->isPayPalAccount()) {
             // Expire the current subscription and attach a new subscription
             $account->cancelSubscription('Your subscription has been canceled because you changed to a new subscription.', true);
         }
         $activeUntil = $plan->getStartTimeFormula();
         $account->attachPayPalSubscription($details, $paypalPaymentProfileId, $plan, $activeUntil);
     }
 } elseif ($cartItem = Cart66Session::get('Cart66Cart')->getMembershipProductItem()) {
     Cart66Common::log('[' . basename(__FILE__) . ' - line ' . __LINE__ . "] Got membership product from the cart after a PayPal transaction.");
     $product = new Cart66Product($cartItem->getProductId());
     $account->attachMembershipProduct($product, $details['FIRSTNAME'], $details['LASTNAME']);
 }
 // Save the order
 if ('FAILURE' != strtoupper($profileResponse['ACK'])) {
     $token = Cart66Common::postVal('token');
     $payerId = Cart66Common::postVal('PayerID');
     $opts = Cart66Setting::getValue('status_options');
     $status = '';
     if (!empty($opts)) {
         $opts = explode(',', $opts);
         $status = trim($opts[0]);