Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Template.DashboardPaymentPaypalExecute.rendered = function(){
- var payerId = window.location.search.split('PayerID=')[1]
- var paymentState;
- Meteor.call('executePaypalPayment',payerId , function(error, result){
- console.log('testing');
- if(error){
- console.log('Error (execute)');
- }else{
- console.log('Success (execute)');
- paymentState = result;
- }
- });
- }
- executePaypalPayment : function(payerId){
- console.log('executePaypalPayment');
- res = Meteor.http.post('https://api.sandbox.paypal.com/v1/payments/payment/' +
- payment.id + '/execute/',
- {
- headers: {
- Authorization: 'Bearer ' + token.access_token,
- 'Content-Type' : 'application/json'
- },
- data : {
- payer_id : payerId
- }
- })
- payment = res.data;
- //created; approved; failed; canceled; expired; pending
- console.log('PAYMENT.STATE');
- console.log(payment.state);
- if ((payment.state === 'approved')|| (payment.state === 'created'))
- {
- console.log('returning true');
- return true;
- }else{
- console.log('returning false');
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement