Payments.PayPalCommerce error: Object reference not set to an instance of an object.

3 ay önce
System.NullReferenceException: Object reference not set to an instance of an object.
   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;
    }
3 ay önce
after add picture to the product I get this error..


Log level: Error
Short message Payments.PayPalCommerce error: Failed request:
Full message: Nop.Core.NopException: Failed request (BadRequest): Request is not well-formed, syntactically incorrect, or violates schema.
{
  "name": "INVALID_REQUEST",
  "message": "Request is not well-formed, syntactically incorrect, or violates schema.",
  "debug_id": "f303881ea32b0",
  "details": [
    {
      "field": "/purchase_units/@reference_id=='default'/items/0/image_url",
      "value": "https://localhost:44358/images/thumbs/0000722_-.jpeg",
      "location": "body",
      "issue": "INVALID_PARAMETER_SYNTAX",
      "description": "The value of a field does not conform to the expected format."
    },
    {
      "field": "/purchase_units/@reference_id=='default'/supplementary_data/card/level3/line_items/0/image_url",
      "value": "https://localhost:44358/images/thumbs/0000722_-.jpeg",
      "location": "body",
      "issue": "INVALID_PARAMETER_SYNTAX",
      "description": "The value of a field does not conform to the expected format."
    }
  ],
  "links": [
    {
      "title": null,
      "href": "https://developer.paypal.com/docs/api/orders/v2/#error-INVALID_PARAMETER_SYNTAX",
      "method": null,
      "rel": "information_link",
      "encType": "application/json",
      "mediaType": null
    }
  ]
}
3 ay önce
What version of nopCommerce ?
What version of the Plugin ?
3 ay önce
nopCommerce version 4.80.4
Plugin version 4.80.14
3 ay önce
khedr wrote:

This error because the null picture.. Is picture required ?


Product pictures are not required. We'll check this, thanks.
3 ay önce
paypal event log... What is the issue ?

Log level: Error
Short message Payments.PayPalCommerce error: Failed request:
Full message: Nop.Core.NopException: Failed request (BadRequest): Request is not well-formed, syntactically incorrect, or violates schema.
{
  "name": "INVALID_REQUEST",
  "message": "Request is not well-formed, syntactically incorrect, or violates schema.",
  "debug_id": "f303881ea32b0",
  "details": [
    {
      "field": "/purchase_units/@reference_id=='default'/items/0/image_url",
      "value": "https://localhost:44358/images/thumbs/0000722_-.jpeg",
      "location": "body",
      "issue": "INVALID_PARAMETER_SYNTAX",
      "description": "The value of a field does not conform to the expected format."
    },
    {
      "field": "/purchase_units/@reference_id=='default'/supplementary_data/card/level3/line_items/0/image_url",
      "value": "https://localhost:44358/images/thumbs/0000722_-.jpeg",
      "location": "body",
      "issue": "INVALID_PARAMETER_SYNTAX",
      "description": "The value of a field does not conform to the expected format."
    }
  ],
  "links": [
    {
      "title": null,
      "href": "https://developer.paypal.com/docs/api/orders/v2/#error-INVALID_PARAMETER_SYNTAX",
      "method": null,
      "rel": "information_link",
      "encType": "application/json",
      "mediaType": null
    }
  ]
}
3 ay önce
It could be that they don't like localhost:port in an image URL

        "field": [ ... ] /line_items/0/image_url",
      "value": "https://localhost:44358/images/thumbs/0000722_-.jpeg",
1 ay önce
Hi,

Has this been fixed or is there a work around other than assigning images to every item?
1 ay önce
Yes, this has been fixed in the plugin 4.80.15 version.