title: Paypal Adaptive Payment in Java with spring boot
body: <p>Hello I am implementing adaptive payment in pay-pal with spring boot.
  But i am getting an error when i hit api in postman.
  Error is : com.paypal.exception.MissingCredentialException: No API accounts have been configured in application properties.
  Please help what i am doing wrong.</p>
  
  <h2>Here is Service Class</h2>
  
  <pre><code>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&lt;String, Object&gt; createPayment(Double total, String email) throws SSLConfigurationException, InvalidCredentialException, UnsupportedEncodingException, HttpErrorException, InvalidResponseDataException, ClientActionRequiredException, MissingCredentialException, OAuthException, IOException, InterruptedException{
          Map&lt;String, Object&gt; response = new HashMap&lt;String, Object&gt;();
  
          RequestEnvelope env = new RequestEnvelope();
          env.setErrorLanguage("en_US");
  
          List&lt;Receiver&gt; receiver = new ArrayList&lt;Receiver&gt;();
          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&lt;String, String&gt; customConfigurationMap = new HashMap&lt;String, String&gt;();
          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;
  
  }
  }
  </code></pre>
  
  <h2>Here is Controller</h2>
  
  <pre><code>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&lt;Map&lt;String, Object&gt;&gt; payout(HttpServletRequest req, HttpServletResponse resp) {
          Map&lt;String, Object&gt; response = new HashMap&lt;String, Object&gt;();
          Map&lt;String, Object&gt; data = new HashMap&lt;String, Object&gt;();
          try {
              Map&lt;String, Object&gt; 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&lt;Map&lt;String, Object&gt;&gt;(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&lt;Map&lt;String, Object&gt;&gt;(response, HttpStatus.INTERNAL_SERVER_ERROR);
          }
      }
  }
  </code></pre>