Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Payment Gateway Missing Order CustomProperties #308

Open
puresystems opened this issue Jul 22, 2020 · 5 comments
Open

Custom Payment Gateway Missing Order CustomProperties #308

puresystems opened this issue Jul 22, 2020 · 5 comments

Comments

@puresystems
Copy link

Describe the bug

When using order.CustomProperties.SetProperty or order.CustomProperties.Add in a PaymentGateway CreateCharge method, calling HccApp.OrderServices.Orders.Update(order) will update the corresponding xml in the CustomProperties field in the hcc_Order table correctly.

We would then access this CustomProperty from the OrderPaid: OrderTask class in the PaymentProvider via context.Order object.

But if we upgrade Dnn to v9.4.4 or above this functionality now fails at some point after leaving the our PaymentGateway code and hitting our PaymentProvider code. The hcc_order.CustomProperties database field is still updated correctly in the CreateCharge method when we call HccApp.OrderServices.Orders.Update(order), but once it hits our OrderPaid: OrderTask class, the order has lost this CustomProperty and checking the database field confirms this. So something is updating the database field without our CustomProperty.

Is this something which you are able to replicate? Should we be using a different way of updating CustomProperties?

Software Versions

  • DNN: 09.04.04+
  • Hotcakes: 03.02.03+

To Reproduce

Steps to reproduce the behavior:

  1. In the Custom PaymentGateway code CreateCharge(Transaction t) method, use this code:
var HccApp2 = HccAppHelper.InitHccApp();
var results = HccApp2.OrderServices.Orders.FindByCriteria(new OrderSearchCriteria()
{
OrderNumber = t.MerchantInvoiceNumber
});

// get an actual order from the search results
var order = HccApp2.OrderServices.Orders.FindForCurrentStore(results[0].bvin);

// create a new order property
order.CustomProperties.Add(DEVELOPERID, "xref", dict["xref"]);

// update the order to save the new property
HccApp2.OrderServices.Orders.Update(order);
  1. In the OrderPaid: OrderTask class in your custom PaymentProvder, in the Execute(OrderTaskContext context) method use code such as this to retrieve the CustomProperty:

var prop = context.Order.CustomProperties.GetProperty(DEVELOPERID, "xref");

This should retrieve the CustomProperty from the order. But after the Dnn upgrade, at this stage the CustomProperty has been removed from the CustomProperties field in the hcc_Order database table.

@WillStrohl
Copy link
Member

Hmmm... DNN should not have a direct impact on this extension point.

@puresystems
Copy link
Author

Agreed, it doesn't make much sense.

We're looking to rebuild our PaymentGateway code against HC 3.4.1 to test further and one issue is that this helper is now missing:

var HccApp2 = HccAppHelper.InitHccApp();

It's obviously depreciated but what can we use instead? We are using it to find the HC order which we're processing payment for using this:

var results = HccApp2.OrderServices.Orders.FindByCriteria(new OrderSearchCriteria()
{
OrderNumber = t.MerchantInvoiceNumber
});
var order = HccApp2.OrderServices.Orders.FindForCurrentStore(results[0].bvin);

@puresystems
Copy link
Author

Thanks for the pointers.

We've retested on a working version of the site (Dnn 9.3.2) which was on HC 3.2.3 and upgraded to HC 3.4.1 and the CustomProperties value is being lost once it leaves our custom PaymentGateway. We can pause the code after we add the custom property and check the Order table and the CustomProperties field contains our new value.

But once it leaves and completes, the CustomProperties field reverts back to it's previous state.

So in this isntance we have left Dnn on 9.3.2 and only upgraded HC. It's as if the code after our Payment Gateway is using a cached version of the Order and so is missing our new custom property.

@WillStrohl
Copy link
Member

Thanks, Dan. We'll look into this as soon as we can. :)

@WillStrohl WillStrohl changed the title order.CustomProperties issue Payment Gateway Missing Order CustomProperties Jul 27, 2020
@WillStrohl WillStrohl changed the title Payment Gateway Missing Order CustomProperties Custom Payment Gateway Missing Order CustomProperties Jul 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants