PAYPAL_URL.urldecode($result['TOKEN']));
}
else
{
// No token, call failed!
echo "
Could not initialize PayPal connection.<
/p>
".print_r($result, true)."
";
}
6. PayPal will redirect the user to the return or cancel URL once the payment is
done. We are using the mode variable to determine if it was a return or cancel
operation. Based on these values, we can update the order status or show a
failure message to the user. The following code shows our implementation.
// Done well, now complete the transaction and get the funds!
$result = hash_call('DoMobileCheckoutPayment',
'&token='.$_REQUEST['token']);
if (strtoupper($result['ACK']) == 'SUCCESS')
{
// Order successful, we can update it now
$orderObj = new Order(null, null);
// We can process/validate all returned info here...
$orderObj->id = $_REQUEST['INVNUM'];
$orderObj->UpdateStatus('P');
echo '
Payment successful. The order will soon be
processed.
';
}
7. At this stage, we can customize the APIError.php file that comes in PayPal
SDK to format the errors the way we want to show them. We can also specify
another file to handle errors in our paypal.
Pages:
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193