@Override public void initialiseContent(JPanel contentPanel) { // BIP70 Payment memo paymentMemo = TextBoxes.newEnterNotes(getWizardModel()); // Apply any Payment Request parameters if (getWizardModel().getPaymentRequestData().isPresent()) { PaymentRequestData paymentRequestData = getWizardModel().getPaymentRequestData().get(); // Fill in the payment memo if (paymentRequestData.getPayment().isPresent()) { paymentMemo.setText(paymentRequestData.getPayment().get().getMemo()); } } paymentMemoLabel = Labels.newBlankLabel(); AccessibilityDecorator.apply(paymentMemoLabel, MessageKey.SEND_PAYMENT_MEMO_TITLE); paymentMemoLabel.setText(Languages.safeText(MessageKey.SEND_PAYMENT_MEMO_LABEL)); contentPanel.setLayout( new MigLayout( Panels.migXYLayout(), "[]", // Column constraints "[]10[]" // Row constraints )); contentPanel.add(paymentMemoLabel, "wrap"); contentPanel.add(paymentMemo, "growx,push,wrap"); }
paymentMemo.setText(paymentRequestData.getPayment().get().getMemo());
@Override public void onSuccess(PaymentProtocol.Ack result) { // Have successfully received a PaymentAck from the merchant log.info("Received PaymentAck from merchant. Memo: {}", result.getMemo()); getSendBitcoinShowPaymentACKMemoPanelModel().setPaymentACKMemo(result.getMemo()); PaymentProtocolService paymentProtocolService = CoreServices.getPaymentProtocolService(); if (finalPayment != null) { Optional<Protos.PaymentACK> paymentACK = paymentProtocolService.newPaymentACK(finalPayment, result.getMemo()); finalPaymentRequestData.setPayment(Optional.of(finalPayment)); finalPaymentRequestData.setPaymentACK(paymentACK); log.debug("Saving PaymentMemo of {} and PaymentACKMemo of {}", finalPayment.getMemo(), paymentACK.isPresent() ? paymentACK.get().getMemo() : "n/a"); WalletService walletService = CoreServices.getOrCreateWalletService(WalletManager.INSTANCE.getCurrentWalletSummary().get().getWalletId()); walletService.addPaymentRequestData(finalPaymentRequestData); // Write payments CharSequence password = WalletManager.INSTANCE.getCurrentWalletSummary().get().getWalletPassword().getPassword(); if (password != null) { walletService.writePayments(password); } CoreEvents.firePaymentSentToRequestorEvent(new PaymentSentToRequestorEvent(true, CoreMessageKey.PAYMENT_SENT_TO_REQUESTER_OK, null)); } else { log.error("No payment and hence cannot save payment or paymentACK"); } }
@Test public void testSimplePayment() throws Exception { // Create a PaymentRequest and make sure the correct values are parsed by the PaymentSession. MockPaymentSession paymentSession = new MockPaymentSession(newSimplePaymentRequest("test")); assertEquals(paymentRequestMemo, paymentSession.getMemo()); assertEquals(coin, paymentSession.getValue()); assertEquals(simplePaymentUrl, paymentSession.getPaymentUrl()); assertTrue(new Date(time * 1000L).equals(paymentSession.getDate())); assertTrue(paymentSession.getSendRequest().tx.equals(tx)); assertFalse(paymentSession.isExpired()); // Send the payment and verify that the correct information is sent. // Add a dummy input to tx so it is considered valid. tx.addInput(new TransactionInput(PARAMS, tx, outputToMe.getScriptBytes())); ArrayList<Transaction> txns = new ArrayList<>(); txns.add(tx); Address refundAddr = new Address(PARAMS, serverKey.getPubKeyHash()); paymentSession.sendPayment(txns, refundAddr, paymentMemo); assertEquals(1, paymentSession.getPaymentLog().size()); assertEquals(simplePaymentUrl, paymentSession.getPaymentLog().get(0).getUrl().toString()); Protos.Payment payment = paymentSession.getPaymentLog().get(0).getPayment(); assertEquals(paymentMemo, payment.getMemo()); assertEquals(merchantData, payment.getMerchantData()); assertEquals(1, payment.getRefundToCount()); assertEquals(coin.value, payment.getRefundTo(0).getAmount()); TransactionOutput refundOutput = new TransactionOutput(PARAMS, null, coin, refundAddr); ByteString refundScript = ByteString.copyFrom(refundOutput.getScriptBytes()); assertTrue(refundScript.equals(payment.getRefundTo(0).getScript())); }
@Test public void testPaymentMessage() throws Exception { // Create List<Transaction> transactions = new LinkedList<>(); transactions.add(FakeTxBuilder.createFakeTx(NETWORK_PARAMS, AMOUNT, TO_ADDRESS)); Coin refundAmount = Coin.SATOSHI; Address refundAddress = new ECKey().toAddress(NETWORK_PARAMS); Payment payment = PaymentProtocol.createPaymentMessage(transactions, refundAmount, refundAddress, MEMO, MERCHANT_DATA); byte[] paymentBytes = payment.toByteArray(); // Parse Payment parsedPayment = Payment.parseFrom(paymentBytes); List<Transaction> parsedTransactions = PaymentProtocol.parseTransactionsFromPaymentMessage(NETWORK_PARAMS, parsedPayment); assertEquals(transactions, parsedTransactions); assertEquals(1, parsedPayment.getRefundToCount()); assertEquals(MEMO, parsedPayment.getMemo()); assertArrayEquals(MERCHANT_DATA, parsedPayment.getMerchantData().toByteArray()); }
/** * <code>optional string memo = 4;</code> * * <pre> * Human-readable message for the merchant * </pre> */ public Builder clearMemo() { bitField0_ = (bitField0_ & ~0x00000008); memo_ = getDefaultInstance().getMemo(); onChanged(); return this; } /**
/** * <code>optional string memo = 4;</code> * * <pre> * Human-readable message for the merchant * </pre> */ public Builder clearMemo() { bitField0_ = (bitField0_ & ~0x00000008); memo_ = getDefaultInstance().getMemo(); onChanged(); return this; } /**
/** * <code>optional string memo = 4;</code> * * <pre> * Human-readable message for the merchant * </pre> */ public Builder clearMemo() { bitField0_ = (bitField0_ & ~0x00000008); memo_ = getDefaultInstance().getMemo(); onChanged(); return this; } /**
/** * <code>optional string memo = 4;</code> * * <pre> * Human-readable message for the merchant * </pre> */ public Builder clearMemo() { bitField0_ = (bitField0_ & ~0x00000008); memo_ = getDefaultInstance().getMemo(); onChanged(); return this; } /**
/** * <code>optional string memo = 4;</code> * * <pre> * Human-readable message for the merchant * </pre> */ public Builder clearMemo() { bitField0_ = (bitField0_ & ~0x00000008); memo_ = getDefaultInstance().getMemo(); onChanged(); return this; } /**