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 gateway class -- Transaction.Items is null first time ProcessTransaction is called #345

Closed
mindcross opened this issue Feb 18, 2021 · 1 comment · Fixed by #349
Closed
Milestone

Comments

@mindcross
Copy link

Describe the bug

When processing a purchase via a custom gateway class (a class inheriting from PaymentGateway), the overridden method ProcessTransaction will receive a parameter of type Transaction, which has a property called Items. For the very first purchase the Items property is null, which of course means the purchase is unable to complete successfully since no item information is available. Subsequent purchase attempts succeed (the Transaction.Items is populated correctly).

Software Versions

  • DNN: 09.08.01
  • Hotcakes: 3.5.0

To Reproduce

  1. Perform an iisreset
  2. Purchase a product
  3. Purchase fails (if your code relies on the Items list not being null).
  4. Try to purchase the product again, with the same user and type in the exact same payment information.
  5. This time the Items list is present and populated and the purchase succeeds.
  6. Perform another iisreset and you can reproduce the problem again.

Example code:

public override void ProcessTransaction(Transaction t)
{
//t.Items is null (FIRST purchase attempt only)

foreach(var item in t.Items) //blows up here when t.Items is null
{
//do something
}
}

Expected behavior

The Items list should always contain the items being purchased by the user.

@joshgk00
Copy link
Contributor

I experienced the same issue. I think I found the cause. What I found was that in the ReceiveCreditCards.ProcessTransaction method the order number that was supposed to be supplied to the Transaction object being created, was always an empty string. This was the case for my custom payment provider and also the providers that come out of the box. If the OrderNumber is blank, the Order Repository will return the first item it finds or it'll return null. I think that's why the items list is coming back null. I believe I have a fix for this bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

3 participants