We're using a custom module to calculate an amount we need to include in the grand total of the order, i.e. the customer will be charged for the product PLUS this custom amount, but it's getting set as Due Total and Stripe only receives the original value of the product and its shipping without our calculation. Code is as follows:
class CustomAmount extends \Magento\Quote\Model\Quote\Address\Total\AbstractTotal
{
public function collect(
\Magento\Quote\Model\Quote $quote,
\Magento\Quote\Api\Data\ShippingAssignmentInterface $shippingAssignment,
\Magento\Quote\Model\Quote\Address\Total $total
) {
parent::collect($quote, $shippingAssignment, $total);
$amount = 187; // fixed amount as example, but this will change
$total->setTotalAmount('installation', $amount);
$total->setBaseTotalAmount('installation', $amount);
$total->setCustomAmount($amount);
$total->setBaseCustomAmount($amount);
$total->addTotalAmount($this->getCode(), $amount);
$total->addBaseTotalAmount($this->getCode(), $amount);
return $this;
}
}
and we're seeing this on admin panel
We have tried with other functions from
\Magento\Quote\Model\Quote\Address\Total
such as replacing $total->addTotalAmount($this->getCode(), $amount);
with $total->addGrandTotal($total->getGrandTotal() + $amount);
We want to see the custom amount be added to the total that is actually paid through Stripe, currently we only see that as Due Amount
.