Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2014
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. Template.DashboardPaymentPaypalExecute.rendered = function(){
  2. var payerId = window.location.search.split('PayerID=')[1]
  3.  
  4. var paymentState;
  5. Meteor.call('executePaypalPayment',payerId , function(error, result){
  6.  
  7. console.log('testing');
  8. if(error){
  9. console.log('Error (execute)');
  10. }else{
  11. console.log('Success (execute)');
  12. paymentState = result;
  13. }
  14. });
  15. }
  16.  
  17. executePaypalPayment : function(payerId){
  18.  
  19. console.log('executePaypalPayment');
  20.  
  21. res = Meteor.http.post('https://api.sandbox.paypal.com/v1/payments/payment/' +
  22. payment.id + '/execute/',
  23. {
  24. headers: {
  25. Authorization: 'Bearer ' + token.access_token,
  26. 'Content-Type' : 'application/json'
  27. },
  28. data : {
  29. payer_id : payerId
  30. }
  31. })
  32.  
  33. payment = res.data;
  34.  
  35. //created; approved; failed; canceled; expired; pending
  36. console.log('PAYMENT.STATE');
  37. console.log(payment.state);
  38.  
  39. if ((payment.state === 'approved')|| (payment.state === 'created'))
  40. {
  41. console.log('returning true');
  42. return true;
  43. }else{
  44. console.log('returning false');
  45. return false;
  46. }
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement