BIP70 How do I send the transaction to the bitcoin network?

I’m going through this guide, implementing BIP70 PaymentProtocol in node. There is a step in the guide that is just a javascript comment, and doesn’t have a code example. I don’t know how to do what the comment says.

The step in the guide is under “Payment”

var body = PaymentProtocol.Payment.decode(rawbody);
var payment = new PaymentProtocol().makePayment(body);
var merchant_data = payment.get(‘merchant_data’);
var transactions = payment.get(‘transactions’);
var refund_to = payment.get(‘refund_to’);
var memo = payment.get(‘memo’);

// send the transaction to the bitcoin network <— How do I do that?

It depends if you implement the server side or the client side of the Payment Protocol. The Payment Protocol itself is “just” supporting the actual bitcoin transaction, to improve user experience and security (man in the middle attack) of wallets…

On the serverside, if you get the Payment message (of the PaymentProtocol) you can extract the transaction and hand it over to the bitcoin p2p protocol. Either you are connected to the p2p network directly and send a TX Message to your peers (e.g. by using bitcore-p2p). Otherwise you can use a web service like e.g. Blockcypher: http://dev.blockcypher.com/#push-raw-transaction-endpoint

Probably, the wallet implementation will send the transaction also to the bitcoin network, besides sending it inside the Payment message. In this case you only would have to listen on the bitcoin network, if the transaction took place.

I assumed, that you wanted to implement the server side.

Yes, I’m doing this server side. Thanks Stefan, that helps a lot!