public static function getCardsByRecruiter(MongoId $recruiterId) { // Get cards. $customerId = RecruiterModel::getCustomerId($recruiterId); if (is_null($customerId)) { $cards = []; } else { $cards = StripeBilling::getCards($customerId); } return $cards; }
public static function buyPlan() { RecruiterController::requireLogin(); global $params; $recruiterId = $_SESSION['_id']; $customerId = RecruiterModel::getCustomerId($recruiterId); $cardId = $params['cardId']; $type = $params['type']; $term = $params['term']; $discount = $params['discount']; if ($discount == self::BUYPLAN_DISCOUNT) { $discountType = 'discounted'; } else { $discountType = 'normal'; } $costs = ['basic' => ['1' => ['normal' => 39, 'discounted' => 29], '3' => ['normal' => 99, 'discounted' => 79], '6' => ['normal' => 179, 'discounted' => 149], '12' => ['normal' => 299, 'discounted' => 259]], 'premium' => ['1' => ['normal' => 99, 'discounted' => 79], '3' => ['normal' => 249, 'discounted' => 219], '6' => ['normal' => 429, 'discounted' => 379], '12' => ['normal' => 799, 'discounted' => 739]]]; $amount = $costs[$type][$term][$discountType] * 100; $description = ucfirst($type) . " plan for {$term} month(s)"; // Charge the card. $err = StripeBilling::charge($customerId, $cardId, $amount, $description); if (!is_null($err)) { return self::ajaxError($err); } $message = "\n _id: {$recruiterId}<br />\n type: {$type}<br />\n term: {$term}<br />\n discount: {$discount}\n "; sendgmail(['*****@*****.**', '*****@*****.**'], "*****@*****.**", 'Subscription Plan Bought!', $message); return self::ajaxSuccess(); }