Hey list,
while trying to get (PayPal)Payment (trunk) work with E-commerce
(trunk), I've come across something I fail to understand.
PayPalPayment is having a 'AuthorisationCode' db-field.
This is sent to Paypal through the PaypalForm using $inputs['custom']
= $this->ID . '-' . $this->AuthorisationCode; '
Then on returning from Paypal, this is part of the $_REQUEST['custom']
function complete() {
if(isset($_REQUEST['custom']) && $custom = $_REQUEST['custom']) {
$params = explode('-', $custom);
if(count($params) == 2) {
if($payment = DataObject::get_by_id('PayPalPayment', $params[0]))
{
if($payment->AuthorisationCode == $params[1]) {
if(isset($_REQUEST['payment_status']) && $_REQUEST
['payment_status'] == 'Completed') {
$payment->Status = 'Success';
$payment->TxnRef = $_REQUEST['txn_id'];
}
else {
$payment->Status = 'Failure';
}
$payment->write();
$payment->redirectToOrder();
}
}
}
}
}
However: nowhere in the trunk code can I see where AuthorisationCode
is being set.
As a result, $params[1] is never set and nothing of this ever happens,
resulting in an error and never a 'completed' transaction. $_REQUEST
['custom'] is always like '5-' or '23-'...
Anything I'm missing here?
Someone on IRC apparently had this problem too and changed the code,
set the AuthorisationCode on the form as the order uid:
$this->AuthorisationCode = $order->UID;
$this->write();
in the PaypalForm.
However, what is the real purpose of AuthorisationCode? I cannot see
it working as currently implemented in trunk.
I've posted this on the forum as well:
http://silverstripe.org/e-commerce-module-forum/show/272955