public static function applyCouponToSubscription(Bf_Coupon $coupon, $subscription)
 {
     $subscriptionID = Bf_Subscription::getIdentifier($subscription);
     // make new Bf_Coupon using only the `couponCode` param
     $requestEntity = new Bf_Coupon(array('couponCode' => $coupon->couponCode), $coupon->getClient());
     $endpoint = sprintf("%s/coupons", rawurlencode($subscriptionID));
     $responseEntity = Bf_Coupon::getClassName();
     $constructedEntity = static::postEntityAndGrabFirst($endpoint, $requestEntity, $responseEntity);
     return $constructedEntity;
 }
 public static function getApplicableCouponsForSubscription($subscription, $options = NULL, $customClient = NULL)
 {
     $subscriptionID = Bf_Subscription::getIdentifier($subscription);
     $endpoint = sprintf("%s/applicable-coupons", rawurlencode($subscriptionID));
     $responseEntity = Bf_Coupon::getClassName();
     return static::getCollection($endpoint, $options, $customClient, $responseEntity);
 }
Exemple #3
0
 public static function initStatics()
 {
     self::$_resourcePath = new Bf_ResourcePath('coupons', 'Coupon');
 }
Exemple #4
0
 public function testCreateCompound()
 {
     $subscription = self::$entities['subscription'];
     // Create model of coupon
     // unique name for test
     $uniqueString = time();
     $couponCode = "TEST2_{$uniqueString}";
     $coupon = new Bf_Coupon(array('name' => '3 Months free', 'couponCode' => $couponCode, 'coupons' => 100, 'uses' => 3));
     $coupon->setRatePlan('Gold membership');
     // $5 off CPU
     $coupon->addCashDiscount("CPU", 5);
     // 5 Mbps free P2P Traffic
     $coupon->addFreeUnitsDiscount("P2P Traffic", 5);
     // 10 Mbps free bandwidth
     $coupon->addFreeUnitsDiscount("Bandwidth", 10);
     $createdCoupon = Bf_Coupon::create($coupon);
 }
Exemple #5
0
 /**
  * Applies Bf_Coupon to this Bf_Subscription
  * @param string The Coupon code to apply to this subscription
  * @return Bf_Coupon The applied coupon.
  */
 public function applyCouponCode($couponCode)
 {
     return Bf_Coupon::applyCouponCodeToSubscription($couponCode, $this);
 }