當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Coupon::create方法代碼示例

本文整理匯總了PHP中Coupon::create方法的典型用法代碼示例。如果您正苦於以下問題:PHP Coupon::create方法的具體用法?PHP Coupon::create怎麽用?PHP Coupon::create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Coupon的用法示例。


在下文中一共展示了Coupon::create方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testSave

 public function testSave()
 {
     self::authorizeFromEnv();
     $id = 'test_coupon-' . self::randomString();
     $c = Coupon::create(array('percent_off' => 25, 'duration' => 'repeating', 'duration_in_months' => 5, 'id' => $id));
     $this->assertSame($id, $c->id);
     // @codingStandardsIgnoreStart
     $this->assertSame(25, $c->percent_off);
     // @codingStandardsIgnoreEnd
     $c->metadata['foo'] = 'bar';
     $c->save();
     $stripeCoupon = Coupon::retrieve($id);
     $this->assertEquals($c->metadata, $stripeCoupon->metadata);
 }
開發者ID:andrewkrug,項目名稱:repucaution,代碼行數:14,代碼來源:CouponTest.php

示例2: testDeletion

 public function testDeletion()
 {
     self::authorizeFromEnv();
     $id = 'test-coupon-' . self::randomString();
     $coupon = Coupon::create(array('percent_off' => 25, 'duration' => 'repeating', 'duration_in_months' => 5, 'id' => $id));
     $customer = self::createTestCustomer(array('coupon' => $id));
     $this->assertTrue(isset($customer->discount));
     $this->assertTrue(isset($customer->discount->coupon));
     $this->assertSame($id, $customer->discount->coupon->id);
     $customer->deleteDiscount();
     $this->assertFalse(isset($customer->discount));
     $customer = Customer::retrieve($customer->id);
     $this->assertFalse(isset($customer->discount));
 }
開發者ID:parsonsc,項目名稱:dofe,代碼行數:14,代碼來源:DiscountTest.php

示例3: post

 public function post()
 {
     $param = Input::only('player_id', 'points');
     $rules = array('points' => 'required|numeric|min:1,max:1000000', 'player_id' => 'required|exists:acl_users,id');
     //custom error messaging
     $messages = array('points.required' => 'Please fill up the player points redemption.', 'merchant_id.exists' => 'Merchant id is not valid');
     $validator = Validator::make($param, $rules, $messages);
     if ($validator->passes()) {
         $player_points = Points::where('account_id', $param['player_id'])->get()->first();
         $param = array('player_id' => $param['player_id'], 'points' => $param['points'], 'redeem_by' => Auth::user()->id, 'coupon_code' => Utils::generateRandomString(), 'redeemed' => 1);
         try {
             $player_bet = Coupon::create($param);
             $update = $player_points->decrement('credits', $param['points']);
             $message = 'Points has been successfully redeemed.';
             return Redirect::action('points.redeem')->with('success', $message);
         } catch (Exception $e) {
             print $e;
         }
     } else {
         $messages = $validator->messages();
         return Redirect::action('points.redeem')->with('error', $messages->all());
     }
 }
開發者ID:pacificcasinohotel,項目名稱:pointsystem,代碼行數:23,代碼來源:RedeemPointsController.php

示例4: retrieveOrCreateCoupon

 /**
  * Verify that a coupon with a given ID exists, or create a new one if it
  * does not.
  */
 protected static function retrieveOrCreateCoupon($id)
 {
     self::authorizeFromEnv();
     try {
         $coupon = Coupon::retrieve($id);
     } catch (Error\InvalidRequest $exception) {
         $coupon = Coupon::create(array('id' => $id, 'duration' => 'forever', 'percent_off' => 25));
     }
 }
開發者ID:Enflick,項目名稱:stripe-php,代碼行數:13,代碼來源:TestCase.php


注:本文中的Coupon::create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。