download:支付宝预授权PHP版.zip说明: 本帖是.net开发语言测试支付宝预授权的请求示例,仅供参考!!
一、下载demo:
Java版:download:支付宝预授权Java版.zip
.NET版:download:支付宝预授权net版.zip
二、请求示例(.NET版)
线上资金授权冻结(alipay.fund.auth.order.app.freeze)
.NET版请求示例:
IAopClient client = new DefaultAopClient(config.gatewayUrl, config.app_id, config.private_key, "json", "1.0", "RSA2", config.alipay_public_key, config.charset, false); AlipayFundAuthOrderAppFreezeRequest request = new AlipayFundAuthOrderAppFreezeRequest(); request.BizContent = "{" + "\"out_order_no\":\"20181121ygyg454451111245031\"," + "\"out_request_no\":\"20181121ygyg454445486031\"," + "\"order_title\":\"煜雨预授权冻结\"," + "\"amount\":0.01," + "\"product_code\":\"PRE_AUTH_ONLINE\"," + "\"payee_user_id\":\"2088721629150894\"," + "\"extra_param\":\"{\\\"category\\\":\\\"CHARGE_PILE_CAR\\\"}\"," + "\"enable_pay_channels\":\"[{\\\"payChannelType\\\":\\\"PCREDIT_PAY\\\"},{\\\"payChannelType\\\":\\\"MONEY_FUND\\\"},{\\\"payChannelType\\\":\\\"CREDITZHIMA\\\"}]\"" + " }"; AlipayFundAuthOrderAppFreezeResponse response = client.SdkExecute(request); Console.WriteLine(response.Body);
返回的请求参数信息:
app_id=2018022802289740&biz_content=%7b%22out_order_no%22%3a%2220181121ygyg454451111245031%22%2c%22out_request_no%22%3a%2220181121ygyg454445486031%22%2c%22order_title%22%3a%22%e7%85%9c%e9%9b%a8%e9%a2%84%e6%8e%88%e6%9d%83%e5%86%bb%e7%bb%93%22%2c%22amount%22%3a0.01%2c%22product_code%22%3a%22PRE_AUTH_ONLINE%22%2c%22payee_user_id%22%3a%222088721629150894%22%2c%22extra_param%22%3a%22%7b%5c%22category%5c%22%3a%5c%22CHARGE_PILE_CAR%5c%22%7d%22%2c%22enable_pay_channels%22%3a%22%5b%7b%5c%22payChannelType%5c%22%3a%5c%22PCREDIT_PAY%5c%22%7d%2c%7b%5c%22payChannelType%5c%22%3a%5c%22MONEY_FUND%5c%22%7d%2c%7b%5c%22payChannelType%5c%22%3a%5c%22CREDITZHIMA%5c%22%7d%5d%22%7d&charset=UTF-8&format=json&method=alipay.fund.auth.order.app.freeze&sign_type=RSA2×tamp=2018-12-05+17%3a25%3a43&version=1.0&sign=RyyyCs3pmxKZLBAAsu%2bvOzTJeWRw0kQcamtquBiaVJ9l3ZVQOGLedtxLRZeY3r7JABnl4rh%2fNS72ATT1Vw1QKjhd6vEoQwp9SNx9XtRKys8XeeKh4v90aKvzCKIQHVmXo0LYWt5pxWejMTyejoVeiK15VB2U%2bM0VmSJQktwwhIcKlcmuOyO2fW%2b7g18pzzcNVWeMR%2fTdik4tp%2b09zcOJFbuTjM8CB66tjJempLDQ0NF%2bD8u7RWYKJrXasxYbCIWiHxEDSwPTlRZxctKkmMLdbvv%2fa3Tx9LE2n0c1fLRcYDszBdoxQQKX9D8friqJYqmI3ySETNozokKbPOuAo80nOg%3d%3d
资金授权操作查询(alipay.fund.auth.operation.detail.query)
.NET版请求示例:
IAopClient client = new DefaultAopClient(config.gatewayUrl, config.app_id, config.private_key, "json", "1.0", "RSA2", config.alipay_public_key, config.charset, false); AlipayFundAuthOperationDetailQueryRequest request = new AlipayFundAuthOperationDetailQueryRequest(); request.BizContent = "{" + // "\"auth_no\":\"2014021601002000640012345678\"," + "\"out_order_no\":\"20181122ygyg454order45111100010\"," + // "\"operation_id\":\"20140216010020006400\"," + "\"out_request_no\":\"20181122ygyg454req4519120010\"" + "}"; AlipayFundAuthOperationDetailQueryResponse response = client.Execute(request); Console.WriteLine(response.Body);
返回的响应参数信息示例:
{"alipay_fund_auth_operation_detail_query_response":{"code":"10000","msg":"Success","amount":"0.01","auth_no":"2018120410002001940211519175","credit_amount":"0.01","extra_param":"{}","fund_amount":"0.00","gmt_create":"2018-12-04 14:35:21","gmt_trans":"2018-12-04 14:35:28","operation_id":"20181204536554269402","operation_type":"FREEZE","order_title":"煜雨支付宝预授权冻结","out_order_no":"20181122ygyg454order45111100010","out_request_no":"20181122ygyg454req4519120010","payer_logon_id":"171****6056","payer_user_id":"2088022304381942","pre_auth_type":"CREDIT_AUTH","remark":"煜雨支付宝预授权冻结","rest_amount":"0.00","rest_credit_amount":"0.00","rest_fund_amount":"0.00","status":"SUCCESS","total_freeze_amount":"0.01","total_freeze_credit_amount":"0.01","total_freeze_fund_amount":"0.00","total_pay_amount":"0.01","total_pay_credit_amount":"0.01","total_pay_fund_amount":"0.00"},"sign":"fZttuSCurCi4ZPj00tNcRs8IZRpk8pkzXOh4hL/zRDIUiTyWBHsX/7xYyAGiN0byeziVBJ4a3Lo+MkKc3CCoqqve+Y3EItr90nA5NoCdsrMrFIhg3zLoMhLm3j7EehAKdlWVwpHEzKs0v+j33UkoAI6o17xG09vcHZVZJFEcLP0onfpPyCzxrprdIMnbwiL5JG/kidaMR69SIrMFvdE2xXm424swhOOozf6w7OHKXa9G61D2zb3eFCDy2ucU/c+OgT4U3J0jLT54bKPmvMF88mrh+x6x5ypYn7WsTGRC/3qZuMum5RUJx0ZPH5gx4qBeFyGm+bT86Wpbu1gCQrkCWQ=="}
授权转支付(alipay.trade.pay)
.NET版请求示例:
IAopClient client = new DefaultAopClient(config.gatewayUrl, config.app_id, config.private_key, "json", "1.0", "RSA2", config.alipay_public_key, config.charset, false); AlipayTradePayRequest request = new AlipayTradePayRequest(); request.BizContent = "{" + "\"out_trade_no\":\"2018092845ygyg4454448940454545977\"," + "\"product_code\":\"PRE_AUTH_ONLINE\"," + "\"subject\":\"煜雨授权转支付\"," + "\"buyer_id\":\"2088112820309864\"," + "\"seller_id\":\"2088721629150894\"," + "\"total_amount\":0.01," + "\"body\":\"煜雨测试\"," + "\"auth_no\":\"2018121210002001940292964839\"" + "}"; AlipayTradePayResponse response = client.Execute(request); Console.WriteLine(response.Body);
返回的响应参数信息示例:
{"alipay_trade_pay_response":{"code":"10000","msg":"Success","buyer_logon_id":"171****6056","buyer_pay_amount":"0.00","buyer_user_id":"2088022304381942","invoice_amount":"0.00","out_trade_no":"2018092845ygyg4454448940454545977","point_amount":"0.00","receipt_amount":"0.00","total_amount":"0.01","trade_no":"2018121222001481941012997618"},"sign":"apnPjicYEKPZs0v7nc6oEk3y4YvuxfVA74w+2iqq2W5Cyse3AXCuHMBSD9AepJbFAAxygoNexhLalOMbDCcHR/+csAUfYVV3nJu4vMR6INT0kCzR8Crpy7fB1/v7009YmxTt/xKeII1YgrJp6dlZIRDh2IYh50VVuijhkIA+fxMViq7gs6taZidZbpLiO8X4sbFHOwPnAnxno6ClQPhez8Qz90P3//SZhiLOJg7iMyI7PPyTpLXLBEFET3E2oKz9UhmWN8mXI3m9zoKLFulEJ9zkWyrAxheZ3MZ7HTNfR/VcKKKtFivp13ojKCux4B5Vl9FnXfkwyc9Gm3jJkcF3ZA=="}
资金授权解冻(alipay.fund.auth.order.unfreeze)
.NET版请求示例:
IAopClient client = new DefaultAopClient(config.gatewayUrl, config.app_id, config.private_key, "json", "1.0", "RSA2", config.alipay_public_key, config.charset, false); AlipayFundAuthOrderUnfreezeRequest request = new AlipayFundAuthOrderUnfreezeRequest(); request.BizContent="{" + "\"auth_no\":\"2018121210002001940296835404\"," + "\"out_request_no\":\"20181122ygyg454unf45454789845454\"," + //自定义 "\"amount\":0.03," + "\"remark\":\"煜雨授权解冻\""+ "}"; AlipayFundAuthOrderUnfreezeResponse response = client.Execute(request); Console.WriteLine(response.Body);
返回的响应参数信息示例:
{"alipay_fund_auth_order_unfreeze_response":{"code":"10000","msg":"Success","amount":"0.03","auth_no":"2018121210002001940296835404","gmt_trans":"2018-12-12 11:16:37","operation_id":"20181212337981519402","out_order_no":"20181122ygyg454order45111100031","out_request_no":"20181122ygyg454unf45454789845454","status":"SUCCESS"},"sign":"GLwHS1abF6IU6UI92Xy9yOSTErY9RS8lT5eeNulVQiWsuLGop6k3qTUNXzDt6/uwc0c68iWFX69ZCGEcFl3MI4ClRyXYZsGW5sE5RDFnmFgK5V813b85SUoP0leZ0WAzFro88X6mNDB2TTdl46jGmDixX3ieA+3mX5lqAOpiVetwLbkzK+v4eltGbCJYLDYlHBDR1VnA+lpihhRM8f+pFt4Hx28ScebblHt07COx7zSx+0ox339xeCm64O77BeWy7/LZSoZisJIrPePvmMuSZPt6IUaWXKzyioFQk7sMdxtarI7feB2CONrUsrewpQbcUXXI2XpLxlq4agpiSadrSA=="}
资金授权撤销(alipay.fund.auth.operation.cancel)
.NET版请求示例:
IAopClient client = new DefaultAopClient(config.gatewayUrl, config.app_id, config.private_key, "json", "1.0", "RSA2", config.alipay_public_key, config.charset, false); AlipayFundAuthOperationCancelRequest request = new AlipayFundAuthOperationCancelRequest(); request.BizContent="{" + "\"auth_no\":\"2018121210002001940293417280\"," + //"\"out_order_no\":\"20181122ygyg454order45111100022\"," + "\"operation_id\":\"20181212345802279402\"," + //"\"out_request_no\":\"20181122ygyg4544545478984578\"," + "\"remark\":\"煜雨授权撤销\"" + "}"; AlipayFundAuthOperationCancelResponse response = client.Execute(request); Console.WriteLine(response.Body);
返回的响应参数信息示例:
{"alipay_fund_auth_operation_cancel_response":{"code":"10000","msg":"Success","action":"unfreeze","auth_no":"2018121210002001940293417280","operation_id":"20181212345802279402","out_order_no":"20181121ygyg45445111124544545","out_request_no":"20181121ygyg454445484545"},"sign":"aD/ehJEEp9xjVTYRBRNG4iIPE68oq1R1fKucQ2JdL4MCPKlMF8CZ6ijtwm7eIvpYQu80YQLWjLThBBrEMP2CQF8dW76cN0rQz+rZJmcaG+I178/vUTkBIhQznV27MIRhTgElwmqb3WxJP3aUurDJtuVC3cUeAfmJyKRqCS7r4Sp1Q9vpCug1zeXXCPWDhQhZ2/0aFrytk1AK41y1N63y5hVJ614BGy7NGwm0DfYnZYuwrYOsBptq55bBa7TEpfnz6a0fFOGzkd/6F6l2zEVOkFtaHRL8GDCt/bJBf9IVdPKb7t5XNpWcgD0bOqCJnf0V55JigbNqovSYg6f37DkBBw=="}