Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2014
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. Route::get('/buy/{id}', function($id)
  2. {
  3. $download = Download::find($id);
  4. return View::make('buy', array('download' => $download));
  5. });
  6.  
  7. Route::post('/buy/{id}', function($id)
  8. {
  9. Stripe::setApiKey(Config::get('laravel-stripe::stripe.sk_test_aaaaaaaaaaaaaaaaaaaaaaaa'));
  10.  
  11. $download = Download::find($id);
  12. $token = Input::get('stripeToken');
  13. // Charge the card
  14. try {
  15. $charge = Stripe_Charge::create(array(
  16. "amount" => $download->price,
  17. "currency" => "gbp",
  18. "card" => $token,
  19. "description" => 'Order: ' . $download->name)
  20. );
  21. // If we get this far, we've charged the user successfully
  22. Session::put('purchased_download_id', $download->id);
  23. return Redirect::to('confirmed');
  24.  
  25. } catch(Stripe_CardError $e) {
  26. // Payment failed
  27. return Redirect::to('buy/'.$id)->with('message', 'Your payment has failed.');
  28. }
  29. });
  30.  
  31. @extends('layouts.default')
  32.  
  33. @section('content')
  34.  
  35. <h1>Your Order</h1>
  36.  
  37. <h2>{{ $download->name }}</h2>
  38.  
  39. <p>£{{ ($download->price/100) }}</p>
  40.  
  41. <form action="" method="POST" id="payment-form" role="form">
  42.  
  43. <input type="hidden" name="did" value="{{ $download->id }}" />
  44.  
  45. <div class="payment-errors alert alert-danger" style="display:none;"></div>
  46.  
  47. <div class="form-group">
  48. <label>
  49. <span>Card Number</span>
  50. <input type="text" size="20" data-stripe="number" class="form-control input-lg" />
  51. </label>
  52. </div>
  53.  
  54. <div class="form-group">
  55. <label>
  56. <span>CVC</span>
  57. <input type="text" size="4" data-stripe="cvc" class="form-control input-lg" />
  58. </label>
  59. </div>
  60.  
  61. <div class="form-group">
  62. <label>
  63. <span>Expires</span>
  64. </label>
  65. <div class="row">
  66. <div class="col-lg-1 col-md-1 col-sm-2 col-xs-3">
  67. <input type="text" size="2" data-stripe="exp-month" class="input-lg" placeholder="MM" />
  68. </div>
  69. <div class="col-lg-1 col-md-1 col-sm-2 col-xs-3">
  70. <input type="text" size="4" data-stripe="exp-year" class="input-lg" placeholder="YYYY" />
  71. </div>
  72. </div>
  73. </div>
  74.  
  75. <div class="form-group">
  76. <button type="submit" class="btn btn-primary btn-lg">Submit Payment</button>
  77. </div>
  78. </form>
  79.  
  80. @stop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement