Hi,
It sure can be done.
Note that as per
developer.paypal.com/ppdevdocs/docs/busi...es/credit-messaging/
you also need the line:
<script src="https://www.paypal.com/sdk/js?client-id=YOUR-CLIENT-ID&components=messages"></script>
where you replace YOUR-CLIENT-ID by the client ID provided to you by PayPal.
Then, where to put it depends a bit on the situation.
You could place the code on the product page, so that instead of adding the product to the cart, the customer could click on that button to directly be redirected to PayPal for the payment of that one product. In that case, you could edit product / show_default.php and and the amount would be available with:
<?php echo round($this->element->prices[0]->price_value_with_tax, 2); ?>
Or you could edit checkout / show_block_cart.php to add the code on the cart view of the checkout. There, you could add such code:
<?php echo round($cart->full_total->prices[0]->price_value_with_tax, 2); ?>[/code]
Note that you can't put your code before the line:
$cart = $this->checkoutHelper->getCart();
since that line initializes $cart which you need for the amount.