public void should_be_able_to_send_token()
        {
            IAopClient client = new DefaultAopClient(TestAccount.ProdCert.Gateway, TestAccount.ProdCert.AppId,
                                                     TestAccount.ProdCert.AppPrivateKey, "json", "1.0", "RSA2", "utf-8", false, TestAccount.ProdCert.CertParams);
            AlipayOpenOperationOpenbizmockBizQueryResponse response = client.CertificateExecute(GetRequest(), "123", "456");

            Assert.AreEqual(response.SubMsg.Contains("无效的应用授权令牌"), true);
        }
        public void should_return_correct_response()
        {
            IAopClient client = new DefaultAopClient(TestAccount.ProdCert.Gateway, TestAccount.ProdCert.AppId,
                                                     TestAccount.ProdCert.AppPrivateKey, "json", "1.0", "RSA2", "utf-8", false, TestAccount.ProdCert.CertParams);
            AlipayOpenOperationOpenbizmockBizQueryRequest request = GetRequest();

            AlipayOpenOperationOpenbizmockBizQueryResponse response = client.CertificateExecute(request);

            Assert.AreEqual(response.IsError, false);
            Assert.AreEqual(response.Code, "10000");
        }
        public void should_be_able_to_parse_xml_format_response()
        {
            //given
            IAopClient client = new DefaultAopClient(TestAccount.ProdCert.Gateway, TestAccount.ProdCert.AppId,
                                                     TestAccount.ProdCert.AppPrivateKey, "xml", "1.0", "RSA2", "utf-8", false, TestAccount.ProdCert.CertParams);
            AlipayOpenOperationOpenbizmockBizQueryRequest request = GetRequest();
            //when
            AlipayOpenOperationOpenbizmockBizQueryResponse response = client.CertificateExecute(request);

            //then
            Assert.AreEqual(response.IsError, false);
        }
        //TODO:待相关依赖上线后替换为线上环境测试
        public void should_auto_download_alipay_public_cert_when_use_sm2()
        {
            IAopClient client = new DefaultAopClient(TestAccount.DevSM2Cert.Gateway, TestAccount.DevSM2Cert.AppId,
                                                     TestAccount.DevSM2Cert.AppPrivateKey,
                                                     "json", "1.0", "SM2", "utf-8", false, TestAccount.DevSM2Cert.CertParams);
            AlipayOpenOperationOpenbizmockBizQueryRequest request = GetRequest();

            AlipayOpenOperationOpenbizmockBizQueryResponse response = client.CertificateExecute(request);

            Assert.AreEqual(response.IsError, false);
            Assert.AreEqual(response.Code, "10000");
        }
        public void should_get_exception_when_call_cert_execute()
        {
            //given
            IAopClient client = new DefaultAopClient(TestAccount.Sandbox.Gateway, TestAccount.Sandbox.AppId,
                                                     TestAccount.Sandbox.AppPrivateKey, "json", "1.0", "RSA2", TestAccount.Sandbox.AlipayPublicKey, "utf-8", false);
            AlipayTradeCreateRequest request = getTradeCreateRequest();

            //then
            AopException ex = Assert.Throws <AopException>(() => client.CertificateExecute(request));

            Assert.AreEqual(ex.Message.Contains("检测到证书相关参数未初始化,非证书模式下请改为调用Execute"), true);
        }
        public void should_return_false_when_app_not_set_private_key()
        {
            //given
            //访问线上一个没有设置公私钥对的APP
            IAopClient client = new DefaultAopClient(TestAccount.ProdCert.Gateway, TestAccount.NotSetKeyAppId,
                                                     TestAccount.ProdCert.AppPrivateKey, "json", "1,0", "RSA2", "utf-8", false, TestAccount.ProdCert.CertParams);
            //when
            AlipayOpenOperationOpenbizmockBizQueryResponse response = client.CertificateExecute(GetRequest());

            //then
            Assert.AreEqual(response.IsError, true);
            Assert.AreEqual(response.SubMsg.Contains("应用未配置对应签名算法的公钥或者证书"), true);
        }
        public void should_auto_download_alipay_public_cert()
        {
            CertParams certParams = TestAccount.ProdCert.CertParams;

            //将支付宝公钥证书路径故意设置成商户证书路径,以便触发自动下载支付宝公钥证书链路
            certParams.AlipayPublicCertPath = certParams.AppCertPath;
            IAopClient client = new DefaultAopClient(TestAccount.ProdCert.Gateway, TestAccount.ProdCert.AppId,
                                                     TestAccount.ProdCert.AppPrivateKey, "json", "1.0", "RSA2", "utf-8", false, certParams);
            AlipayOpenOperationOpenbizmockBizQueryRequest request = GetRequest();

            AlipayOpenOperationOpenbizmockBizQueryResponse response = client.CertificateExecute(request);

            Assert.AreEqual(response.IsError, false);
            Assert.AreEqual(response.Code, "10000");
        }
Beispiel #8
0
        public void should_be_able_to_upload_file()
        {
            IAopClient client = new DefaultAopClient(TestAccount.ProdCert.Gateway, TestAccount.ProdCert.AppId,
                                                     TestAccount.ProdCert.AppPrivateKey, "json", "1.0", "RSA2", "utf-8", false, TestAccount.ProdCert.CertParams);

            AlipayOfflineMaterialImageUploadRequest request = new AlipayOfflineMaterialImageUploadRequest();

            request.ImageType = "jpg";
            request.ImageName = "海底捞";
            FileItem ImageContent = new FileItem(GetTestImagePath());

            request.ImagePid     = "2088021822217233";
            request.ImageContent = ImageContent;
            AlipayOfflineMaterialImageUploadResponse response = client.CertificateExecute(request);

            Assert.AreEqual(response.Body.Contains("ISV权限不足"), true);
        }
        public ActionResult CheckApplyCashRecordByAli(int id)
        {
            try
            {
                UserInfo             userInfo             = LoginUserInfo.Get();
                dm_basesettingEntity dm_BasesettingEntity = dM_BaseSettingIBLL.GetEntity(userInfo.companyId);

                dm_apply_cashrecordEntity jlm_Xcx_Apply_CashrecordEntity = dM_Apply_CashRecordIBLL.GetEntity(id);

                if (jlm_Xcx_Apply_CashrecordEntity.IsEmpty())
                {
                    throw new Exception("未找到提现记录!");
                }

                if (jlm_Xcx_Apply_CashrecordEntity.status != 0)
                {
                    throw new Exception("当前提现记录不可操作!");
                }

                dm_userEntity dm_UserEntity = dM_UserIBLL.GetEntity(jlm_Xcx_Apply_CashrecordEntity.user_id);
                if (dm_UserEntity.IsEmpty())
                {
                    throw new Exception("未检测到用户信息!");
                }
                if (dm_UserEntity.realname.IsEmpty())
                {
                    throw new Exception("该用户未实名!");
                }
                if (dm_UserEntity.zfb.IsEmpty())
                {
                    throw new Exception("该用户未绑定支付宝账号!");
                }


                IAopClient client = new DefaultAopClient("https://openapi.alipay.com/gateway.do", dm_BasesettingEntity.alipay_appid, dm_BasesettingEntity.merchant_private_key, "json", "1.0", "RSA2", "utf-8", false, AliPayHelper.GetCertParams(dm_BasesettingEntity.alipay_appid, base.Server));
                AlipayFundTransUniTransferRequest request = new AlipayFundTransUniTransferRequest();
                request.BizContent = "{" +
                                     "\"out_biz_no\":\"" + Guid.NewGuid().ToString() + "\"," +
                                     "\"trans_amount\":" + jlm_Xcx_Apply_CashrecordEntity.price + "," +
                                     "\"product_code\":\"TRANS_ACCOUNT_NO_PWD\"," +
                                     "\"biz_scene\":\"DIRECT_TRANSFER\"," +
                                     "\"order_title\":\"哆来米\"," +
                                     "\"original_order_id\":\"\"," +
                                     "\"payee_info\":{" +
                                     "\"identity\":\"" + dm_UserEntity.zfb + "\"," +
                                     "\"identity_type\":\"ALIPAY_LOGON_ID\"," +
                                     "\"name\":\"" + dm_UserEntity.realname + "\"" +
                                     "    }," +
                                     "\"remark\":\"余额提现\"," +
                                     "\"business_params\":\"{\\\"sub_biz_scene\\\":\\\"REDPACKET\\\"}\"" +
                                     "  }";
                AlipayFundTransUniTransferResponse response = client.CertificateExecute(request);
                if (response.IsError)
                {
                    throw new Exception(response.Msg + "=>" + response.SubMsg);
                }

                jlm_Xcx_Apply_CashrecordEntity.paytype        = 2;
                jlm_Xcx_Apply_CashrecordEntity.status         = 1;
                jlm_Xcx_Apply_CashrecordEntity.OrderId        = response.OrderId;
                jlm_Xcx_Apply_CashrecordEntity.PayFundOrderId = response.PayFundOrderId;
                jlm_Xcx_Apply_CashrecordEntity.TransDate      = DateTime.Parse(response.TransDate);
                jlm_Xcx_Apply_CashrecordEntity.checktime      = DateTime.Now;

                dM_Apply_CashRecordIBLL.CheckApplyCashRecordByAli(jlm_Xcx_Apply_CashrecordEntity);

                return(Success("打款成功!"));
            }
            catch (Exception ex)
            {
                return(FailException(ex));
            }
        }