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

Add Integration for Create QR Code, Update QR Code, Overseas Query, Spot Refund #94

Merged

Conversation

@chloerei
Copy link
Owner

Thanks for contributing. This new methods didn't affect other method usage, so I'm happy to merge.

A few more questions before merging:

  • Are you using these codes in a production environment? since I don't have environment to test, I wonder if these codes work.
  • Can you add some test to test/alipay/service_test.rb ? This prevents future changes from breaking these methods.

@yimwaikei
Copy link
Author

Yeap, these codes are running in production environment

Ok, will add some tests

@yimwaikei
Copy link
Author

HI @chloerei , @kahshing96 has added some unit tests, maybe you can take a look at it to see if it's ok to merge?

@chloerei chloerei merged commit 9c935a5 into chloerei:master Jul 26, 2023
@chloerei
Copy link
Owner

Looks good, I'll release a new version later.

@chloerei
Copy link
Owner

@yimwaikei @kahshing96

Sorry I didn't setup CI before, when I run test local, I found test fails:

# Running:

................F......F..............................

Finished in 0.155827s, 346.5383 runs/s, 385.0426 assertions/s.

  1) Failure:
Alipay::ServiceTest#test_create_merchant_qr_code [/rails/test/alipay/service_test.rb:284]:
--- expected
+++ actual
@@ -1 +1 @@
-"https://mapi.alipay.com/gateway.do?service=alipay.commerce.qrcode.create&_input_charset=utf-8&partner=1000000000000000&timestamp=2023-12-11+17%3A01%3A01&biz_data=%7B%22address%22%3A+%22No.278%2C+Road+YinCheng%2C+Shanghai%2C+China%22%2C%22country_code%22%3A+%22CN%22%2C%22currency%22%3A+%22USD%22%2C%22secondary_merchant_id%22%3A+%22xxx001%22%2C%22secondary_merchant_industry%22%3A+%227011%22%2C%22secondary_merchant_name%22%3A+%22xxx+Store%22%2C%22store_id%22%3A+%220001%22%2C%22store_name%22%3A+%22Apple+store%22%2C%22trans_currency%22%3A+%22USD%22%7D&biz_type=OVERSEASHOPQRCODE&sign_type=MD5&sign=fbfcc8c9316cc209c385eefcbceb2105"
+"https://mapi.alipay.com/gateway.do?service=alipay.commerce.qrcode.create&_input_charset=utf-8&partner=1000000000000000&timestamp=2023-12-12+01%3A01%3A01&biz_data=%7B%22address%22%3A+%22No.278%2C+Road+YinCheng%2C+Shanghai%2C+China%22%2C%22country_code%22%3A+%22CN%22%2C%22currency%22%3A+%22USD%22%2C%22secondary_merchant_id%22%3A+%22xxx001%22%2C%22secondary_merchant_industry%22%3A+%227011%22%2C%22secondary_merchant_name%22%3A+%22xxx+Store%22%2C%22store_id%22%3A+%220001%22%2C%22store_name%22%3A+%22Apple+store%22%2C%22trans_currency%22%3A+%22USD%22%7D&biz_type=OVERSEASHOPQRCODE&sign_type=MD5&sign=1c8881161f5895d0e7bbc8f4f5cad06c"


  2) Failure:
Alipay::ServiceTest#test_update_merchant_qr_code [/rails/test/alipay/service_test.rb:307]:
--- expected
+++ actual
@@ -1 +1 @@
-"https://mapi.alipay.com/gateway.do?service=alipay.commerce.qrcode.modify&_input_charset=utf-8&partner=1000000000000000&timestamp=2023-12-11+17%3A01%3A01&biz_data=%7B%22address%22%3A+%22No.278%2C+Road+YinCheng%2C+Shanghai%2C+China%22%2C%22country_code%22%3A+%22CN%22%2C%22currency%22%3A+%22USD%22%2C%22secondary_merchant_id%22%3A+%22xxx001%22%2C%22secondary_merchant_industry%22%3A+%227011%22%2C%22secondary_merchant_name%22%3A+%22xxx+Store%22%2C%22store_id%22%3A+%220001%22%2C%22store_name%22%3A+%22Apple+store%22%2C%22trans_currency%22%3A+%22USD%22%7D&biz_type=OVERSEASHOPQRCODE&qr_code=https%3A%2F%2Fqr.alipay.com%2Fbaxxxxx&sign_type=MD5&sign=5a72863d023163147f2909e74b741e52"
+"https://mapi.alipay.com/gateway.do?service=alipay.commerce.qrcode.modify&_input_charset=utf-8&partner=1000000000000000&timestamp=2023-12-12+01%3A01%3A01&biz_data=%7B%22address%22%3A+%22No.278%2C+Road+YinCheng%2C+Shanghai%2C+China%22%2C%22country_code%22%3A+%22CN%22%2C%22currency%22%3A+%22USD%22%2C%22secondary_merchant_id%22%3A+%22xxx001%22%2C%22secondary_merchant_industry%22%3A+%227011%22%2C%22secondary_merchant_name%22%3A+%22xxx+Store%22%2C%22store_id%22%3A+%220001%22%2C%22store_name%22%3A+%22Apple+store%22%2C%22trans_currency%22%3A+%22USD%22%7D&biz_type=OVERSEASHOPQRCODE&qr_code=https%3A%2F%2Fqr.alipay.com%2Fbaxxxxx&sign_type=MD5&sign=4d43f06b3d60cfc96750876287ef66ca"

I can simply modify the test case to make it pass, but want to confirm whether your local test also has this error?

@kahshing96
Copy link
Contributor

kahshing96 commented Jul 26, 2023

@yimwaikei @kahshing96

Sorry I didn't setup CI before, when I run test local, I found test fails:

# Running:

................F......F..............................

Finished in 0.155827s, 346.5383 runs/s, 385.0426 assertions/s.

  1) Failure:
Alipay::ServiceTest#test_create_merchant_qr_code [/rails/test/alipay/service_test.rb:284]:
--- expected
+++ actual
@@ -1 +1 @@
-"https://mapi.alipay.com/gateway.do?service=alipay.commerce.qrcode.create&_input_charset=utf-8&partner=1000000000000000&timestamp=2023-12-11+17%3A01%3A01&biz_data=%7B%22address%22%3A+%22No.278%2C+Road+YinCheng%2C+Shanghai%2C+China%22%2C%22country_code%22%3A+%22CN%22%2C%22currency%22%3A+%22USD%22%2C%22secondary_merchant_id%22%3A+%22xxx001%22%2C%22secondary_merchant_industry%22%3A+%227011%22%2C%22secondary_merchant_name%22%3A+%22xxx+Store%22%2C%22store_id%22%3A+%220001%22%2C%22store_name%22%3A+%22Apple+store%22%2C%22trans_currency%22%3A+%22USD%22%7D&biz_type=OVERSEASHOPQRCODE&sign_type=MD5&sign=fbfcc8c9316cc209c385eefcbceb2105"
+"https://mapi.alipay.com/gateway.do?service=alipay.commerce.qrcode.create&_input_charset=utf-8&partner=1000000000000000&timestamp=2023-12-12+01%3A01%3A01&biz_data=%7B%22address%22%3A+%22No.278%2C+Road+YinCheng%2C+Shanghai%2C+China%22%2C%22country_code%22%3A+%22CN%22%2C%22currency%22%3A+%22USD%22%2C%22secondary_merchant_id%22%3A+%22xxx001%22%2C%22secondary_merchant_industry%22%3A+%227011%22%2C%22secondary_merchant_name%22%3A+%22xxx+Store%22%2C%22store_id%22%3A+%220001%22%2C%22store_name%22%3A+%22Apple+store%22%2C%22trans_currency%22%3A+%22USD%22%7D&biz_type=OVERSEASHOPQRCODE&sign_type=MD5&sign=1c8881161f5895d0e7bbc8f4f5cad06c"


  2) Failure:
Alipay::ServiceTest#test_update_merchant_qr_code [/rails/test/alipay/service_test.rb:307]:
--- expected
+++ actual
@@ -1 +1 @@
-"https://mapi.alipay.com/gateway.do?service=alipay.commerce.qrcode.modify&_input_charset=utf-8&partner=1000000000000000&timestamp=2023-12-11+17%3A01%3A01&biz_data=%7B%22address%22%3A+%22No.278%2C+Road+YinCheng%2C+Shanghai%2C+China%22%2C%22country_code%22%3A+%22CN%22%2C%22currency%22%3A+%22USD%22%2C%22secondary_merchant_id%22%3A+%22xxx001%22%2C%22secondary_merchant_industry%22%3A+%227011%22%2C%22secondary_merchant_name%22%3A+%22xxx+Store%22%2C%22store_id%22%3A+%220001%22%2C%22store_name%22%3A+%22Apple+store%22%2C%22trans_currency%22%3A+%22USD%22%7D&biz_type=OVERSEASHOPQRCODE&qr_code=https%3A%2F%2Fqr.alipay.com%2Fbaxxxxx&sign_type=MD5&sign=5a72863d023163147f2909e74b741e52"
+"https://mapi.alipay.com/gateway.do?service=alipay.commerce.qrcode.modify&_input_charset=utf-8&partner=1000000000000000&timestamp=2023-12-12+01%3A01%3A01&biz_data=%7B%22address%22%3A+%22No.278%2C+Road+YinCheng%2C+Shanghai%2C+China%22%2C%22country_code%22%3A+%22CN%22%2C%22currency%22%3A+%22USD%22%2C%22secondary_merchant_id%22%3A+%22xxx001%22%2C%22secondary_merchant_industry%22%3A+%227011%22%2C%22secondary_merchant_name%22%3A+%22xxx+Store%22%2C%22store_id%22%3A+%220001%22%2C%22store_name%22%3A+%22Apple+store%22%2C%22trans_currency%22%3A+%22USD%22%7D&biz_type=OVERSEASHOPQRCODE&qr_code=https%3A%2F%2Fqr.alipay.com%2Fbaxxxxx&sign_type=MD5&sign=4d43f06b3d60cfc96750876287ef66ca"

I can simply modify the test case to make it pass, but want to confirm whether your local test also has this error?

hmm weird, i am able to pass the test locally

i think the issue should be the Time.now somehow not able to be stub correctly, which cause the signature value is different, but not sure why it not reproducible at my end

  alipay git:(master) bundle exec rake
/Users/kschee/Workspace/fave/alipay/lib/alipay/utils.rb:26: warning: assigned but unused variable - exception
Run options: --seed 38168

# Running:

......................................................

Finished in 0.629430s, 85.7919 runs/s, 95.3243 assertions/s.

54 runs, 60 assertions, 0 failures, 0 errors, 0 skips

@chloerei
Copy link
Owner

@kahshing96 You are running test on master, can you test on branch FAVE-27624-rebase-original-repo ? I test fail after pull the branch local.

@kahshing96
Copy link
Contributor

@chloerei work for me

  alipay git:(chore/FAVE-27624-rebase-original-repo)  bundle exec rake
/Users/kschee/Workspace/fave/alipay/lib/alipay/utils.rb:26: warning: assigned but unused variable - exception
Run options: --seed 57383

# Running:

......................................................

Finished in 0.275448s, 196.0443 runs/s, 217.8270 assertions/s.

54 runs, 60 assertions, 0 failures, 0 errors, 0 skips

@chloerei
Copy link
Owner

chloerei commented Jul 26, 2023

@kahshing96 I think it's the timezone. Time.new(2023, 12, 12, 1, 1, 1) base on local timezone.

I think it should use current_time = Time.utc(2023, 12, 12, 1, 1, 1) in test case. Then the test will fail because the sign in the test case before is based on your local time.

@kahshing96
Copy link
Contributor

@chloerei i think you're right, it was due to the timezone which cause the test failed, let me try create a new PR for this

@chloerei
Copy link
Owner

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

Successfully merging this pull request may close these issues.

4 participants