Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Links in Chinese #62

Open
Loschcode opened this issue Mar 10, 2017 · 7 comments
Open

Links in Chinese #62

Loschcode opened this issue Mar 10, 2017 · 7 comments

Comments

@Loschcode
Copy link

All your references and links are in Chinese. I don't speak Chinese and try to integrate WechatPay for days. It's a true nightmare.

Could you link the details of how it works / how it should be done in English as you did with your gem ? Thanks.

@jasl
Copy link
Owner

jasl commented Mar 10, 2017

I totally understand you, Tencent only provides Chinese version of document, but even a Chinese are complicated how to integrate Wechat pay cause their docs suck 😂 .

To integrate with Wechat pay, I think you need a register their open platform and need to verify some materials, Could you describe your situation or progress that let me think how to help you.

@jasl
Copy link
Owner

jasl commented Mar 10, 2017

The most challenge I think is you need a company that registered in China mainland, Wechat pay need verify your company's material.

I just search Wechat document, they provide overseas version, but docs still Chinese

@Loschcode
Copy link
Author

I didn't expect a reply, so it's very nice of you 😄

Basically we are trying to test a demo payment using invoke_unifiedorder but it returns an error saying the signature is wrong, I tried many work around and to understand how it's generated but nothing worked so far ...

Is there any specific demo credentials I should be aware of ? We also registered an account and all that, but it's the same result 😢

I was looking for any guide step by step and could not find any ...

@Loschcode
Copy link
Author

Loschcode commented Mar 14, 2017

This is the file so far


  def show

    # required fields
    params = {
      body: 'test',
      out_trade_no: 'jlkkkmlkjtest003',
      total_fee: 1,
      spbill_create_ip: '127.0.0.1',
      notify_url: 'http://making.dev/notify',
      trade_type: 'JSAPI', # could be "JSAPI", "NATIVE" or "APP",
      openid: 'A VALID OPENID FOR OUR TESTING' # required when trade_type is `JSAPI`
    }

    signature = {
      appid: WxPay.appid,
      mch_id: WxPay.mch_id,
      device_info: 1000,
      body: 'test',
      nonce_str: SecureRandom.uuid.tr('-', '')
    }
    # appid:	wxd930ea5d5a258f4f
    # mch_id:	10000100
    # device_info:	1000
    # body:	test
    # nonce_str:	ibuaiVcKdpRxkhJA

    params[:sign] = WxPay::Sign.generate(signature)


    # wechat_username: wx84debd17520da2a3
    # wechat_password: 07e1c9e9e850d3e6b8e0b8a83a9ac0e9
    binding.pry

    # request = WxPay::Service.generate_js_pay_req(params)
    result = WxPay::Service.invoke_unifiedorder(params)

  end

As you can see I tried to hack the signature and find a way to pass this, but nothing worked, the result is {:raw=>{"xml"=>{"return_code"=>"FAIL", "return_msg"=>"签名错误"}}, "return_code"=>"FAIL", "return_msg"=>"签名错误"}

@jasl
Copy link
Owner

jasl commented Mar 14, 2017

@Loschcode
You don't need to sign signature yourself, wx_pay should handle this in make_payload , you can see it's will ignore your passed sign.

Could you tell me why you need to hack the signature? if necessary I will refactor to support you do this

@Loschcode
Copy link
Author

I see that now, but it doesn't matter the return_msg is always the same 签名错误 as I tried it out again ... Do you have any idea what's going on there ?

@jasl
Copy link
Owner

jasl commented Mar 15, 2017

@Loschcode
That means the signature is invalid, the most possibility is wrong config, you need to check these:

  • remember, Wechat Pay MUST test on production server
  • check configurations on Wechat Pay site, like your website host url, pid, secret, etc.
  • check wx_pay config has set equal to Wechat Pay site's

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants