It would be nice to use the note field when creating a transaction. The note would contain the products purchased.

Comments

focal55 created an issue. See original summary.

focal55’s picture

StatusFileSize
new1.05 KB

Here is pass at adding notes to the transaction.

czigor’s picture

'note' is not really good for this purpose. We can create an order in square (https://docs.connect.squareup.com/api/connect/v2#endpoint-createorder) that would hold the order items info. Then we can link this order to the transaction using the transaction's order_id parameter (https://docs.connect.squareup.com/api/connect/v2#endpoint-charge).

czigor’s picture

Status: Active » Needs review
StatusFileSize
new7.15 KB

The patch creates a square order based on the DC order line items and links it to the square transaction.

The square order total is required to match the payment amount. This is not the case if we have order promotions or other adjustments.

Case #1 The square order total is more than the payment amount.
SInce square does not allow negative amounts for line items, we decrease square line item prices until we make up for the difference.

Case #2 The square order total is less than the payment amount.
We create a fake square line item with name 'Adjustments' to make up for the difference.

czigor’s picture

Would be nice if someone could test this with live transactions too: sandbox transactions do not appear on the dashboard, I could only check square orders via the api.

czigor’s picture

Status: Needs review » Needs work

Instead of juggling with square line item base prices we should probably use square line item discounts
$line_item->setDiscounts($discounts)

czigor’s picture

StatusFileSize
new6.86 KB
new5.95 KB

Using square discounts now. Code is shorter and easier to read this way.

czigor’s picture

Status: Needs work » Needs review
czigor’s picture

StatusFileSize
new6.84 KB

Reroll for latest dev.

focal55’s picture

Thank you czigor!

mglaman’s picture

focal55 have you given this a test in production? I'm going to do a basic test. But we need some end-user confidence before we commit and put in a release.

mglaman’s picture

I reached out to Square to see if we can find additional ways to test beyond: 1) Push to API and see no errors. 2) Use API to pull order down and verify.

focal55’s picture

@mglaman I should have some time with this today and will report back asap.

focal55’s picture

StatusFileSize
new6.76 KB

I wasn't able to make czigor's patch at #9 work with latest dev version. Here is a new patch applied against commerce_square 8.x-1.x.

I can confirm with commerce 8.x-2.x and commerce_square 8.x-1.x this work as expected. When you view the transaction on Square website the transaction is clickable and shows the product and quantity purchased. See screenshot:
https://cl.ly/3C2q1s1I3A2e

mglaman’s picture

Status: Needs review » Reviewed & tested by the community

focal55, thanks! I'll commit this and then mark it for 7.x backport.

  • mglaman committed 60ea875 on 8.x-1.x authored by focal55
    Issue #2912445 by czigor, focal55: Add purchase details to transaction...
mglaman’s picture

Status: Reviewed & tested by the community » Patch (to be ported)

Committed to 8.x.

mglaman’s picture

Status: Patch (to be ported) » Fixed

I don't like the "Patch (to be ported)" status. Let's close this as fixed and just have a new issue, #2931511: Backport "Add purchase details to transaction notes" to 7.x

focal55’s picture

Woot! Thanks mglaman and czigor

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.