Git Product home page Git Product logo

Comments (5)

biilmann avatar biilmann commented on May 21, 2024

Should only be set when the payment goes through

from gocommerce.

brycekahle avatar brycekahle commented on May 21, 2024

Allow searching by this order number as well.

from gocommerce.

brycekahle avatar brycekahle commented on May 21, 2024

Fixed in #86

from gocommerce.

mraerino avatar mraerino commented on May 21, 2024

While going through the code I noticed this can still happen.

E.g. when a transaction is failing, the invoice number is increased anyways.
https://github.com/netlify/gocommerce/blob/master/api/payments.go#L159-L177

	invoiceNumber, err := models.NextInvoiceNumber(tx, order.InstanceID)
	if err != nil {
		tx.Rollback()
		return internalServerError("We failed to generate a valid invoice ID, please try again later: %v", err)
	}

	tr := models.NewTransaction(order)
	processorID, err := charge(params.Amount, params.Currency, order, invoiceNumber)
	tr.ProcessorID = processorID
	tr.InvoiceNumber = invoiceNumber

	if err != nil {
		tr.FailureCode = strconv.FormatInt(http.StatusInternalServerError, 10)
		tr.FailureDescription = err.Error()
		tr.Status = models.FailedState
		tx.Create(tr)
		tx.Commit()
		return internalServerError("There was an error charging your card: %v", err).WithInternalError(err)
	}

The error case should rollback the invoice id. And the transaction should probably not get one if failed.

from gocommerce.

mraerino avatar mraerino commented on May 21, 2024

Fixed by #182

from gocommerce.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.