at Nop.Plugin.Payments.PayPalCommerce.Services.PayPalCommerceServiceManager.<>c__DisplayClass44_0.<<PrepareOrderItemsAsync>b__0>d.MoveNext() in D:\Mine\Fitawy\Solution\src\Plugins\Nop.Plugin.Payments.PayPalCommerce\Services\PayPalCommerceServiceManager.cs:line 394
--- End of stack trace from previous location ---
at System.Linq.AsyncEnumerable.SelectEnumerableAsyncIteratorWithTask`2.MoveNextCore()
at System.Linq.AsyncIteratorBase`1.MoveNextAsync() in /_/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs:line 70
at System.Linq.AsyncIteratorBase`1.MoveNextAsync() in /_/Ix.NET/Source/System.Linq.Async/System/Linq/AsyncIterator.cs:line 75
at System.Linq.AsyncEnumerable.<ToListAsync>g__Core|424_0[TSource](IAsyncEnumerable`1 source, CancellationToken cancellationToken) in /_/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs:line 36
at System.Linq.AsyncEnumerable.<ToListAsync>g__Core|424_0[TSource](IAsyncEnumerable`1 source, CancellationToken cancellationToken) in /_/Ix.NET/Source/System.Linq.Async/System/Linq/Operators/ToList.cs:line 36
at Nop.Plugin.Payments.PayPalCommerce.Services.PayPalCommerceServiceManager.PrepareOrderItemsAsync(CartDetails details) in D:\Mine\Fitawy\Solution\src\Plugins\Nop.Plugin.Payments.PayPalCommerce\Services\PayPalCommerceServiceManager.cs:line 385
at Nop.Plugin.Payments.PayPalCommerce.Services.PayPalCommerceServiceManager.<>c__DisplayClass66_0.<<CreateOrderAsync>b__0>d.MoveNext() in D:\Mine\Fitawy\Solution\src\Plugins\Nop.Plugin.Payments.PayPalCommerce\Services\PayPalCommerceServiceManager.cs:line 1522
--- End of stack trace from previous location ---
at Nop.Plugin.Payments.PayPalCommerce.Services.PayPalCommerceServiceManager.HandleFunctionAsync[TResult](Func`1 function, Boolean logErrors) in D:\Mine\Fitawy\Solution\src\Plugins\Nop.Plugin.Payments.PayPalCommerce\Services\PayPalCommerceServiceManager.cs:line 200
This error because the null picture.. Is picture required ?
private async Task<List<Item>> PrepareOrderItemsAsync(CartDetails details)
{
//cart items
var items = await details.Cart.SelectAwait(async item =>
{
var product = await _productService.GetProductByIdAsync(item.ProductId);
var sku = await _productService.FormatSkuAsync(product, item.AttributesXml);
var seName = await _urlRecordService.GetSeNameAsync(product);
var url = await _nopUrlHelper.RouteGenericUrlAsync<Product>(new { SeName = seName }, _webHelper.GetCurrentRequestProtocol());
var picture = await _pictureService.GetProductPictureAsync(product, item.AttributesXml);
//PayPal doesn't currently support WebP images
var ext = await _pictureService.GetFileExtensionFromMimeTypeAsync(picture.MimeType);
var (imageUrl, _) = ext != "webp" ? await _pictureService.GetPictureUrlAsync(picture) : default;
var (itemSubTotal, itemDiscount, _, _) = await _shoppingCartService.GetSubTotalAsync(item, true);
var unitPrice = itemSubTotal / item.Quantity;
var (unitPriceExclTax, _) = await _taxService.GetProductPriceAsync(product, unitPrice, false, details.Customer);
return new Item
{
Name = CommonHelper.EnsureMaximumLength(product.Name, 127),
Description = CommonHelper.EnsureMaximumLength(product.ShortDescription, 127),
Sku = CommonHelper.EnsureMaximumLength(sku, 127),
Quantity = item.Quantity.ToString(),
Category = product.IsDownload
? CategoryType.DIGITAL_GOODS.ToString().ToUpper()
: CategoryType.PHYSICAL_GOODS.ToString().ToUpper(),
Url = url,
ImageUrl = imageUrl,
UnitAmount = PrepareMoney(unitPriceExclTax, details.CurrencyCode)
};
}).ToListAsync();
//and checkout attributes
var checkoutAttributes = await _genericAttributeService
.GetAttributeAsync<string>(details.Customer, NopCustomerDefaults.CheckoutAttributes, details.Store.Id);
var checkoutAttributeValues = _checkoutAttributeParser.ParseAttributeValues(checkoutAttributes);
await foreach (var (attribute, values) in checkoutAttributeValues)
{
await foreach (var attributeValue in values)
{
var (attributePriceExclTax, _) = await _taxService.GetCheckoutAttributePriceAsync(attribute, attributeValue, false, details.Customer);
items.Add(new()
{
Name = CommonHelper.EnsureMaximumLength(attribute.Name, 127),
Description = CommonHelper.EnsureMaximumLength($"{attribute.Name} - {attributeValue.Name}", 127),
Quantity = 1.ToString(),
UnitAmount = PrepareMoney(attributePriceExclTax, details.CurrencyCode)
});
}
}
return items;
}