AopClientTest.php 5.3 KB

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