Test.py 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. """
  4. @Copyright (C) ansjer cop Video Technology Co.,Ltd.All rights reserved.
  5. @AUTHOR: ASJRD018
  6. @NAME: Ansjer
  7. @software: PyCharm
  8. @DATE: 2018/5/22 13:58
  9. @Version: python3.6
  10. @MODIFY DECORD:ansjer dev
  11. @file: Test.py
  12. @Contact: chanjunkai@163.com
  13. """
  14. from django.views.generic.base import View
  15. '''
  16. http://192.168.136.40:8077/Test
  17. '''
  18. from Object.ResponseObject import ResponseObject
  19. from Ansjer.config import BASE_DIR
  20. # 测试接口sdk
  21. class Test(View):
  22. def get(self, request, *args, **kwargs):
  23. response = ResponseObject()
  24. from alipay import AliPay, ISVAliPay
  25. app_private_key_string = open(BASE_DIR + '/Controller/alipay_private_2048.pem').read()
  26. alipay_public_key_string = open(BASE_DIR + '/Controller/alipay_public_2048.pem').read()
  27. alipay = AliPay(
  28. appid="2016092200569234",
  29. app_notify_url=None, # the default notify path
  30. app_private_key_string=app_private_key_string,
  31. # alipay public key, do not use your own public key!
  32. alipay_public_key_string=alipay_public_key_string,
  33. sign_type="RSA", # RSA or RSA2
  34. debug=False # False by default
  35. )
  36. order_string = alipay.api_alipay_trade_wap_pay(
  37. out_trade_no="20161112",
  38. total_amount=0.01,
  39. subject="实用性充气版玩具",
  40. return_url="http://example.com",
  41. notify_url="https://example.com/notify" # this is optional
  42. )
  43. print(order_string)
  44. from django.http import HttpResponseRedirect
  45. # return response.json(0,"https://openapi.alipay.com/gateway.do? + {order_string}".format(order_string=order_string))
  46. print(order_string)
  47. return HttpResponseRedirect("https://openapi.alipaydev.com/gateway.do?"+order_string)
  48. return response.json(0,)
  49. # 增加
  50. def post(self, request, *args, **kwargs):
  51. response = ResponseObject()
  52. return response.json(0)
  53. # 修改 资源改变
  54. def put(self, request):
  55. response = ResponseObject()
  56. return response.json(0)
  57. # 修改 属性改变
  58. def PATCH(self, request):
  59. response = ResponseObject()
  60. return response.json(0)
  61. # 删除
  62. def delete(self, request):
  63. response = ResponseObject()
  64. return response.json(0)
  65. def validation(self, request_dict, *args, **kwargs):
  66. response = ResponseObject()
  67. return response.json(0)