Difference between revisions of "Amazon Integration"

From Opentaps Wiki
Jump to navigationJump to search
(To Do)
Line 212: Line 212:
== To Do ==
* Relation of Amazon taxLocationCode to Opentaps taxAuthorityId

Revision as of 00:14, 31 October 2007

Setting Up Amazon Integration

To enable integration with Amazon.com:

  • Uncomment the line for the Amazon.com component in hot-deploy/component-load.xml
  • Load the seed data in hot-deploy/amazon/data/AmazonSeedData.xml
  • Load the demo data in hot-deploy/amazon/data/AmazonDemoData.xml or use it as a guide to configure your own data
  • Configure the following properties in hot-deploy/amazon/config/amazon.properties (see below for descriptions of the properties):
    • opentaps.amazon.merchantIdentifier
    • opentaps.amazon.merchantName
    • opentaps.amazon.userName
    • opentaps.amazon.password
    • opentaps.amazon.error.email.fromAddress (optional)
    • opentaps.amazon.error.email.toAddress (optional)
  • If you plan to use Opentaps to schedule shipments with carriers, comment out the ShipmentRouteSegment eECA in hot-deploy/amazon/entitydef/eecas_amazon_orders.xml and uncomment the completePack sECA in hot-deploy/amazon/servicedef/secas_amazon_orders.xml. This will ensure that the tracking numbers returned by the carrier are correctly posted to Amazon.

Basic Workflow

  • Product Importing
    • The Amazon integration component disallows the changing of the ASIN and SKU GoodIdentification numbers in the catalog manager.
  • Customer Matching
    • Amazon uses email address as the unique identifier of a customer.
    • Amazon sends phone numbers which are parsed with regex into separate area code and phone numbers
    • Amazon sends state and country codes which are matched against the Geo and GeoAssoc entities in opentaps.
  • Order Importing
    • Pending order documents are downloaded from Amazon and stored periodically (opentaps.amazon.storePendingOrderDocuments service)
    • Acknowledgement is posted to Amazon of downloaded order documents (opentaps.amazon.acknowledgeOrderDocumentDownload service)
    • Amazon orders are extracted from stored order documents (opentaps.amazon.extractOrdersForImport service)
    • Extracted orders are imported into the Opentaps data model (opentaps.amazon.importOrders service)
    • Acknowledgement is posted to Amazon of imported orders (opentaps.amazon.acknowledgeImportedOrders service)
    • Acknowledgement is posted to Amazon of fulfilled (shipped) order items. This is accomplished by two independent services: opentaps.amazon.queueShippedItemsForFulfillmentPost, which is responsible for detecting shipment of order items related to Amazon orders (currently via an entity-ECA triggered by the update of a ShipmentRouteSegment.carrierServiceStatusId to SHRSCS_ACCEPTED) and queueing them for fulfillment acknowledgement; and opentaps.amazon.acknowledgeFulfilledOrderItems which posts the fulfillment acknowledgement to Amazon of any order items in the acknowledgement queue.
    • Posted acknowledgement documents are periodically checked for availability of their related processing report from Amazon. If the processing report becomes available it will be retrieved and the statuses of the related objects updated according to the information in the report.
    • There are no execution dependencies - these steps will all run independently from one another by scheduled jobs and will operate on whatever data is available in the right condition at each runtime.


Service Area Action Notes


Orders Requests all pending order documents from Amazon and stores each document in the AmazonOrderDocument entity. The service will fail only if there is a database error or a communication error with Amazon. Each document is treated separately - if the download of one document fails, the AmazonOrderDocument record will reflect the error and reason, but other documents in the same batch won't be affected. If a document download fails, the service will keep trying to download it from Amazon at each run. Documents will also fail if they consist of invalid or unparseable XML.
  • An attempt to parse the XML of the downloaded document is made before storing a success result


Orders Finds any AmazonOrderDocuments in the database which have been successfully downloaded, but for which download acknowledgement has not yet been posted back to Amazon, and posts that acknowledgement. The service will fail only in the case of a database error. If there is an error posting acknowledgement, each of the affected AmazonOrderDocuments will reflect the failure and the reason. The AmazonOrderDocument.ackStatusId field will be set to AMZN_DOC_ACKED or AMZN_DOC_ACK_ERR.


Orders Finds any AmazonOrderDocuments in the database which have been successfully downloaded *and* successfully acknowledged, and for which extraction has failed no more than the number of times defined in the opentaps.amazon.import.order.retry.threshold.extract property, and attempts to parse each document in order to extract information about Amazon orders. The service will fail only in the case of a database error. Order documents are dealt with in an atomic fashion - if a document is unparseable or there is a problem extracting or storing order information into the import tables for any order in an order document, the entire order document will be marked as a failure and no orders will be extracted from it. Records in these entities will be created for each Amazon order extracted successfully (see the Entities section below for a description of the contents of each entity):
  • AmazonOrder
  • AmazonOrderItem
  • AmazonOrderItemPriceComponent
  • AmazonOrderItemFee
  • AmazonOrderItemTaxJurisdtn
  • AmazonOrderItemTaxAmount
  • AmazonOrderItemTaxRate
  • AmazonOrderItemPromo
  • When dates for order date and order posted date are extracted from the XML as strings, they are corrected to the server's timezone before being stored in AmaonOrder as timestamps.

importOrders service

Orders Creates the constellation of order-related data from any unimported Amazon orders, or any Amazon orders for which import has failed no more than the number of times defined in the opentaps.amazon.import.order.retry.threshold.import property. Each order will succeed or fail independently of the others - the service will only return error in the case of a database error. Individual Amazon orders are updated to AMZN_ORDR_IMPTD status if successful, AMZN_ORDR_IMPTD_ERR if unsuccessful. If unsuccessful, the importFailure count for the Amazon order will be incremented and the reason for the failure will be recorded in the corresponding AmazonOrder.importErrorMessage field. If successful, an AmazonOrderImport record and one or more AmazonOrderItemImport records will be created to define the relation to the Opentaps order and items. An AmazonParty record will also be created if the customer didn't previously exist in the system (determined by looking for the buyerEmailAddress in the AmazonParty entity).


Orders Finds any Amazon orders which have been successfully imported and haven't yet been acknowledged, or for which acknowledgement failed previously. Constructs one XML document and posts it to Amazon, and updates each order's status to AMZN_ORDR_ACK_SENT if the post is successful, and AMZN_ORDR_SC_ACK_ERR if unsuccessful. All orders succeed or fail together, and the AmazonOrder.acknowledgeErrorMessage field stores the reason for failure. If successful, the AmazonOrder.processingDocumentId and AmazonOrder.acknowledgeMessageId fields are updated with values used later by the opentaps.amazon.checkAcknowledgementStatuses to retrieve processing data.


Orders Triggered by confirming a shipment with a carrier. If the shipment contains items related to an Amazon order, constructs an AmazonOrderItemFulfillment record for each item, for the quantity shipped, with ackStatusId AMZN_SHIP_NOT_ACKED.


Orders Finds any AmazonOrderItemFulfillment records which haven't yet been acknowledged, or for which acknowledgement failed previously. Constructs one XML document and posts it to Amazon, and updates each order item's ackStatusId to AMZN_SHIP_ACK_SENT if the post is successful, and AMZN_SHIP_ACK_ERR if unsuccessful. All order item fulfillments succeed or fail together, and the AmazonOrderItemFulfillment.acknowledgeErrorMessage field stores the reason for failure. If successful, the AmazonOrderItemFulfillment.processingDocumentId and AmazonOrderItemFulfillment.acknowledgeMessageId fields are updated with values used later by the opentaps.amazon.checkAcknowledgementStatuses to retrieve processing data.


Orders Finds any Amazon-related objects (currently AmazonOrder and AmazonOrderItemFulfillment) which are recorded as having had an acknowledgment posted to Amazon. Retrieves the set of processingDocumentIds from these objects, and retrieves each document. Each document is examined for reports of processing errors relating to the objects. The object's ackStatusId field is updated to a success status (AMZN_ORDER_SCSS_ACKED/AMZN_ORDR_FAIL_ACKED or AMZN_SHIP_ACKED) or error status (AMZN_ORDER_SCSS_ACK_ERR/AMZN_ORDR_FL_ACK_ERR or AMZN_SHIP_ACK_ERR) and the object's acknowledgeErrorMessage holds any errors reported.


Orders Posts failure acknowledgement to Amazon of an order which can't or won't be imported. AmazonOrder.statusId is set to AMZN_ORDR_CANCELLED and ackStatusId to AMZN_ORDR_ACK_FL_ST if success or AMZN_ORDR_FL_ACK_ERR if error.


Entity Holds

Configuration Properties

Property Controls

Test Cases

Order Item Fulfillment (Charge-When-Ship)

Test Case Action Result
1 Order an item on Amazon.com and wait until the order has been imported into Opentaps. Pack the full order in the Warehouse application. Wait until the scheduled job for the opentaps.amazon.acknowledgeFulfilledOrderItems services has run (or run it manually). Result: There should be AmazonOrderItemFulfillment records representing the fulfilled order items, for which the ackStatusId field should be AMZN_SHIP_ACK_ERR. The orders should be marked 'Confirmed' in the Amazon Seller Central site's 'Manage Orders' screen.
2 Place a multiple-item order on Amazon.com and wait until the order has been imported. Pack part of the order. Wait until the service has run as above. The shipped order items should be noted in Seller Central, but the entire order should not be marked confirmed since it hasn't all been shipped.
3 Pack the rest of the order from case 2. Wait until the service has run as above. The order should be marked confirmed in Seller Central, since it has been fully shipped.