Здравствуйте. Я внедряю адаптивный платеж в Pay-Pal с пружинной загрузкой.
Но я получаю сообщение об ошибке, когда я ударил API в почтальоне.
Ошибка: com.paypal.exception.MissingCredentialException: в свойствах приложения не настроены учетные записи API.
Пожалуйста, помогите, что я делаю неправильно.
Вот класс обслуживания
package com.AdaptivePayment.Service;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Service;
import com.paypal.exception.ClientActionRequiredException;
import com.paypal.exception.HttpErrorException;
import com.paypal.exception.InvalidCredentialException;
import com.paypal.exception.InvalidResponseDataException;
import com.paypal.exception.MissingCredentialException;
import com.paypal.exception.SSLConfigurationException;
import com.paypal.sdk.exceptions.OAuthException;
import com.paypal.svcs.services.AdaptivePaymentsService;
import com.paypal.svcs.types.ap.PayRequest;
import com.paypal.svcs.types.ap.PayResponse;
import com.paypal.svcs.types.ap.Receiver;
import com.paypal.svcs.types.ap.ReceiverList;
import com.paypal.svcs.types.common.RequestEnvelope;
@Service
public class AdaptivePaymentService {
String UserName= " caller_1312486258_biz_api1.gmail.com";
String Password= "1312486294";
String Signature= " AbtI7HV1xB428VygBUcIhARzxch4AL65.T18CTeylixNNxDZUu0iO87e";
public Map<String, Object> createPayment(Double total, String email) throws SSLConfigurationException, InvalidCredentialException, UnsupportedEncodingException, HttpErrorException, InvalidResponseDataException, ClientActionRequiredException, MissingCredentialException, OAuthException, IOException, InterruptedException{
Map<String, Object> response = new HashMap<String, Object>();
RequestEnvelope env = new RequestEnvelope();
env.setErrorLanguage("en_US");
List<Receiver> receiver = new ArrayList<Receiver>();
Receiver rec = new Receiver();
rec.setAmount(total);
rec.setEmail(email);
receiver.add(rec);
ReceiverList receiverlst = new ReceiverList(receiver);
PayRequest payRequest = new PayRequest();
payRequest.setReceiverList(receiverlst);
payRequest.setRequestEnvelope(env);
Map<String, String> customConfigurationMap = new HashMap<String, String>();
customConfigurationMap.put("mode", "sandbox"); // Load the map with all mandatory parameters
AdaptivePaymentsService adaptivePaymentsService = new AdaptivePaymentsService(customConfigurationMap);
PayResponse payResponse = adaptivePaymentsService.pay(payRequest,UserName);
response.put("status", "success");
response.put("payment", payResponse);
return response;
}
}
Вот контроллер
package com.AdaptivePayment.Controller;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.AdaptivePayment.Service.AdaptivePaymentService;
@Controller
public class AdaptivePaymentController {
@Autowired
private AdaptivePaymentService adaptiveService;
@RequestMapping(value = "adaptivePayment", method = RequestMethod.POST)
public ResponseEntity<Map<String, Object>> payout(HttpServletRequest req, HttpServletResponse resp) {
Map<String, Object> response = new HashMap<String, Object>();
Map<String, Object> data = new HashMap<String, Object>();
try {
Map<String, Object> adaptiveResponse = adaptiveService.createPayment(16.00, "admin-facilitator@e-rrands.in");
data.put("Adaptive", adaptiveResponse.get("status"));
response.put("data", data);
response.put("status", "OK");
response.put("code", "200");
response.put("message", "Payout Created successfully.");
return new ResponseEntity<Map<String, Object>>(response, HttpStatus.OK);
} catch (Exception e) {
e.printStackTrace();
response.put("status", "ERROR");
response.put("code", "500");
response.put("message", "Something went wrong");
return new ResponseEntity<Map<String, Object>>(response, HttpStatus.INTERNAL_SERVER_ERROR);
}
}
}