提交 e00c1ddd authored 作者: 吴德鹏's avatar 吴德鹏

paypal token

上级 43c33a49
......@@ -172,19 +172,8 @@ public class PaypalContoller extends Controller {
public APIContext getToken() throws IOException {
//获取paypal的最新token
Optional<Token> tokenOptional = tokenRepository.findFirstToken();
Optional<String> token = Optional.empty();
//第一次执行时,token表都为空
if (tokenOptional.isPresent()) {
token = Optional.ofNullable(tokenOptional.get().getToken());
}
if (!token.isPresent()) {
String oldToken = oldApiContext.getAccessToken();
String token1 = PayPalUtil.getToken(oldToken,mode);
token = Optional.ofNullable(token1);
}
APIContext apiContext = new APIContext(token.get());
String token = PayPalUtil.getToken(tokenOptional.get().getToken(), mode);
APIContext apiContext = new APIContext(token);
Map<String, String> sdkConfig = new HashMap<>();
sdkConfig.put("mode", mode);
apiContext.setConfigurationMap(sdkConfig);
......
//package com.example.afrishop_v3;
//
//import com.example.afrishop_v3.models.JsonTag;
//import com.example.afrishop_v3.models.TbCfOrder;
//import com.example.afrishop_v3.repository.TbCfOrderRepository;
//import com.google.gson.JsonObject;
//import net.sf.json.JSONObject;
//import org.junit.jupiter.api.Test;
//import org.junit.runner.Result;
//import org.junit.runner.RunWith;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.boot.test.context.SpringBootTest;
//import org.springframework.http.ResponseEntity;
//import org.springframework.test.context.junit4.SpringRunner;
//import org.springframework.web.client.RestTemplate;
//
//import java.text.SimpleDateFormat;
//import java.time.LocalDateTime;
//import java.util.Date;
//import java.util.HashMap;
//import java.util.Map;
//import java.util.Optional;
//
//@RunWith(SpringRunner.class)
//@SpringBootTest
//public class AfrishopV3ApplicationTests {
//
// RestTemplate restTemplate = new RestTemplate();
//
// @Test
// void contextLoads() {
// SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
// String now = format.format(new Date());
// System.out.println(now);
// }
//
// private String url = "http://localhost:8099/afrishop/discover/bonus/saveNetworkMarketing";
// @Autowired
// private TbCfOrderRepository orderRepository;
//
//// post35789572fbf643cdab55901d1dc511a6
//// userInfo00297bf300ed45e092a5182dececad21
//// productSharervv32GmG4q
//// amount0.9
//// orderId008272b1fb994aef9b199449f46d5aa5
//
// @Test
// public void test1() {
//
// Optional<TbCfOrder> byId = orderRepository.findById("12a9d7d1042348278c97980a00fc67c4");
// JSONObject json=new JSONObject();
// json.put("userInfo", "32dcda5a709c4265a6f01686ae9b1c1c");
// json.put("amount", byId.get().getItemsPrice());
// json.put("orderId","12a9d7d1042348278c97980a00fc67c4");
// System.out.println(json);
// ResponseEntity<Result> resultResponseEntity = restTemplate.postForEntity(url, json, Result.class);
// System.err.println(resultResponseEntity);
// }
//
//}
package com.example.afrishop_v3;
import com.example.afrishop_v3.models.JsonTag;
import com.example.afrishop_v3.models.TbCfOrder;
import com.example.afrishop_v3.models.Token;
import com.example.afrishop_v3.repository.TbCfOrderRepository;
import com.example.afrishop_v3.repository.TokenRepository;
import com.google.gson.JsonObject;
import net.sf.json.JSONObject;
import org.junit.jupiter.api.Test;
import org.junit.runner.Result;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.web.client.RestTemplate;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
@RunWith(SpringRunner.class)
@SpringBootTest
public class AfrishopV3ApplicationTests {
RestTemplate restTemplate = new RestTemplate();
@Test
void contextLoads() {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
String now = format.format(new Date());
System.out.println(now);
}
private String url = "http://localhost:8099/afrishop/discover/bonus/saveNetworkMarketing";
@Autowired
private TbCfOrderRepository orderRepository;
// post35789572fbf643cdab55901d1dc511a6
// userInfo00297bf300ed45e092a5182dececad21
// productSharervv32GmG4q
// amount0.9
// orderId008272b1fb994aef9b199449f46d5aa5
@Test
public void test1() {
Optional<TbCfOrder> byId = orderRepository.findById("12a9d7d1042348278c97980a00fc67c4");
JSONObject json=new JSONObject();
json.put("userInfo", "32dcda5a709c4265a6f01686ae9b1c1c");
json.put("amount", byId.get().getItemsPrice());
json.put("orderId","12a9d7d1042348278c97980a00fc67c4");
System.out.println(json);
ResponseEntity<Result> resultResponseEntity = restTemplate.postForEntity(url, json, Result.class);
System.err.println(resultResponseEntity);
}
@Autowired
private TokenRepository tokenRepository;
@Test
public void test2(){
Optional<Token> firstToken = tokenRepository.findFirstToken();
if (firstToken.isPresent()){
System.out.println(firstToken.get().getToken());
}
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论