1、以支付宝“电脑网站支付”为例,下载sdk demo
/open/270/106291
demo代码如下
2、打开支付宝开发者中心 ->沙箱环境->沙箱应用
/platform/appDaily.htm?tab=info
将APPID、支付宝网关填入配置文件(根目录下config.php)
3、接下来配置config.php中的 “支付宝公钥”和“商户私钥”
此时需要下载“支付宝开放平台开发助手” , 我这里是win版本
/open/291/106097/
安装后打开,点击生成秘钥按钮
将“应用私钥”复制到config.php中merchant_private_key
应用公钥需要配置到沙箱环境中 如下:
保存设置
将“支付宝公钥”复制到config.php中alipay_public_key
4、访问demo下index.php即可打开支付demo示例
注意:域名不能使用localhost,必须使用公网可访问的域名才可以,如果没有推荐使用 natapp
下面是config.php配置详情
<?php$config = array (//应用ID,您的APPID。'app_id' => "102300743062",//商户私钥'merchant_private_key' => "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCa8tQBDr9gg5qPd4ra1QmksdlDscIemaOAuiXsN6oSm9SY8wuUKd+MYV6Oaxt4CauNtAcJZvOP1EmEAxoRw4RLx5n6Z8OiuT/3Fjc9gVgHEOpFtYO952H2yNy/9BY0lCBFCGN0B7bSqXzpXk8IRLTbiQdqdLORmsi/OE40SKma8SQEBbZmA/mKGQ7wE1DlkU7id7YrB1FrGbvzyDrr+csA2o7by8pic93twK7rvkLQxfVZAYVuY+ZlHubG6vruNXEQXHYehI5FBqVu6FpP/EGuagzhUrijuQneYIlYnGf7U4IhksxcBMwAB5EO2+lSAgpW1RPr7qj6/52fVMRhlgMZAgMBAAECggEAWCBoB7n1itUO4S4iYVftRiiI44GEYJcNcTduPi1io3bRsbP6D+jI5jSy7NlqJBmL4upTXjuZp2Ib9eM1voivA9KgdtTxZelqwgN2o5qfEFXEiKU2KpohE5UmSF5xCrJ8sAaXWfTRPHt9OdWTqaY6HuqOtzNsthGMv4UspXv2StKabyGbSPSEiI8IUP2ZXWdl6+uyLgWaN5epwlb76NIFIXIBp7Vlzk4ht4Ov95MeQVxwCdIotU1TvxR2W0ab7iLxO0e4qC1TYRU2fn5ebq1lhLnfOQ9V/g0zkPTiWL7XIJTrIk6I+AXTSivu9Z+OEfpsM+VsA5Jg9maT3hfVaVcpAQKBgQDoDYgKB1ULlLpJXxf6SidyYD7ARFlzxERoiDUIljuNMyYxfuUZEKAs4q6IIu1DwnSYDdBosUapc1qgpIwshAOsoKvDsLXIDovEck88xTs3AxgPZvZ0g/yArmyQg1S/Z2HMIs75Bxh6OLOEzns4oOZbu52PC6gwS1vqOnfOOhbOSQKBgQCq8FK3tkems6xf8kZ48MO2xDonp73k7HLiMYHfqJmQ+rlGUM5ejD8+xmF0IzhVk5EvwbgtBQzNbotM6HBBsmm0g70ITs4vySn2WS/1hYIPa8uADA45WGdKy/p82n3SJbmrZW5Suvodf72yw4NLKFyZAs2yVfawOsaWsdQh82DOUQKBgQDcb347iJuRVMdhy6PLb4XpcOQrYMJY5qjVZA59CbmoeF5fxlt7Y//Eo9GIISWiqKZ5iyXfTggCEEKXN7iw0PdslXSVgNguIyNCihQbdoC50YaZmwWjyX2kAA3BegCXkm2kraxPhB4MfLCMCFmlgbNSkPcrW7d5qRy3dLM6hJQFgQKBgHg5MCQvWnN/WNPeZPw4cZ4AotozGtaACkjWAv7X6LHT9SzkNlC/GNhA1FfHUZ62e913xN48+AUgI28C57j9D2U7Zl8Kde+b7xxpG9b1gETyTp0PXY2thHBRyCm5zdZYXB6U5yPeh3zp0/R/l77rczzWgO9VkHvfyr4/8e+y6boRAoGBALdodJUD44rLKevD1fsBqoFg203G7crvSG3IY9Iosbc80uK6TSVxU+Pyj8PmjowrO6j14jjS7Ue40qmjcganTgsPylvvKGYbqe8mj85iTB3aHwoXF6uJDutlVbSlZ7317sgchpkdE3pP7aPDaM0Vp1zQgwK0/o1MzvXvKuBLEezj",//异步通知地址'notify_url' => "/ali_pc_pay/notify_url.php",//同步跳转'return_url' => "/ali_pc_pay/return_url.php",//编码格式'charset' => "UTF-8",//签名方式'sign_type'=>"RSA2",//支付宝网关'gatewayUrl' => "/gateway.do",//支付宝公钥,查看地址:/platform/keyManage.htm 对应APPID下的支付宝公钥。'alipay_public_key' => "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAn8URxKc9wXVSfICqlTm+bLYLzZxbaaLEZDSlmzjrIGwusoS9wazmuIRBKLW1f77PnumnNlxFVo4boh9755szlZMOfbJt2dxMRJQj+Vs19gVbxnq7C9mpseT/ywbIf71bN7HdEk3GHgd2bYc180P5Ug/7W7pX43GAwCRgX83kkKRVVv0b35aLWXgRfTwBErY+PvnfpeN0hbGC0M9UITdEO6cy+rcX7oNI1No9/te617nlP1EdDWMxw7zpFe5M88yF2gbIudmHZ/INUFFpaMnXCsHNW+XT6+ztbGjeMR5qHS8yJ5EclpK8uRiRf2t9ny9bJYqz0+u/OyYMtz0ezEwVdQIDAQAB",);
如果觉得《支付宝沙箱环境测试(给初学者参考)》对你有帮助,请点赞、收藏,并留下你的观点哦!