activa Posted June 19, 2015 Report Posted June 19, 2015 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'])) ); } Quote
Max Posted June 19, 2015 Report Posted June 19, 2015 $this->log($this->ifSet($post_to), serialize($response), "input", false); I don't know if that's the problem here, but if you use Blesta's log function with the first (url) parameter empty -which could happen here if $post_to is empty-, nothing gets logged and it terminates the script with a fatal Error: a:1:{s:3:"url";a:1:{s:5:"empty";s:12:"Missing URL.";}} exception. We have had an issue with that as well. In our module log() was being called with empty first parameter only when run under crontab. One of those places where nobody sees error messages being printed, and nothing got logged. Quote
Blesta Addons Posted June 19, 2015 Report Posted June 19, 2015 Post_to is not empty it get the live or sandbox URL . We are using sandbox .in our developer center show a successfully transaction Quote
activa Posted June 20, 2015 Author Report Posted June 20, 2015 is like a callback not recieved ... also no logs are saved in validate functions ... Quote
Max Posted June 20, 2015 Report Posted June 20, 2015 Post_to is not empty it get the live or sandbox URL . Ok. Thought that may not be always the case, because of the ifSet() == is like a callback not recieved ... You did include your class name in the callback URL, so that the request gets routed to your class? As in: $callbackurl = Configure::get("Blesta.gw_callback_url").Configure::get("Blesta.company_id")."/".strtolower(get_class($this))."/"; In case you are not able to find your problem, you may also able to use Paypal Express through our Omnipay module. Quote
activa Posted June 22, 2015 Author Report Posted June 22, 2015 Ok. Thought that may not be always the case, because of the ifSet() == You did include your class name in the callback URL, so that the request gets routed to your class? As in: $callbackurl = Configure::get("Blesta.gw_callback_url").Configure::get("Blesta.company_id")."/".strtolower(get_class($this))."/"; In case you are not able to find your problem, you may also able to use Paypal Express through our Omnipay module. i will check it just for inspiration , because we need a separate gateway for checkout . and we will adding the incontext feature checkout later . Quote
serge Posted June 23, 2015 Report Posted June 23, 2015 depending of if you are shoppingcart or gateway side, the term , callback URL or postback URL mean the same, it's the Notification URL, what paypal mean by IPN (Instant Payment Notification) URL. Quote
activa Posted June 23, 2015 Author Report Posted June 23, 2015 Hello $notify_url = Configure::get("Blesta.gw_callback_url") . Configure::get("Blesta.company_id") ."/paypal_express_checkout/?client_id=" . $this->ifSet($contact_info['client_id']) ; in the developper section a see a successfull transaction . Quote
Tyson Posted June 23, 2015 Report Posted June 23, 2015 The fact no logs exist in Blesta suggests the callback URL is either incorrect or PayPal is unable to communicate with it. This might happen, for instance, if you're testing payments from your local machine @ localhost. Quote
serge Posted June 23, 2015 Report Posted June 23, 2015 you could check webserver log, to see http error code Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.