修改PayPal创建订单参数returnUrl
This commit is contained in:
@@ -133,7 +133,7 @@ public class PaypalConfig {
|
||||
}
|
||||
|
||||
//下单
|
||||
public JSONObject createOrder(BuyOrder buyOrder){
|
||||
public JSONObject createOrder(BuyOrder buyOrder,String returnUrl,String cancelUrl){
|
||||
try{
|
||||
URL u = new URL(modeUrl+createOrderURL);
|
||||
HttpURLConnection connection = (HttpURLConnection) u.openConnection();
|
||||
|
||||
@@ -53,7 +53,7 @@ public class PaypalController {
|
||||
if ("point".equals(buyOrder.getOrderType())){
|
||||
buyOrder.setRemark("Recharge Virtual Coin");
|
||||
}
|
||||
JSONObject res = paypalConfig.createOrder(buyOrder);
|
||||
JSONObject res = paypalConfig.createOrder(buyOrder,params.get("returnUrl").toString(),params.get("cancelUrl").toString());
|
||||
if (res.containsKey("links")&&res.containsKey("status")){
|
||||
if ("CREATED".equals(res.get("status").toString())){
|
||||
PayPaypalOrder payPaypalOrder = new PayPaypalOrder();
|
||||
@@ -63,7 +63,16 @@ public class PaypalController {
|
||||
payPaypalOrder.setPaypalOrderId(res.get("id").toString());
|
||||
payPaypalOrder.setDescription(buyOrder.getRemark());
|
||||
payPaypalOrderService.save(payPaypalOrder);
|
||||
return R.ok().put("id",res.get("id").toString());
|
||||
JSONArray array = (JSONArray)res.get("links");
|
||||
String url = "";
|
||||
for (int i = 0; i < array.size(); i++) {
|
||||
JSONObject o = (JSONObject)array.get(i);
|
||||
if ("approve".equals(o.get("rel"))){
|
||||
url = o.get("href").toString();
|
||||
}
|
||||
}
|
||||
|
||||
return R.ok().put("id",res.get("id").toString()).put("url",url);
|
||||
}
|
||||
}
|
||||
return R.error(res.get("error").toString());
|
||||
|
||||
Reference in New Issue
Block a user