LTroya

Paypal integration

Sep 21st, 2017
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script src="https://www.paypalobjects.com/api/checkout.js"></script>
  2.  
  3.         <script>
  4.             paypal.Button.render({
  5.                 client: {
  6.                     sandbox: 'AUqe7hp0cLjEDtBW1wip6Ro-S0C1IGjbglBdLLLy9NRPyQgqDbAqCtVySFK-bqxF4Vb1BpSmDqD_Bxzt',
  7.                     production: 'AXQ9cwtDj9fVeosCzIDTCj8tXroo8-NfcUbOogZGG1dL5Ay_a7pzdC52TSdfq0GWbnIltZRr7weZJ1Hd'
  8.                 },
  9.  
  10.                 style: {
  11.                     size: 'small',
  12.                     color: 'gold',
  13.                     shape: 'rect',
  14.                     label: 'generic'
  15.                 },
  16.  
  17.                 env: 'production', // Or 'production',
  18.  
  19.                 commit: true, // Show a 'Pay Now' button
  20.  
  21.                 timeout: 30000,
  22.  
  23.                 payment: function (data, actions) {
  24.                     return actions.payment.create({
  25.                         payment: {
  26.                             transactions: [
  27.                                 {
  28.                                     amount: {total: '{{$price}}', currency: 'USD'}
  29.                                 }
  30.                             ]
  31.                         }
  32.                     });
  33.                 },
  34.  
  35.                 onAuthorize: function (data, actions) {
  36.                     return actions.payment.execute().then(function (payment) {
  37.                         $.ajax({
  38.                             method: 'POST',
  39.                             url: '{{ route('tasks.payments.paypal', ['task' => $task])}}',
  40.                         }).done(function (response) {
  41.                             window.location = response.redirect;
  42.                         });
  43.                     });
  44.                 }
  45.  
  46.             }, '#paypal-button');
  47.         </script>
Add Comment
Please, Sign In to add comment