[英]problem in redirection to a url using rest api
I am trying to redirect to a external link using a rest api , but the desired link is not displayed and i got this the console : 我正在尝试使用rest api重定向到外部链接,但未显示所需的链接,而我在控制台中得到了此信息:
i'm using angular 4 / spring boot 2 ** when I send the request with postman it return the code html of the link :
我正在使用angular 4 / spring boot 2 **当我用邮递员发送请求时,它返回链接的代码html:
my spring code : 我的春季代码:
@GetMapping("/create")
static public RedirectView createPayment(HttpServletRequest req, HttpServletResponse res)
throws Exception {
TransactionRequest request = new TransactionRequest();
request.setOrderId("1242").setCurrency("MAD").setAmount(1500);
request.setShippingType(ShippingType.VIRTUAL);
request.setPaymentMode(PaymentMode.SINGLE);
request.setPaymentType(PaymentType.CREDIT_CARD);
request.setCtrlRedirectURL("http://capmission.ma");
request.setCustomerIP("105.159.248.185");
try {
request.validate();
} catch (BadRequestException e) {
throw new Exception("Ooops, an error occurred validating the payment request: " + e.getMessage());
}
Connect2payClient c2p = new Connect2payClient("https://paiement.payzone.ma", "104747", "vbK7@pQ3G@W9X2k2");
TransactionResponse response = null;
try {
response = c2p.prepareTransaction(request);
} catch (Exception e) {
throw new Exception("Ooops, an error occurred preparing the payment: " + e.getMessage());
}
if (response != null && ResultCode.SUCCESS.equals(response.getCode())) {
response.setCustomerToken(response.getCustomerToken());
String redirectURL = response.getCustomerRedirectURL();
System.out.println(redirectURL);
if (redirectURL != null) {
return new RedirectView("https://www.google.com");
}
} else {
System.out.println(response.getCode());
}
return null;
}
my angular code : 我的角度代码:
//service :
public testPaiementEnLigne2(){
return
this.http.get(this.baseUrl+"payzone/create").map(data=>data.json());
}
the fonction that do the redirection : 进行重定向的功能:
payer2(){
this.paiementService.testPaiementEnLigne2().subscribe(
data=>{
console.log(data);
},
err=>{
console.log(err);
});
}
You expect JSON but you get HTML: 您期望使用JSON,但获得HTML:
//service :
public testPaiementEnLigne2(){
return
this.http.get(this.baseUrl+"payzone/create").map(data=>data.text());
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.