Skip to content

Commit

Permalink
few minor tweaks and fixes to plans
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisFrench committed Jun 11, 2014
1 parent c13c5d4 commit 171c03e
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 11 deletions.
18 changes: 9 additions & 9 deletions src/Striper/Admin/Controllers/Plan.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,16 @@ protected function doAdd($data)
$create = array_filter($values['stripe']);

//make a method for this, convert float to cents
$create['amount'] = (int) $create['amount']*100;
$settings = \Striper\Models\Settings::fetch();
// Set your secret key: remember to change this to your live secret key in production
// See your keys here https://manage.stripe.com/account
\Stripe::setApiKey($settings->{$settings->mode.'.secret_key'});
$plan = \Stripe_Plan::create($create);

$create['amount'] = (int) $create['amount'];

$settings = \Striper\Models\Settings::fetch();
// Set your secret key: remember to change this to your live secret key in production
// See your keys here https://manage.stripe.com/account
\Stripe::setApiKey($settings->{$settings->mode.'.secret_key'});


$values['stripe'] = array('id'=>$plan->id, 'name'=>$plan->name, 'created' => $plan->created);
$plan = \Stripe_Plan::create($create);

$values['stripe'] = array('id'=>$plan->id, 'name'=>$plan->name, 'created' => $plan->created, 'amount' => $plan->amount, 'interval' => $plan->interval, 'currency' => $plan->currency, 'interval_count' => $plan->interval_count, 'trial_period_days' => $plan->trial_period_days);
unset($values['submitType']);
//\Dsc\System::instance()->addMessage(\Dsc\Debug::dump($values), 'warning');
$this->item = $model->create($values);
Expand Down
2 changes: 1 addition & 1 deletion src/Striper/Admin/Views/plans/stripe_plan.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<div class="row">
<div class="col-md-5">
<label>Amount</label>
<input type="number" name="stripe[amount]" value="<?php echo $flash->old('stripe.amount'); ?>" class="form-control" />
<input type="number" name="stripe[amount]" value="<?php echo $flash->old('stripe.amount'); ?>" class="form-control" /> // in cents (ie $20.00 == 2000)
<p class="help-block">A positive integer in cents (or 0 for a free plan) representing how much to charge (on a recurring basis).</p>

</div>
Expand Down
2 changes: 1 addition & 1 deletion src/Striper/Models/PaymentRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ protected function beforeSave()
public function sendChargeEmailClient($charge){

$html = \Dsc\System::instance()->get( 'theme' )->renderView( 'Striper/Site/Views::paymentrequests/emails/client_success_html.php' );
$text = \Dsc\System::instance()->get( 'theme' )->renderView( 'Striper/Site/Views::paymentrequests/emails/client_success_text.php' );
$text = \Dsc\System::instance()->get( 'theme' )->renderView( 'Striper/Site/Views::paymentrequests/emails/client_success_text.php' );

\Dsc\System::instance()->get('mailer')->send($charge->{'client.email'}, 'Successfully Subscribed', array($html, $text) );

Expand Down
26 changes: 26 additions & 0 deletions src/Striper/Models/Plans.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,32 @@ public function amountForStripe()

return $amount;
}

public static function planDescription($plan)
{
$amount = money_format('$%i', number_format(( $plan->amount/100),2));
$interval = $plan->interval;
$interval_count = $plan->interval_count;
$string = $amount;
if($interval_count > 1) {
$string .= ' every ' .$interval_count ;
switch ($interval) {
case 'week':
$string .= ' weeks. ';
break;
case 'month':
$string .= ' months ';
break;
case 'year':
$string .= ' years ';
break;
}
} else {
$string .= '/'.$interval;
}

return $string;
}


public function acceptPayment($charge) {
Expand Down

0 comments on commit 171c03e

Please sign in to comment.