Hello
we are working in the paypal express checkout gateway , wehave almost done all the code, but when we test it we have some probleme in the callback .
we pass the payment to paypal site and it show a successfull payment , and the gateway return the user to the blesta site to return url .
in the log no entries for successfull or failed reponse , also no transaction are stored in the clients side .
the validate function is the fallowing , is there any mistake in it ?
public function validate(array $get, array $post) {
print_r($get);
$client_id = $this->ifSet($get['client_id']);
$token = $this->ifSet($get['token']);
// $payer_id = $this->ifSet($get['PayerID']);
// if (!$client_id) {
// $client_id = $this->clientIdFromEmail($this->ifSet($post['payer_email']));
// }
$post_to = $this->getApiUrl();
$params = array(
'TOKEN' => $token,
);
$response = $this->execute_request("GetExpressCheckoutDetails", $params);
// Exit when we don't get a sucess request
if (isset($response['ACK']) && $response['ACK'] != 'Success') {
$this->Input->setErrors($this->getCommonError("invalid"));
// Log error response
$this->log($this->ifSet($post_to), serialize($response), "input", false);
return;
}
// Log Success response
$this->log($this->ifSet($post_to), serialize($response), "input", true);
// Do the payment
$request_params = array(
'TOKEN' => $response['TOKEN'],
'PAYERID' => $response['PAYERID'],
'PAYMENTREQUEST_0_AMT' => $response['PAYMENTREQUEST_0_AMT'],
'PAYMENTREQUEST_0_PAYMENTACTION' => $this->payment_action,
'PAYMENTREQUEST_0_CURRENCYCODE' => $this->currency,
);
// Make the call to PayPal to finalize payment
$do_response = $this->execute_request("DoExpressCheckoutPayment", $request_params);
// Exit when we don't get a sucess request
if (isset($do_response['ACK']) && $do_response['ACK'] != 'Success') {
$this->Input->setErrors($this->getCommonError("invalid"));
// Log error response
$this->log($this->ifSet($post_to), serialize($do_response), "input", false);
return;
}
$this->log($this->ifSet($post_to), serialize($do_response), "output", true);
// Capture the IPN status, or reject it if invalid
switch (strtolower($this->ifSet($do_response['PAYMENTINFO_0_PAYMENTSTATUS']))) {
case "completed":
case "processed":
case "completed-funds-held":
$status = "approved";
break;
case "pending":
case "in-progress":
$status = "pending";
break;
case "refunded":
$status = "refunded";
break;
case "voided":
$status = "voided";
break;
case 'denied':
case 'failed':
case 'expired':
$status = 'declined';
break;
default:
// Log request received, even though not processed
$this->log($this->ifSet($post_to), serialize($do_response['PAYMENTINFO_0_PAYMENTSTATUS']), "output", true);
return;
}
return array(
'client_id' => $client_id,
'amount' => $this->ifSet($do_response['PAYMENTREQUEST_0_AMT']),
'currency' => $this->ifSet($do_response['PAYMENTREQUEST_0_CURRENCYCODE']),
'status' => $status,
'reference_id' => null,
'transaction_id' => $this->ifSet($do_response['PAYMENTINFO_0_TRANSACTIONID']),
// 'parent_transaction_id' => $this->ifSet($post['parent_txn_id']),
// 'invoices' => $this->unserializeInvoices($this->ifSet($post['custom']))
);
}