@@ -45,7 +45,7 @@ public class PayPalService : IPayPalService
4545 private readonly IPaymentService _paymentService ;
4646 private readonly IPriceCalculationService _priceCalculationService ;
4747 private readonly ITaxService _taxService ;
48- private readonly Lazy < ICurrencyService > _currencyService ;
48+ private readonly ICurrencyService _currencyService ;
4949 private readonly Lazy < IPictureService > _pictureService ;
5050 private readonly Lazy < CompanyInformationSettings > _companyInfoSettings ;
5151
@@ -59,7 +59,7 @@ public PayPalService(
5959 IPaymentService paymentService ,
6060 IPriceCalculationService priceCalculationService ,
6161 ITaxService taxService ,
62- Lazy < ICurrencyService > currencyService ,
62+ ICurrencyService currencyService ,
6363 Lazy < IPictureService > pictureService ,
6464 Lazy < CompanyInformationSettings > companyInfoSettings )
6565 {
@@ -126,6 +126,7 @@ private Dictionary<string, object> CreateAmount(
126126 var amount = new Dictionary < string , object > ( ) ;
127127 var amountDetails = new Dictionary < string , object > ( ) ;
128128 var language = _services . WorkContext . WorkingLanguage ;
129+ var currency = _services . WorkContext . WorkingCurrency ;
129130 var currencyCode = store . PrimaryStoreCurrency . CurrencyCode ;
130131 var includingTax = ( _services . WorkContext . GetTaxDisplayTypeFor ( customer , store . Id ) == TaxDisplayType . IncludingTax ) ;
131132
@@ -138,7 +139,9 @@ private Dictionary<string, object> CreateAmount(
138139
139140 var shipping = ( _orderTotalCalculationService . GetShoppingCartShippingTotal ( cart ) ?? decimal . Zero ) ;
140141
141- var paymentFee = _paymentService . GetAdditionalHandlingFee ( cart , providerSystemName ) ;
142+ var additionalHandlingFee = _paymentService . GetAdditionalHandlingFee ( cart , providerSystemName ) ;
143+ var paymentFeeBase = _taxService . GetPaymentMethodAdditionalFee ( additionalHandlingFee , customer ) ;
144+ var paymentFee = _currencyService . ConvertFromPrimaryStoreCurrency ( paymentFeeBase , currency ) ;
142145
143146 var total = ( _orderTotalCalculationService . GetShoppingCartTotal ( cart , out orderDiscountInclTax , out orderAppliedDiscount , out appliedGiftCards ,
144147 out redeemedRewardPoints , out redeemedRewardPointsAmount ) ?? decimal . Zero ) ;
@@ -150,7 +153,7 @@ private Dictionary<string, object> CreateAmount(
150153 decimal unitPrice = _priceCalculationService . GetUnitPrice ( item , true ) ;
151154 decimal productPrice = _taxService . GetProductPrice ( item . Item . Product , unitPrice , includingTax , customer , out unitPriceTaxRate ) ;
152155
153- if ( items != null )
156+ if ( items != null && productPrice != decimal . Zero )
154157 {
155158 var line = new Dictionary < string , object > ( ) ;
156159 line . Add ( "quantity" , item . Item . Quantity ) ;
@@ -168,18 +171,19 @@ private Dictionary<string, object> CreateAmount(
168171
169172 if ( total != itemsPlusMisc )
170173 {
171- if ( items != null )
174+ var otherAmount = ( total - itemsPlusMisc ) ;
175+ totalOrderItems += otherAmount ;
176+
177+ if ( items != null && otherAmount != decimal . Zero )
172178 {
173179 // e.g. discount applied to cart total
174180 var line = new Dictionary < string , object > ( ) ;
175181 line . Add ( "quantity" , "1" ) ;
176182 line . Add ( "name" , T ( "Plugins.SmartStore.PayPal.Other" ) . Text . Truncate ( 127 ) ) ;
177- line . Add ( "price" , ( total - itemsPlusMisc ) . FormatInvariant ( ) ) ;
183+ line . Add ( "price" , otherAmount . FormatInvariant ( ) ) ;
178184 line . Add ( "currency" , currencyCode ) ;
179185 items . Add ( line ) ;
180186 }
181-
182- totalOrderItems += ( total - itemsPlusMisc ) ;
183187 }
184188
185189 // fill amount object
@@ -417,7 +421,7 @@ public string CreatePaymentInstruction(PayPalPaymentInstruction instruct)
417421
418422 try
419423 {
420- var currency = _currencyService . Value . GetCurrencyByCode ( instruct . AmountCurrencyCode ) ;
424+ var currency = _currencyService . GetCurrencyByCode ( instruct . AmountCurrencyCode ) ;
421425 var format = ( currency != null && currency . CustomFormatting . HasValue ( ) ? currency . CustomFormatting : "C" ) ;
422426
423427 amount = instruct . Amount . ToString ( format , culture ) ;
0 commit comments