AopClientTest.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <?php
  2. /**
  3. * 重庆赤晓店信息科技有限公司
  4. * https://www.chixiaodian.com
  5. * Copyright (c) 2023 赤店商城 All rights reserved.
  6. */
  7. require_once '../AopClient.php';
  8. require_once '../AopCertification.php';
  9. require_once '../request/AlipayTradeQueryRequest.php';
  10. require_once '../request/AlipayTradeWapPayRequest.php';
  11. require_once '../request/AlipayTradeAppPayRequest.php';
  12. /**
  13. * 证书类型AopClient功能方法使用测试
  14. * 1、execute 调用示例
  15. * 2、sdkExecute 调用示例
  16. * 3、pageExecute 调用示例
  17. */
  18. //1、execute 使用
  19. $aop = new AopClient ();
  20. $aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
  21. $aop->appId = '你的appid';
  22. $aop->rsaPrivateKey = '你的应用私钥';
  23. $aop->alipayrsaPublicKey = '你的支付宝公钥';
  24. $aop->apiVersion = '1.0';
  25. $aop->signType = 'RSA2';
  26. $aop->postCharset = 'utf-8';
  27. $aop->format = 'json';
  28. $request = new AlipayTradeQueryRequest ();
  29. $request->setBizContent("{" .
  30. "\"out_trade_no\":\"20150320010101001\"," .
  31. "\"trade_no\":\"2014112611001004680 073956707\"," .
  32. "\"org_pid\":\"2088101117952222\"," .
  33. " \"query_options\":[" .
  34. " \"TRADE_SETTE_INFO\"" .
  35. " ]" .
  36. " }");
  37. $result = $aop->execute($request);
  38. echo $result;
  39. //2、sdkExecute 测试
  40. $aop = new AopClient ();
  41. $aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
  42. $aop->appId = '你的appid';
  43. $aop->rsaPrivateKey = '你的应用私钥';
  44. $aop->alipayrsaPublicKey = '你的支付宝公钥';
  45. $aop->apiVersion = '1.0';
  46. $aop->signType = 'RSA2';
  47. $aop->postCharset = 'utf-8';
  48. $aop->format = 'json';
  49. $request = new AlipayTradeAppPayRequest ();
  50. $request->setBizContent("{" .
  51. "\"timeout_express\":\"90m\"," .
  52. "\"total_amount\":\"9.00\"," .
  53. "\"product_code\":\"QUICK_MSECURITY_PAY\"," .
  54. "\"body\":\"Iphone6 16G\"," .
  55. "\"subject\":\"大乐透\"," .
  56. "\"out_trade_no\":\"70501111111S001111119\"," .
  57. "\"time_expire\":\"2016-12-31 10:05\"," .
  58. "\"goods_type\":\"0\"," .
  59. "\"promo_params\":\"{\\\"storeIdType\\\":\\\"1\\\"}\"," .
  60. "\"passback_params\":\"merchantBizType%3d3C%26merchantBizNo%3d2016010101111\"," .
  61. "\"extend_params\":{" .
  62. "\"sys_service_provider_id\":\"2088511833207846\"," .
  63. "\"hb_fq_num\":\"3\"," .
  64. "\"hb_fq_seller_percent\":\"100\"," .
  65. "\"industry_reflux_info\":\"{\\\\\\\"scene_code\\\\\\\":\\\\\\\"metro_tradeorder\\\\\\\",\\\\\\\"channel\\\\\\\":\\\\\\\"xxxx\\\\\\\",\\\\\\\"scene_data\\\\\\\":{\\\\\\\"asset_name\\\\\\\":\\\\\\\"ALIPAY\\\\\\\"}}\"," .
  66. "\"card_type\":\"S0JP0000\"" .
  67. " }," .
  68. "\"merchant_order_no\":\"20161008001\"," .
  69. "\"enable_pay_channels\":\"pcredit,moneyFund,debitCardExpress\"," .
  70. "\"store_id\":\"NJ_001\"," .
  71. "\"specified_channel\":\"pcredit\"," .
  72. "\"disable_pay_channels\":\"pcredit,moneyFund,debitCardExpress\"," .
  73. " \"goods_detail\":[{" .
  74. " \"goods_id\":\"apple-01\"," .
  75. "\"alipay_goods_id\":\"20010001\"," .
  76. "\"goods_name\":\"ipad\"," .
  77. "\"quantity\":1," .
  78. "\"price\":2000," .
  79. "\"goods_category\":\"34543238\"," .
  80. "\"categories_tree\":\"124868003|126232002|126252004\"," .
  81. "\"body\":\"特价手机\"," .
  82. "\"show_url\":\"http://www.alipay.com/xxx.jpg\"" .
  83. " }]," .
  84. "\"ext_user_info\":{" .
  85. "\"name\":\"李明\"," .
  86. "\"mobile\":\"16587658765\"," .
  87. "\"cert_type\":\"IDENTITY_CARD\"," .
  88. "\"cert_no\":\"362334768769238881\"," .
  89. "\"min_age\":\"18\"," .
  90. "\"fix_buyer\":\"F\"," .
  91. "\"need_check_info\":\"F\"" .
  92. " }," .
  93. "\"business_params\":\"{\\\"data\\\":\\\"123\\\"}\"," .
  94. "\"agreement_sign_params\":{" .
  95. "\"personal_product_code\":\"CYCLE_PAY_AUTH_P\"," .
  96. "\"sign_scene\":\"INDUSTRY|DIGITAL_MEDIA\"," .
  97. "\"external_agreement_no\":\"test20190701\"," .
  98. "\"external_logon_id\":\"13852852877\"," .
  99. "\"access_params\":{" .
  100. "\"channel\":\"ALIPAYAPP\"" .
  101. " }," .
  102. "\"sub_merchant\":{" .
  103. "\"sub_merchant_id\":\"2088123412341234\"," .
  104. "\"sub_merchant_name\":\"滴滴出行\"," .
  105. "\"sub_merchant_service_name\":\"滴滴出行免密支付\"," .
  106. "\"sub_merchant_service_description\":\"免密付车费,单次最高500\"" .
  107. " }," .
  108. "\"period_rule_params\":{" .
  109. "\"period_type\":\"DAY\"," .
  110. "\"period\":3," .
  111. "\"execute_time\":\"2019-01-23\"," .
  112. "\"single_amount\":10.99," .
  113. "\"total_amount\":600," .
  114. "\"total_payments\":12" .
  115. " }" .
  116. " }" .
  117. " }");
  118. $result = $aop->sdkExecute($request);
  119. $responseNode = str_replace(".", "_", $request->getApiMethodName()) . "_response";
  120. echo $responseNode;
  121. //3、pageExecute 测试
  122. $aop = new AopClient ();
  123. $aop->gatewayUrl = 'https://openapi.alipay.com/gateway.do';
  124. $aop->appId = '你的appid';
  125. $aop->rsaPrivateKey = '你的应用私钥';
  126. $aop->alipayrsaPublicKey = '你的支付宝公钥';
  127. $aop->apiVersion = '1.0';
  128. $aop->signType = 'RSA2';
  129. $aop->postCharset = 'utf-8';
  130. $aop->format = 'json';
  131. $request = new AlipayTradeWapPayRequest ();
  132. $request->setBizContent("{" .
  133. " \"body\":\"对一笔交易的具体描述信息。如果是多种商品,请将商品描述字符串累加传给body。\"," .
  134. " \"subject\":\"测试\"," .
  135. " \"out_trade_no\":\"70501111111S001111119\"," .
  136. " \"timeout_express\":\"90m\"," .
  137. " \"total_amount\":9.00," .
  138. " \"product_code\":\"QUICK_WAP_WAY\"" .
  139. " }");
  140. $result = $aop->pageExecute($request);
  141. echo $result;