当前位置: 首页>>代码示例>>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;未经允许,请勿转载。