1

I have been trying to build a woocommerce plugin for Alipay from what I understand from their docs is:

  1. I have request a payment through an url(consist of several params, like notify_url, return_url etc.)
  2. Pay through their websit by loggin in.
  3. Then they redirect me to the return_url submitted in the first step (with several new params along with old ones)
  4. They send another request to notify_url with a notify_id and a notify_status and some other params.
  5. After that I have to confirm I got the notification.

Now the issue here is, I am being redirected to return_url and getting expected values. But the code supposed to be triggered by notify_url is not being executed. But if I replace the return_url with notify_url, when alipay redirects me to return_url(in this case reuthn_url = notify_url) notification verification code executes properly.

I am using their demo code.

Here is the configuration:

$gateway = "https://openapi.alipaydev.com/gateway.do?";
$partner = "";
$security_code = "";
$_input_charset = "utf-8"; 
$sign_type = "MD5"; 
$transport= "http";
$notify_url = "http://localhost/code/notify_url.php";
$return_url = "http://localhost/code/return_url.php";

N.B. They say payment process is successful in thier website, before redirecting me to return_url.

Shafayat Alam
  • 702
  • 1
  • 14
  • 32
  • Can others access your `notify_url` ? Also, are you using their sandbox API ? – Himal Jul 21 '17 at 09:51
  • I am trying in localhost. Yes, I am using sandbox API. Let me add the config file. – Shafayat Alam Jul 21 '17 at 09:53
  • Can Alipay access your localhost's `notify_url` through internet ? if not it won't work. – Himal Jul 21 '17 at 09:54
  • as I use localhost it won't be accessible directly by Alipay, right? In that case, how can I test in localhost? – Shafayat Alam Jul 21 '17 at 10:00
  • 1
    If you haven't made any special changes then yes, it won't be possible. You could try [ngrok](https://ngrok.com/). but not sure if you have to register the new URL given by 'ngrok' with Alipay though. Also, if you are using WAMP for example, you have to use the `Put Online` option. – Himal Jul 21 '17 at 10:05
  • Thanks @Himal, issues seems to be related with Alipay not reaching the notify_url. – Shafayat Alam Jul 21 '17 at 10:15
  • Now that notify_url is reachable because of `ngrok` Alipay response is always `false`. Do you know what could possibly cause this? this is the verification url `http://notify.alipay.com/trade/notify_query.do?notify_id=9aedcb360bb101b18145037fbe2792fie6&partner=2088621877564976` – Shafayat Alam Jul 21 '17 at 12:20
  • See if your server have actually received the Alipay's notification. from the access logs. You are echoing “success” or "fail" right ? – Himal Jul 21 '17 at 12:34
  • yes I am, I even logged the api request got from Alipay, and tried verifying manually, always 'false' – Shafayat Alam Jul 21 '17 at 12:36

0 Answers0