The CyberSource Tax calcuation service has a field for productCode for each line item, and currently this is set to default in commerce_cybersource_itemize_order(). I'd like to be able to specify a field on each product that contains this product code from their table (we're already entered all the information). It might make sense to allow a setting for this in the payment settings.

If this isn't accepted in commerce_cybersource, a reasonable workaround would be to use hook_commerce_cybersource_item_alter() to add this information.

Comments

rszrama’s picture

Agreed. Looks like I just hardcoded "default" and thought to come back to it later. We should add a field selection widget that lets you identify any field attached to a product type as the productCode field (let's assume there will only be one since fields can be reused across types). We can also provide a textfield for the default value that defaults to "default".

mikey_p’s picture

Status: Active » Needs review
StatusFileSize
new4.55 KB

Here's a first stab at this.

I changed a couple of invalid line item properties that we're invalid along with the addition for product code in a custom field:

-      $item->productName = $line_item_wrapper->description->value();
-      $item->productSKU = $line_item_wrapper->label->value();
+      $item->productName = $line_item_wrapper->line_item_label->value();
+      $item->productSKU = $line_item_wrapper->type->value();
mikey_p’s picture

Removed a redundant comment.

mikey_p’s picture

Another patch, this one removes the line that assigns and ID to the item, since cybersource only uses the index, not ID, and it only indexes from 0. (If item 0 is missing, it rejects, and returns an missing field error).

$item->id = $line_item_wrapper->line_item_id->value();

I don't know much about how entity_metadata_wrapper works, but I hope we can trust the Iterator and ArrayAccess to consistently sort the items, otherwise we'll have to flatten it out into a separate array and sort it before preparing the order, and remapping the response to line items will be a bit of a pain.

mikey_p’s picture

I take that back, the missing id field was causing CyberSource to return a SOAPException about java.lang.NullPointer error or something like that.

This just uses the delta since it's going to get reassigned anyway.

rszrama’s picture

Issue summary: View changes
Status: Needs review » Fixed

Thanks for your efforts on this back in the day, sorry we never carried this forward to a full release. I'm leaving the 7.x branch marked as supported to avoid error messages in the UI, but given the 8+ years that have elapsed, I'm marking all 7.x issues outdated and focusing on a feature complete integration in the 8.x branch.

rszrama’s picture

Status: Fixed » Closed (outdated)