Test.py 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. import time
  26. app_private_key_string = open(BASE_DIR + '/Controller/alipay_private_2048.pem').read()
  27. alipay_public_key_string = open(BASE_DIR + '/Controller/alipay_public_2048.pem').read()
  28. orderID = int(time.time())+int(time.time())
  29. alipay = AliPay(
  30. appid="2017080107983629",
  31. app_notify_url=None, # the default notify path
  32. app_private_key_string=app_private_key_string,
  33. # alipay public key, do not use your own public key!
  34. alipay_public_key_string=alipay_public_key_string,
  35. sign_type="RSA", # RSA or RSA2
  36. debug=False # False by default
  37. )
  38. order_string = alipay.api_alipay_trade_wap_pay(
  39. out_trade_no=str(orderID),
  40. total_amount=0.01,
  41. subject="实用性充气版玩具",
  42. return_url="https://test.dvema.com",
  43. # notify_url="https://example.com/notify" # this is optional
  44. )
  45. print(order_string)
  46. from django.http import HttpResponseRedirect
  47. # return response.json(0,"https://openapi.alipay.com/gateway.do? + {order_string}".format(order_string=order_string))
  48. print(order_string)
  49. return HttpResponseRedirect("https://openapi.alipay.com/gateway.do?"+order_string)
  50. # # 增加
  51. # def get(self, request, *args, **kwargs):
  52. # response = ResponseObject()
  53. # from alipay import AliPay, ISVAliPay
  54. # import time
  55. # app_private_key_string = open(BASE_DIR + '/Controller/alipay_private_2048.pem').read()
  56. # alipay_public_key_string = open(BASE_DIR + '/Controller/alipay_public_2048.pem').read()
  57. # orderID = int(time.time())+int(time.time())
  58. # alipay = AliPay(
  59. # appid="2016092200569234",
  60. # app_notify_url=None, # the default notify path
  61. # app_private_key_string=app_private_key_string,
  62. # # alipay public key, do not use your own public key!
  63. # alipay_public_key_string=alipay_public_key_string,
  64. # sign_type="RSA", # RSA or RSA2
  65. # debug=False # False by default
  66. # )
  67. # order_string = alipay.api_alipay_trade_wap_pay(
  68. # out_trade_no=str(orderID),
  69. # total_amount=0.01,
  70. # subject="实用性充气版玩具",
  71. # return_url="https://test.dvema.com",
  72. # # notify_url="https://example.com/notify" # this is optional
  73. # )
  74. # print(order_string)
  75. # from django.http import HttpResponseRedirect
  76. # # return response.json(0,"https://openapi.alipay.com/gateway.do? + {order_string}".format(order_string=order_string))
  77. # print(order_string)
  78. # return HttpResponseRedirect("https://openapi.alipaydev.com/gateway.do?"+order_string)
  79. # # 增加
  80. def post(self, request, *args, **kwargs):
  81. response = ResponseObject()
  82. return response.json(0)
  83. # 修改 资源改变
  84. def put(self, request):
  85. response = ResponseObject()
  86. return response.json(0)
  87. # 修改 属性改变
  88. def PATCH(self, request):
  89. response = ResponseObject()
  90. return response.json(0)
  91. # 删除
  92. def delete(self, request):
  93. response = ResponseObject()
  94. return response.json(0)
  95. def validation(self, request_dict, *args, **kwargs):
  96. response = ResponseObject()
  97. return response.json(0)