本文整理汇总了PHP中Subscription::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Subscription::get方法的具体用法?PHP Subscription::get怎么用?PHP Subscription::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subscription
的用法示例。
在下文中一共展示了Subscription::get方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Check stripe data.
*
* @access public
* @return void
*/
public function run()
{
try {
$paymentGateway = Payment_gateways::findOneActiveBySlug('stripe');
if ($paymentGateway->exists()) {
\Stripe\Stripe::setApiKey($paymentGateway->getFieldValue('apiKey'));
$subscriptions = new Subscription();
$allSubscriptions = $subscriptions->get();
/* @var Subscription $_subscription */
foreach ($allSubscriptions as $_subscription) {
if ($_subscription->end_date <= strtotime('now')) {
$paymentTransaction = $_subscription->payment_transaction->get();
if ($paymentTransaction->system == 'stripe') {
$user = new User($_subscription->user_id);
$customer = \Stripe\Customer::retrieve($user->stripe_id);
$subscription = $customer->subscriptions->retrieve($paymentTransaction->payment_id);
if ($subscription->status == 'active') {
$date = new DateTime();
$date->setTimestamp($subscription->current_period_end);
$_subscription->end_date = $date->format('Y-m-d');
$_subscription->activate();
$_subscription->save();
}
}
}
}
log_message('CRON_SUCCESS', __FUNCTION__);
} else {
log_message('CRON_ERROR', __FUNCTION__ . ' > ' . 'No Stripe Api key.');
}
} catch (Exception $e) {
log_message('CRON_ERROR', __FUNCTION__ . ' > ' . $e->getMessage());
}
}
示例2: run
/**
* Check paypal data. If acccount expired - block it
*
* @access public
* @return void
*/
public function run()
{
try {
$subscriptions = new Subscription();
$allSubscriptions = $subscriptions->get();
foreach ($allSubscriptions as $_subscription) {
if ($_subscription->end_date <= strtotime('now')) {
$user = new User($_subscription->user_id);
if ($user->id != null) {
$user->active = false;
$user->save();
}
}
}
log_message('CRON_SUCCESS', __FUNCTION__);
} catch (Exception $e) {
log_message('CRON_ERROR', __FUNCTION__ . ' > ' . $e->getMessage());
}
}
示例3: cancelSubscription
function cancelSubscription($data, $form)
{
// Get the reasons for cancel
$reasons = '';
foreach ($data['Reasons'] as $reason) {
if ($reasons == '') {
$reasons = $reason;
} else {
$reasons .= ", {$reason}";
}
}
$member = Member::currentUser();
$subscription = Subscription::get()->filter(array('MemberID' => $member->ID, 'Status' => 1))->first();
// Get the member order
$order = $subscription->Order();
//Get InfusionSoft Api
$app = $this->getInfusionSoftApi();
//Set the current subscription to Inactive
$result = $this->setSubscriptionStatus($subscription->SubscriptionID, 'Inactive');
if (is_int($result)) {
$isConId = $member->ISContactID;
//Remove IS trial tag
$app->grpRemove($isConId, 2216);
$returnFields = array('_AWofmonths');
$conDat = $app->loadCon($isConId, $returnFields);
$subCount = $conDat['_AWofmonths'];
$date = $app->infuDate(date('j-n-Y'));
if ($this->isTrialMember($member->ID)) {
// Add tag - Cancelled after trial
$app->grpAssign($isConId, 2226);
//Add a note
$conActionDat = array('ContactId' => $isConId, 'ActionType' => 'UPDATE', 'ActionDescription' => "Cancelled AW Trial", 'CreationDate' => $date, 'ActionDate' => $date, 'CompletionDate' => $date, 'CreationNotes' => $reasons, 'UserID' => 1);
$conActionID = $app->dsAdd("ContactAction", $conActionDat);
//Update IS Contact
$conDat = array('_AttentionWizard' => 'Cancelled after trial', '_AWcanceldate' => $date);
$conID = $app->updateCon($isConId, $conDat);
} else {
// Add tag - Cancelled paid subscription
$app->grpAssign($isConId, 2758);
// Add a note
$conActionDat = array('ContactId' => $isConId, 'ActionType' => 'UPDATE', 'ActionDescription' => "Cancelled AW Subscription", 'CreationDate' => $date, 'ActionDate' => $date, 'CompletionDate' => $date, 'CreationNotes' => $reasons, 'UserID' => 1);
$conActionID = $app->dsAdd("ContactAction", $conActionDat);
// Update IS Contact
$conDat = array('_AttentionWizard' => 'Cancelled paid subscription', '_AWcanceldate' => $date);
$conID = $app->updateCon($isConId, $conDat);
}
// Set the subscription status to inactive
$subscription->Status = 0;
$subscription->IsTrial = 0;
$subscription->ReasonCancelled = $reasons;
$subscription->ExpireDate = date('Y-m-d H:i:s');
$subscription->write();
//Send an email to the user
$product = $subscription->Product();
$email = new Email();
$email->setSubject("Your {$product->Name} Subscription Has Been Cancelled");
$email->setFrom('support@attentionwizard.com');
$email->setTo($member->Email);
$email->setTemplate('CancelSubscriptionEmail');
$email->populateTemplate(array('firstName' => $member->FirstName, 'lastName' => $member->Surname));
$email->send();
// Redirect to user dashboard
$this->setMessage('Success', 'The subscription is cancelled successfully.');
$this->redirect('/account-settings');
} else {
$this->setMessage('Error', 'Sorry the subscription could not be cancelled due to some reason,please try again later.');
$this->redirect('/account-settings/#tabs-4');
return false;
}
}
示例4: do_removeSubscriptions
function do_removeSubscriptions()
{
$foldersubscriptions = KTUtil::arrayGet($_REQUEST, 'foldersubscriptions');
$documentsubscriptions = KTUtil::arrayGet($_REQUEST, 'documentsubscriptions');
if (empty($foldersubscriptions) && empty($documentsubscriptions)) {
$this->errorRedirectToMain(_kt('No subscriptions were chosen'));
}
$iSuccesses = 0;
$iFailures = 0;
if (!empty($foldersubscriptions)) {
foreach ($foldersubscriptions as $iSubscriptionId) {
$oSubscription = Subscription::get($iSubscriptionId, SubscriptionEvent::subTypes('Folder'));
if ($oSubscription) {
$oSubscription->delete();
$iSuccesses++;
} else {
$iFailures++;
}
}
}
if (!empty($documentsubscriptions)) {
foreach ($documentsubscriptions as $iSubscriptionId) {
$oSubscription = Subscription::get($iSubscriptionId, SubscriptionEvent::subTypes('Document'));
if ($oSubscription) {
$oSubscription->delete();
$iSuccesses++;
} else {
$iFailures++;
}
}
}
$sMessage = _kt("Subscriptions removed") . ": ";
if ($iFailures) {
$sMessage .= sprintf(_kt('%d successful, %d failures'), $iSuccesses, $iFailures);
} else {
$sMessage .= sprintf('%d', $iSuccesses);
}
$this->successRedirectToMain($sMessage);
exit(0);
}
示例5: UpdateBillingAddress
public function UpdateBillingAddress($data, $form)
{
$member = Member::currentUser();
$isConID = $member->ISContactID;
//Get InfusionSoft Api
$creditCardType = Controller::curr()->getISCreditCardType($data['CreditCardType']);
$app = Controller::curr()->getInfusionSoftApi();
if (!isset($data['CreditCardNumber']) || $data['CreditCardNumber'] != $data['CreditCardNumberCopy'] && !is_numeric($data['CreditCardNumber'])) {
Controller::curr()->setMessage('Error', 'The credit card is invalid!');
return Controller::curr()->redirect(Controller::curr()->Link('#tabs-2'));
}
if ($data['CreditCardNumber'] == $data['CreditCardNumberCopy']) {
$cardNumber = $data['CreditCardNumberCur'];
} else {
$cardNumber = $data['CreditCardNumber'];
}
// Validate credit card
$card = array('CardType' => $creditCardType, 'ContactId' => $isConID, 'CardNumber' => $cardNumber, 'ExpirationMonth' => sprintf("%02s", $data['ExpiryMonth']), 'ExpirationYear' => $data['ExpiryYear'], 'CVV2' => $data['CreditCardCVV']);
$result = $app->validateCard($card);
if ($result['Valid'] != 'true') {
Controller::curr()->setMessage('Error', 'The credit card is invalid!');
return Controller::curr()->redirect(Controller::curr()->Link('#tabs-2'));
}
// Get country text from code
$country = Geoip::countryCode2name($data['Country']);
if ($data['CreditCardNumber'] == $data['CreditCardNumberCopy']) {
//Get the credit card
$creditCard = CreditCard::get()->filter(array('CreditCardNumber' => $data['CreditCardNumberCur'], 'MemberID' => $member->ID))->First();
//Update the credit card on InfusionSoft
$ccData = array('FirstName' => $data['FirstName'], 'LastName' => $data['LastName'], 'BillAddress1' => $data['StreetAddress1'], 'BillAddress2' => $data['StreetAddress2'], 'BillCity' => $data['City'], 'BillState' => $data['State'], 'BillZip' => $data['PostalCode'], 'BillCountry' => $country, 'CardType' => $creditCardType, 'NameOnCard' => $data['NameOnCard'], 'CVV2' => $data['CreditCardCVV'], 'ExpirationMonth' => sprintf("%02s", $data['ExpiryMonth']), 'ExpirationYear' => $data['ExpiryYear']);
$app->dsUpdate("CreditCard", $creditCard->ISCCID, $ccData);
//Update the credit card on site
$creditCard->CreditCardType = $data['CreditCardType'];
$creditCard->NameOnCard = $data['NameOnCard'];
$creditCard->CreditCardCVV = $data['CreditCardCVV'];
$creditCard->ExpiryMonth = $data['ExpiryMonth'];
$creditCard->ExpiryYear = $data['ExpiryYear'];
$creditCard->Company = $data['Company'];
$creditCard->StreetAddress1 = $data['StreetAddress1'];
$creditCard->StreetAddress2 = $data['StreetAddress2'];
$creditCard->City = $data['City'];
$creditCard->State = $data['State'];
$creditCard->PostalCode = $data['PostalCode'];
$creditCard->Country = $data['Country'];
$creditCard->Current = 1;
$creditCard->write();
} else {
//Find if the credit card exist
$creditCard = CreditCard::get()->filter(array('CreditCardNumber' => $data['CreditCardNumber'], 'MemberID' => $member->ID))->First();
if ($creditCard) {
//Get current credit card, un-mark it as current
Controller::curr()->unsetCurrentCreditCard($member->ID);
$ccID = $creditCard->ISCCID;
//Update the credit card on InfusionSoft
$ccData = array('FirstName' => $data['FirstName'], 'LastName' => $data['LastName'], 'BillAddress1' => $data['StreetAddress1'], 'BillAddress2' => $data['StreetAddress2'], 'BillCity' => $data['City'], 'BillState' => $data['State'], 'BillZip' => $data['PostalCode'], 'BillCountry' => $country, 'CardType' => $creditCardType, 'NameOnCard' => $data['NameOnCard'], 'CVV2' => $data['CreditCardCVV'], 'ExpirationMonth' => sprintf("%02s", $data['ExpiryMonth']), 'ExpirationYear' => $data['ExpiryYear']);
$app->dsUpdate("CreditCard", $ccID, $ccData);
//Update the credit card on site
$creditCard->CreditCardType = $data['CreditCardType'];
$creditCard->NameOnCard = $data['NameOnCard'];
$creditCard->CreditCardCVV = $data['CreditCardCVV'];
$creditCard->ExpiryMonth = $data['ExpiryMonth'];
$creditCard->ExpiryYear = $data['ExpiryYear'];
$creditCard->Company = $data['Company'];
$creditCard->StreetAddress1 = $data['StreetAddress1'];
$creditCard->StreetAddress2 = $data['StreetAddress2'];
$creditCard->City = $data['City'];
$creditCard->State = $data['State'];
$creditCard->PostalCode = $data['PostalCode'];
$creditCard->Country = $data['Country'];
$creditCard->Current = 1;
$creditCard->write();
} else {
// Add the credit card on InfusionSoft
$ccData = array('ContactId' => $isConID, 'FirstName' => $data['FirstName'], 'LastName' => $data['LastName'], 'BillAddress1' => $data['StreetAddress1'], 'BillAddress2' => $data['StreetAddress2'], 'BillCity' => $data['City'], 'BillState' => $data['State'], 'BillZip' => $data['PostalCode'], 'BillCountry' => $country, 'CardType' => $creditCardType, 'NameOnCard' => $data['NameOnCard'], 'CardNumber' => $data['CreditCardNumber'], 'CVV2' => $data['CreditCardCVV'], 'ExpirationMonth' => sprintf("%02s", $data['ExpiryMonth']), 'ExpirationYear' => $data['ExpiryYear']);
$ccID = $app->dsAdd("CreditCard", $ccData);
//Get current credit card un-mark it as current
Controller::curr()->unsetCurrentCreditCard($member->ID);
// Store Credit card on site and mark it as current
$newCreditCard = new CreditCard();
$newCreditCard->CreditCardType = $data['CreditCardType'];
$newCreditCard->CreditCardNumber = $data['CreditCardNumber'];
$newCreditCard->NameOnCard = $data['NameOnCard'];
$newCreditCard->CreditCardCVV = $data['CreditCardCVV'];
$newCreditCard->ExpiryMonth = $data['ExpiryMonth'];
$newCreditCard->ExpiryYear = $data['ExpiryYear'];
$newCreditCard->Company = $data['Company'];
$newCreditCard->StreetAddress1 = $data['StreetAddress1'];
$newCreditCard->StreetAddress2 = $data['StreetAddress2'];
$newCreditCard->City = $data['City'];
$newCreditCard->State = $data['State'];
$newCreditCard->PostalCode = $data['PostalCode'];
$newCreditCard->Country = $data['Country'];
$newCreditCard->Current = 1;
$newCreditCard->ISCCID = $ccID;
$newCreditCard->MemberID = $member->ID;
$newCreditCard->write();
}
//Update the user active Infusionsoft subscription Credit Card
$subscription = Subscription::get()->filter(array('MemberID' => $member->ID, 'Status' => 1))->first();
if ($subscription) {
//.........这里部分代码省略.........
示例6: subscription
public function subscription($id)
{
$sbc = new Subscription($this, array("SubscriptionId" => $id));
$sbc->get();
return $sbc;
}
示例7: getSSSubscription
public function getSSSubscription($memberId, $productId)
{
$subscription = Subscription::get()->filter(array('MemberID' => $memberId, 'ProductID' => $productId, 'Status' => 1))->first();
if ($subscription) {
return $subscription;
}
$subscription = Subscription::get()->filter(array('MemberID' => $memberId, 'ProductID' => $productId))->sort('Created', 'DESC')->first();
return $subscription;
}
示例8: getSubscriptions
/**
* [getSubscriptions - get all subscriptions]
* @return [json] [description]
*/
public function getSubscriptions()
{
$subscriptions = Subscription::get(["id", "service_id"]);
return Response::json($subscriptions);
}
示例9: changeSubscription
public function changeSubscription($data, $form)
{
//Get the record ID
$id = Controller::curr()->request->param('ID');
// Get the subscription
$subscription = Subscription::get()->byID($id);
//Get the new product ID
$newProductID = $data['ProductID'];
if ($subscription->ProductID == $newProductID) {
$form->sessionMessage("Please select a new subscription.", 'bad');
return $this->edit(Controller::curr()->getRequest());
}
// Get the Page controller
$Pg_Ctrl = new Page_Controller();
// Get InfusionSoft Api
$app = $Pg_Ctrl->getInfusionSoftApi();
// Get AttentionWizard member
$member = Member::get()->byID($data['MemberID']);
// Get IndusionSoft contact ID
$isConID = $member->ISContactID;
//Get current date
$curdate = $app->infuDate(date('j-n-Y'));
//Get old order
$oldOrder = $subscription->Order();
//Get new product
$product = Product::get()->byID($newProductID);
$credits = $product->Credits;
$isProductID = $product->ISInitialProductID;
// Get the current InfusionSoft credit card ID
$creditCard = $Pg_Ctrl->getCurrentCreditCard($member->ID);
if (!$creditCard) {
$form->sessionMessage("The user does not have a Credit Card on account, please add a credit card.", 'bad');
return $this->edit(Controller::curr()->getRequest());
}
$ccID = $creditCard->ISCCID;
$subscriptionID = $Pg_Ctrl->createISSubscription($isConID, $product->ISProductID, $product->RecurringPrice, $ccID, 30);
if ($subscriptionID && is_int($subscriptionID)) {
// Create an order
$order = new Order();
$order->OrderStatus = 'P';
$order->Amount = $product->RecurringPrice;
$order->MemberID = $member->ID;
$order->ProductID = $newProductID;
$order->CreditCardID = $creditCard->ID;
$orderID = $order->write();
//Create an infusionsoft order
$config = SiteConfig::current_site_config();
$invoiceId = $app->blankOrder($isConID, $product->Name, $curdate, 0, 0);
$orderItem = $app->addOrderItem($invoiceId, $isProductID, 9, floatval($product->RecurringPrice), 1, $product->Name, $product->Name);
$result = $app->chargeInvoice($invoiceId, $product->Name, $ccID, $config->MerchantAccount, false);
if ($result['Successful']) {
$nextBillDate = $Pg_Ctrl->getSubscriptionNextBillDate($subscriptionID);
$expireDate = date('Y-m-d H:i:s', strtotime($nextBillDate));
$startDate = date('Y-m-d H:i:s', strtotime($expireDate . "-30 days"));
//Set the current subscription to Inactive
$Pg_Ctrl->setSubscriptionStatus($subscription->SubscriptionID, 'Inactive');
//Remove trial tag if exists
$app->grpRemove($isConID, 2216);
//get old Tag ID
if ($Pg_Ctrl->isTrialMember($member->ID)) {
$oldISTagID = 2216;
} else {
$oldISTagID = $Pg_Ctrl->getISTagIdByProduct($oldOrder->ProductID);
}
//Remove old tag ID
$app->grpRemove($isConID, $oldISTagID);
$newISTagID = $Pg_Ctrl->getISTagIdByProduct($newProductID);
//Add new tag ID
$app->grpAssign($isConID, $newISTagID);
//Add a note
$conActionDat = array('ContactId' => $isConID, 'ActionType' => 'UPDATE', 'ActionDescription' => "Payment made for AW service", 'CreationDate' => $curdate, 'ActionDate' => $curdate, 'CompletionDate' => $curdate, 'CreationNotes' => "{$product->Name} Subscription", 'UserID' => 1);
$app->dsAdd("ContactAction", $conActionDat);
$returnFields = array('_AWofmonths');
$conData = $app->loadCon($isConID, $returnFields);
$conDat = array('_AWofmonths' => (isset($conData['_AWofmonths']) ? $conData['_AWofmonths'] : 0) + 1, '_AttentionWizard' => 'Paid and Current');
$app->updateCon($isConID, $conDat);
//Create a new Subscription
$newSubscription = new Subscription();
$newSubscription->StartDate = $startDate;
$newSubscription->ExpireDate = $expireDate;
$newSubscription->SubscriptionID = $subscriptionID;
$newSubscription->Status = 1;
$newSubscription->IsTrial = 0;
$newSubscription->SubscriptionCount = 1;
$newSubscription->MemberID = $member->ID;
$newSubscription->ProductID = $newProductID;
$newSubscription->OrderID = $orderID;
$newSubscription->write();
// Create a MemberCredits record
$memberCredits = new MemberCredits();
$memberCredits->Credits = $credits;
$memberCredits->Expire = 1;
$memberCredits->ExpireDate = $expireDate;
$memberCredits->MemberID = $member->ID;
$memberCredits->ProductID = $newProductID;
$memberCredits->SubscriptionID = $newSubscription->ID;
$memberCredits->write();
// Update order
$order->OrderStatus = 'c';
$order->write();
//.........这里部分代码省略.........
示例10: sourceRecords
public function sourceRecords($params = null)
{
return Subscription::get()->filter(array('ProductID' => 3, 'Status' => 1))->exclude('Member.ID', null);
}