Hello! I'm using the paypal-Button. My js-code is like: paypal.Button.render(
{ <?php if ($this->test)
print "env:'sandbox'";
else print "env:'production'";
?>,
locale: 'de_DE',
style:
{ size: 'medium',
color: 'gold',
shape: 'pill',
label: 'checkout'
},
payment: function(resolve, reject)
{ paypal.request.post('create-payment.php'+q, {})
.then(function(data)
{ if (data.status == 'Ok')
{ resolve(data.paymentID);
}
else
{ reject(data.msg);
alert("Error: "+data.msg);
}
})
.catch(function(err)
{ reject(err);
});
},
onAuthorize: function(data, actions)
{ actions.payment.get()
.then(function(payment)
{ var data = payment.payer;
data['paymentID'] = payment.id;
$.ajax(
{ type:'POST',
url: '/fetchuserdata.php',
data: data,
cache: false,
dataType: 'json',
success: function(data, textStatus)
{ if (data.status == "Ok")
{ document.location.href = "/continue-checkout.php";
}
else
{ alert("Error: "+data.msg);
}
},
error: function( jqXHR, textStatus, errorThrown )
{ alert('Connection-Error: '+textStatus+' '+errorThrown);
}
});
});
},
onCancel: function()
{ // Do nothing
}
}, '#paypal-express-button'); In fetchuserdata.php I'm doing something like: $payer_info = $_POST["payer_info"];
$PayerId = $payer_info['payer_id']; $name = $payer_info['shipping_address']['recipient_name']; $street = $payer_info['shipping_address']['line1']; ... My problem is that out of 20 orders today with the Paypal-button, I got 2 where fetchuserdata.php was not called, but the user was sent to "/continue-checkout.php" anyway (which shouldn't be possible...), but got no payer_id so the ExecutePayment went wrong. Is there a way to get the info stored in "data" in OnAuthorize in PHP via REST API to make really really sure all data is available before checkout?
... View more