public Builder mergeFrom(org.bitcoin.protocols.payments.Protos.Payment other) { if (other == org.bitcoin.protocols.payments.Protos.Payment.getDefaultInstance()) return this; if (other.hasMerchantData()) { setMerchantData(other.getMerchantData());
public Builder mergeFrom(org.bitcoin.protocols.payments.Protos.Payment other) { if (other == org.bitcoin.protocols.payments.Protos.Payment.getDefaultInstance()) return this; if (other.hasMerchantData()) { setMerchantData(other.getMerchantData());
public Builder mergeFrom(org.bitcoin.protocols.payments.Protos.Payment other) { if (other == org.bitcoin.protocols.payments.Protos.Payment.getDefaultInstance()) return this; if (other.hasMerchantData()) { setMerchantData(other.getMerchantData());
public Builder mergeFrom(org.bitcoin.protocols.payments.Protos.Payment other) { if (other == org.bitcoin.protocols.payments.Protos.Payment.getDefaultInstance()) return this; if (other.hasMerchantData()) { setMerchantData(other.getMerchantData());
public Builder mergeFrom(org.bitcoin.protocols.payments.Protos.Payment other) { if (other == org.bitcoin.protocols.payments.Protos.Payment.getDefaultInstance()) return this; if (other.hasMerchantData()) { setMerchantData(other.getMerchantData());
@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 bytes merchant_data = 1;</code> * * <pre> * From PaymentDetails.merchant_data * </pre> */ public Builder clearMerchantData() { bitField0_ = (bitField0_ & ~0x00000001); merchantData_ = getDefaultInstance().getMerchantData(); onChanged(); return this; }
/** * <code>optional bytes merchant_data = 1;</code> * * <pre> * From PaymentDetails.merchant_data * </pre> */ public Builder clearMerchantData() { bitField0_ = (bitField0_ & ~0x00000001); merchantData_ = getDefaultInstance().getMerchantData(); onChanged(); return this; }
/** * <code>optional bytes merchant_data = 1;</code> * * <pre> * From PaymentDetails.merchant_data * </pre> */ public Builder clearMerchantData() { bitField0_ = (bitField0_ & ~0x00000001); merchantData_ = getDefaultInstance().getMerchantData(); onChanged(); return this; }
/** * <code>optional bytes merchant_data = 1;</code> * * <pre> * From PaymentDetails.merchant_data * </pre> */ public Builder clearMerchantData() { bitField0_ = (bitField0_ & ~0x00000001); merchantData_ = getDefaultInstance().getMerchantData(); onChanged(); return this; }
/** * <code>optional bytes merchant_data = 1;</code> * * <pre> * From PaymentDetails.merchant_data * </pre> */ public Builder clearMerchantData() { bitField0_ = (bitField0_ & ~0x00000001); merchantData_ = getDefaultInstance().getMerchantData(); onChanged(); return this; }