ShopifySharp icon indicating copy to clipboard operation
ShopifySharp copied to clipboard

Can't create gift cards

Open UMDev-Brian opened this issue 6 months ago • 0 comments

Hello, I was wondering if there was a trick to creating gift cards. What we have:

  • Shopify Plus
  • Read-Write access to Gift Cards Transactions
  • Read-Write access to Gift Cards

Here is my attempt:

var gc = new GiftCard()
        {
            InitialValue = (decimal)amount,
            Code = code,
        };
        
        try
        {
            
            var result = await _service.CreateAsync(gc);
            if (result != null) gc = result;
        }
        catch (Exception e)
        {
            _logger.LogError("Failed to create new gift card {ID}", code);
            
        }

Here is the exception always get: Object reference not set to an instance of an object.

Stack Trace

   at ShopifySharp.Infrastructure.Serializer.DeserializeWithNewtonsoft[T](String json, String rootElementPath, Nullable`1 dateParseHandlingOverride)
   at ShopifySharp.Infrastructure.Serializer.Deserialize[T](String json, String rootElementPath, Nullable`1 dateParseHandlingOverride)
   at ShopifySharp.ShopifyService.ExecuteRequestCoreAsync[T](RequestUri uri, HttpMethod method, CancellationToken cancellationToken, HttpContent content, Dictionary`2 headers, String rootElement, Nullable`1 graphqlQueryCost, Nullable`1 dateParseHandlingOverride)
   at ShopifySharp.ShopifyService.ExecuteRequestAsync[T](RequestUri uri, HttpMethod method, CancellationToken cancellationToken, HttpContent content, String rootElement, Dictionary`2 headers)
   at ShopifySharp.GiftCardService.CreateAsync(GiftCard giftCard, CancellationToken cancellationToken)
   at Flourish.PaymentProcessing.ShopifyFlourishGiftCardService.ActivateGiftCardAsync(String code, Int64 amount)

Something about Parsing Dates?? Not sure. Any help would be much appreciated!

UMDev-Brian avatar Apr 02 '25 20:04 UMDev-Brian