@Override public Ack call() throws Exception { HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("POST"); connection.setRequestProperty("Content-Type", "application/bitcoin-payment"); connection.setRequestProperty("Accept", "application/bitcoin-paymentack"); connection.setRequestProperty("Content-Length", Integer.toString(payment.getSerializedSize())); connection.setUseCaches(false); connection.setDoInput(true); connection.setDoOutput(true); // Send request. DataOutputStream outStream = new DataOutputStream(connection.getOutputStream()); payment.writeTo(outStream); outStream.flush(); outStream.close(); // Get response. InputStream inStream = connection.getInputStream(); Protos.PaymentACK.Builder paymentAckBuilder = Protos.PaymentACK.newBuilder().mergeFrom(inStream); Protos.PaymentACK paymentAck = paymentAckBuilder.build(); String memo = null; if (paymentAck.hasMemo()) memo = paymentAck.getMemo(); return new Ack(memo); } });
@Override public void initialiseContent(JPanel contentPanel) { paymentSentOKSummary = Labels.newStatusLabel(Optional.<MessageKey>absent(), null, Optional.<Boolean>absent()); AccessibilityDecorator.apply(paymentSentOKSummary, CoreMessageKey.PAYMENT_SENDING_TO_REQUESTER); // BIP70 PaymentACK memo paymentACKMemo = TextBoxes.newReadOnlyTextArea(6, MultiBitUI.PASSWORD_LENGTH); // Apply any Payment Request parameters if (getWizardModel().getPaymentRequestData().isPresent()) { PaymentRequestData paymentRequestData = getWizardModel().getPaymentRequestData().get(); // Fill in the paymentACK memo if (paymentRequestData.getPaymentACK().isPresent()) { paymentACKMemo.setText(paymentRequestData.getPaymentACK().get().getMemo()); } } paymentACKMemoLabel = Labels.newBlankLabel(); paymentACKMemoLabel.setText(Languages.safeText(MessageKey.SEND_PAYMENT_ACK_MEMO_LABEL)); AccessibilityDecorator.apply(paymentACKMemoLabel, MessageKey.SEND_PAYMENT_ACK_MEMO_TITLE); contentPanel.setLayout( new MigLayout( Panels.migXYLayout(), "[]", // Column constraints "[]40[]2[]" // Row constraints )); contentPanel.add(paymentSentOKSummary, "wrap"); contentPanel.add(paymentACKMemoLabel, "wrap"); contentPanel.add(paymentACKMemo, "growx,push,wrap"); }
paymentACKMemo.setText(paymentRequestData.getPaymentACK().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"); } }
/** * <code>optional string memo = 2;</code> * * <pre> * human-readable message for customer * </pre> */ public Builder clearMemo() { bitField0_ = (bitField0_ & ~0x00000002); memo_ = getDefaultInstance().getMemo(); onChanged(); return this; } /**
/** * <code>optional string memo = 2;</code> * * <pre> * human-readable message for customer * </pre> */ public Builder clearMemo() { bitField0_ = (bitField0_ & ~0x00000002); memo_ = getDefaultInstance().getMemo(); onChanged(); return this; } /**
/** * <code>optional string memo = 2;</code> * * <pre> * human-readable message for customer * </pre> */ public Builder clearMemo() { bitField0_ = (bitField0_ & ~0x00000002); memo_ = getDefaultInstance().getMemo(); onChanged(); return this; } /**
/** * <code>optional string memo = 2;</code> * * <pre> * human-readable message for customer * </pre> */ public Builder clearMemo() { bitField0_ = (bitField0_ & ~0x00000002); memo_ = getDefaultInstance().getMemo(); onChanged(); return this; } /**
/** * <code>optional string memo = 2;</code> * * <pre> * human-readable message for customer * </pre> */ public Builder clearMemo() { bitField0_ = (bitField0_ & ~0x00000002); memo_ = getDefaultInstance().getMemo(); onChanged(); return this; } /**
/** * Parse payment ack into an object. */ public static Ack parsePaymentAck(Protos.PaymentACK paymentAck) { final String memo = paymentAck.hasMemo() ? paymentAck.getMemo() : null; return new Ack(memo); }
/** * Parse payment ack into an object. */ public static Ack parsePaymentAck(Protos.PaymentACK paymentAck) { final String memo = paymentAck.hasMemo() ? paymentAck.getMemo() : null; return new Ack(memo); }
/** * Parse payment ack into an object. */ public static Ack parsePaymentAck(Protos.PaymentACK paymentAck) { final String memo = paymentAck.hasMemo() ? paymentAck.getMemo() : null; return new Ack(memo); }
/** * Parse payment ack into an object. */ public static Ack parsePaymentAck(Protos.PaymentACK paymentAck) { final String memo = paymentAck.hasMemo() ? paymentAck.getMemo() : null; return new Ack(memo); }
@Test public void testPaymentAck() throws Exception { // Create Payment paymentMessage = Protos.Payment.newBuilder().build(); PaymentACK paymentAck = PaymentProtocol.createPaymentAck(paymentMessage, MEMO); byte[] paymentAckBytes = paymentAck.toByteArray(); // Parse PaymentACK parsedPaymentAck = PaymentACK.parseFrom(paymentAckBytes); assertEquals(paymentMessage, parsedPaymentAck.getPayment()); assertEquals(MEMO, parsedPaymentAck.getMemo()); } }
/** * Parse payment ack into an object. */ public static Ack parsePaymentAck(Protos.PaymentACK paymentAck) { final String memo = paymentAck.hasMemo() ? paymentAck.getMemo() : null; return new Ack(memo); }