docs: public static void signPaymentRequest(Protos.PaymentRequest.Builder paymentRequest,
                                            X509Certificate[] certificateChain, PrivateKey privateKey) {
          try {
              final Protos.X509Certificates.Builder certificates = Protos.X509Certificates.newBuilder();
              for (final Certificate certificate : certificateChain)
                  certificates.addCertificate(ByteString.copyFrom(certificate.getEncoded()));
  
              paymentRequest.setPkiType("x509+sha256");
              paymentRequest.setPkiData(certificates.build().toByteString());
              paymentRequest.setSignature(ByteString.EMPTY);
              final Protos.PaymentRequest paymentRequestToSign = paymentRequest.build();
  
              final String algorithm;
              if ("RSA".equalsIgnoreCase(privateKey.getAlgorithm()))
                  algorithm = "SHA256withRSA";
              else
                  throw new IllegalStateException(privateKey.getAlgorithm());
  
              final Signature signature = Signature.getInstance(algorithm);
              signature.initSign(privateKey);
              signature.update(paymentRequestToSign.toByteArray());
  
              paymentRequest.setSignature(ByteString.copyFrom(signature.sign()));
          } catch (final GeneralSecurityException x) {
              // Should never happen so don't make users have to think about it.
              throw new RuntimeException(x);
          }
      }