title: Spring boot paypal INVALID_RESOURCE_ID
body: <p>I'm trying to implement PayPal's API, but as this is the first time im using it, I get some errors.</p>
  <p>This is the code:</p>
  <p><strong>Controller</strong></p>
  <pre><code>   @PostMapping(&quot;/checkout/paypal&quot;)
      public String checkout_paypal(@RequestParam(value = &quot;id&quot;) Integer id) throws Exception {
          Order order = orderServices.findOrderById(id);
          try {
              Payment payment = service.createPayment(order.getTotalPrice().doubleValue(), &quot;EUR&quot;, &quot;PAYPAL&quot;,
                      &quot;ORDER&quot;, &quot;Order id:&quot;+order.getId(), &quot;http://localhost:4200/checkout?id=&quot;+order.getId(),
                      &quot;http://localhost:4200/checkout?id=&quot;+order.getId());
              for(Links link:payment.getLinks()) {
                  if(link.getRel().equals(&quot;approval_url&quot;)) {
                      return &quot;redirect:&quot;+link.getHref();
                  }
              }
  
          } catch (PayPalRESTException e) {
  
              e.printStackTrace();
          }
          System.out.println(&quot;Success&quot;);
          return &quot;Success&quot;;
      }
  
      @GetMapping(&quot;/successPaymentPaypal&quot;)
      public String successPayment(@RequestParam(value = &quot;id&quot;) Integer id,@RequestParam(value = &quot;paymentId&quot;) String paymentId,@RequestParam(value = &quot;PayerID&quot;) String PayerID) throws Exception {
          System.out.println(id+&quot; &quot;+paymentId+&quot; &quot;+PayerID);
          try {
              Payment payment = service.executePayment(paymentId, PayerID);
              if(payment.getState().equals(&quot;approved&quot;)){
                  Order order = orderServices.findOrderById(id);
                  order.setOrderState(OrderState.PAID);
                  orderServices.saveOrder(order);
                  return &quot;success&quot;;
              }
          } catch (PayPalRESTException e) {
              throw new Exception(&quot;Error occured while processing payment!&quot;);
          }
          return &quot;Done&quot;;
      }
  </code></pre>
  <p><strong>Service</strong></p>
  <pre><code>  @Autowired
      private APIContext apiContext;
  
      public Payment createPayment(
              Double total,
              String currency,
              String method,
              String intent,
              String description,
              String cancelUrl,
              String successUrl) throws PayPalRESTException {
          Amount amount = new Amount();
          amount.setCurrency(currency);
          total = new BigDecimal(total).setScale(2, RoundingMode.HALF_UP).doubleValue();
          amount.setTotal(String.format(&quot;%.2f&quot;, total));
  
          Transaction transaction = new Transaction();
          transaction.setDescription(description);
          transaction.setAmount(amount);
  
          List&lt;Transaction&gt; transactions = new ArrayList&lt;&gt;();
          transactions.add(transaction);
  
          Payer payer = new Payer();
          payer.setPaymentMethod(method.toString());
  
          Payment payment = new Payment();
          payment.setIntent(intent.toString());
          payment.setPayer(payer);
          payment.setTransactions(transactions);
          RedirectUrls redirectUrls = new RedirectUrls();
          redirectUrls.setCancelUrl(cancelUrl);
          redirectUrls.setReturnUrl(successUrl);
          payment.setRedirectUrls(redirectUrls);
  
          return payment.create(apiContext);
      }
  
      public Payment executePayment(String paymentId, String payerId) throws PayPalRESTException{
          Payment payment = new Payment();
          payment.setId(paymentId);
          PaymentExecution paymentExecute = new PaymentExecution();
          paymentExecute.setPayerId(payerId);
          return payment.execute(apiContext, paymentExecute);
      }
  </code></pre>
  <p><strong>Config</strong></p>
  <pre><code>@Value(&quot;${paypal.client.id}&quot;)
  private String clientId;
  @Value(&quot;${paypal.mode}&quot;)
  private String paypalMode;
  @Value(&quot;${paypal.client.secret}&quot;)
  private String clientSecret;
  
  @Bean
  public Map&lt;String, String&gt; paypalSdkConfig(){
      Map&lt;String, String&gt; sdkConfig = new HashMap&lt;&gt;();
      sdkConfig.put(&quot;mode&quot;, paypalMode);
      return sdkConfig;
  }
  
  @Bean
  public OAuthTokenCredential authTokenCredential(){
      return new OAuthTokenCredential(clientId, clientSecret, paypalSdkConfig());
  }
  
  @Bean
  public APIContext apiContext() throws PayPalRESTException{
      APIContext apiContext = new APIContext(authTokenCredential().getAccessToken());
      apiContext.setConfigurationMap(paypalSdkConfig());
      return apiContext;
  }
  </code></pre>
  <p>This is the error:</p>
  <blockquote>
  <p>Response code: 404    Error response: {&quot;name&quot;:&quot;INVALID_RESOURCE_ID&quot;,&quot;message&quot;:&quot;Requested resource ID was not found.&quot;,&quot;information_link&quot;:&quot;https://developer.paypal.com/docs/api/payments/#errors&quot;,&quot;debug_id&quot;:&quot;c2dc1e86af7fe&quot;}</p>
  </blockquote>
  <p>The checkout/paypal dont give any error, and works well i think, it got me redirect to my frontend, where i make second request, but there is when error comes..
  I really dont know what is the problem..</p>