/**
  * Generates a Payment message based on the information in the PaymentRequest. Provide
  * transactions built by the wallet. If the PaymentRequest did not specify a payment_url, returns
  * null.
  *
  * @param txns list of transactions to be included with the Payment message.
  * @param refundAddr will be used by the merchant to send money back if there was a problem.
  * @param memo is a message to include in the payment message sent to the merchant.
  */
 @Nullable
 public Protos.Payment getPayment(
     List<Transaction> txns, @Nullable Address refundAddr, @Nullable String memo)
     throws IOException, PaymentProtocolException.InvalidNetwork {
   if (paymentDetails.hasPaymentUrl()) {
     for (Transaction tx : txns)
       if (!tx.getParams().equals(params))
         throw new PaymentProtocolException.InvalidNetwork(params.getPaymentProtocolId());
     return PaymentProtocol.createPaymentMessage(
         txns, totalValue, refundAddr, memo, getMerchantData());
   } else {
     return null;
   }
 }
 /**
  * Creates a PaymentSession from the provided {@link Protos.PaymentRequest}. If verifyPki is true,
  * also validates the signature and throws an exception if it fails. If trustStoreLoader is null,
  * the system default trust store is used.
  */
 public PaymentSession(
     Protos.PaymentRequest request,
     boolean verifyPki,
     @Nullable final TrustStoreLoader trustStoreLoader)
     throws PaymentProtocolException {
   TrustStoreLoader nonNullTrustStoreLoader =
       trustStoreLoader != null
           ? trustStoreLoader
           : new TrustStoreLoader.DefaultTrustStoreLoader();
   parsePaymentRequest(request);
   if (verifyPki) {
     try {
       pkiVerificationData =
           PaymentProtocol.verifyPaymentRequestPki(request, nonNullTrustStoreLoader.getKeyStore());
     } catch (IOException x) {
       throw new PaymentProtocolException(x);
     } catch (KeyStoreException x) {
       throw new PaymentProtocolException(x);
     }
   } else {
     pkiVerificationData = null;
   }
 }