Step 4. Process IPN messages

Instead of periodically checking the processing status using the GetFeedSubmissionResult operation, you can subscribe to the Batch Complete Instant Payment Notification (IPN). This IPN is sent when all requests in a batch have completed execution. The IPN summarizes the results of the batch and contains a report ID, which sellers can use to obtain a report by calling the GetReport operation of the Reports API. The endpoint used to receive the IPN is the same as the one used for Amazon Pay and Login with Amazon notifications, which can be configured in Seller Central Settings in Integration Settings.

Sample IPN messages

The sections below show the types of API calls that you can submit in a feed and a sample IPN for each call.

Order Reference IPN message

This IPN message is sent in response to an Order Reference object that has been moved to a Closed state.

 
    <OrderReferenceNotification
            xmlns="https://mws.amazonservices.com/ipn/OffAmazonPayments/2013-01-01"> 
      <OrderReference>        
        <AmazonOrderReferenceId>P01-8574386-4998340</AmazonOrderReferenceId>       
        <OrderTotal>            
          <Amount>0.01</Amount>            
          <CurrencyCode>USD</CurrencyCode>        
        </OrderTotal>        
        <SellerOrderAttributes>            
          <SellerId>A1Y7L5QEXAMPLE</SellerId>            
          <SellerOrderId>1234567</SellerOrderId>            
          <OrderItemCategories/>        
        </SellerOrderAttributes>        
        <OrderReferenceStatus>            
          <State>Closed</State>            
          <LastUpdateTimestamp>2014-12-05T18:53:29.849Z</LastUpdateTimestamp>   
          <ReasonCode>MaxAuthorizationsProcessed</ReasonCode>        
        </OrderReferenceStatus>        
        <CreationTimestamp>2014-12-05T18:53:25.796Z</CreationTimestamp>        
        <ExpirationTimestamp>2015-06-03T18:53:25.796Z</ExpirationTimestamp>    
      </OrderReference>
    </OrderReferenceNotification>
    

Authorize IPN message

This IPN message is sent when an authorization status has changed to a closed state. Note that this API call is not available for EU feeds.

 
    <AuthorizationNotification 
                   xmlns="https://mws.amazonservices.com/ipn/OffAmazonPayments/2013-01-01">    
      <AuthorizationDetails>        
        <AmazonAuthorizationId>
          P01-8574386-4998340-A064528
        </AmazonAuthorizationId>
        <AuthorizationReferenceId>
          1647644-2000AMYO
        </AuthorizationReferenceId>   
        <AuthorizationAmount>            
          <Amount>0.01</Amount>            
          <CurrencyCode>USD</CurrencyCode>       
        </AuthorizationAmount>        
        <CapturedAmount>           
          <Amount>0.01</Amount>            
          <CurrencyCode>USD</CurrencyCode>       
        </CapturedAmount>        
        <AuthorizationFee>            
          <Amount>0.0</Amount>           
          <CurrencyCode>USD</CurrencyCode>        
        </AuthorizationFee>        
        <IdList>            
          <Id>P01-8574386-4998340-C064528</Id>       
        </IdList>        
        <CreationTimestamp>2014-12-05T18:53:26.049Z</CreationTimestamp> 
        <ExpirationTimestamp>2015-01-04T18:53:26.049Z</ExpirationTimestamp>  
        <AuthorizationStatus>            
          <State>Closed</State>            
          <LastUpdateTimestamp>2014-12-05T18:53:28.892Z</LastUpdateTimestamp> 
          <ReasonCode>MaxCapturesProcessed</ReasonCode>        
        </AuthorizationStatus>        
        <OrderItemCategories/>        
        <CaptureNow>true</CaptureNow>        
        <SoftDescriptor> AMZ*Test </SoftDescriptor>    
      </AuthorizationDetails>
    </AuthorizationNotification>
    

Capture IPN message

This IPN message is sent when the capture status changes to a Completed state.

 
    <CaptureNotification xmlns="https://mws.amazonservices.com/ipn/OffAmazonPayments/2013-01-01">
      <CaptureDetails>        
        <AmazonCaptureId>
          P01-8574386-4998340-C064528
        </AmazonCaptureId>  
        <CaptureReferenceId>
          1647644-2000AMYO
        </CaptureReferenceId>        
        <CaptureAmount>            
          <Amount>0.01</Amount>            
          <CurrencyCode>USD</CurrencyCode>       
        </CaptureAmount>        
        <RefundedAmount>            
          <Amount>0.0</Amount>            
          <CurrencyCode>USD</CurrencyCode>       
        </RefundedAmount>        
        <CaptureFee>            
          <Amount>0.05</Amount>           
          <CurrencyCode>USD</CurrencyCode>        
        </CaptureFee>        
        <IdList/>        
        <CreationTimestamp>2014-12-05T18:53:26.149Z</CreationTimestamp>        
        <CaptureStatus>           
          <State>Completed</State>            
          <LastUpdateTimestamp>2014-12-05T18:53:26.149Z</LastUpdateTimestamp>       
        </CaptureStatus>        
        <SoftDescriptor>AMZ*Test</SoftDescriptor>   
      </CaptureDetails>
    </CaptureNotification>
    

Sandbox testing batch service

You can test your integration with the Batch Service in Sandbox before going live. Be sure to use sandbox marketplace IDs and the endpoint URL from Step 2. Submit your feed content while testing your integration, and when you are done testing change the sandbox marketplace ID to the production marketplace ID.

Sample batch complete IPN message

 
    {
      "Type" : "Notification",
      "MessageId" : "ad26db82-463d-536f-963c-927c067afb7d",
      "TopicArn" : "arn:aws:sns:us-east-1:598607868003:A341L3VCFKNMIYA074997131C7YZGL81KKR",
      "Message" : 
    "{
      "NotificationReferenceId":"a9e5b8cb-7dc7-443e-bbf1-f3ec484c15e6",
      "NotificationType":"Batch",
      "SellerId":"ABIWJIDVP7V6Z",
      "ReleaseEnvironment":"Live",
      "Version":"2013-01-01",
      "NotificationData":
    
      "<?xml version="1.0" encoding="UTF-8"?>
      <BatchNotification xmlns="https://mws.amazonservices.com/ipn/OffAmazonPayments/2013-01-01">
      <Header>
        <MerchantIdentifier>ABIWJIDVP7V6Z</MerchantIdentifier>
      </Header>
        <BatchSummary>
           <BatchReferenceId>4360683431</BatchReferenceId>
           <ReportId>16674517103</ReportId>
           <CreationTimestamp>2013-05-03T10:45:27Z</CreationTimestamp>
           <BatchStatus>Complete</BatchStatus>    
           <ProcessingSummary>
              <RequestsProcessed>10</RequestsProcessed>    
              <RequestsSuccessful>9</RequestsSuccessful>    
              <RequestsFailed>1</RequestsFailed>    
           </ProcessingSummary>
        </BatchSummary>
      </BatchNotification>",
        "Timestamp":"2013-05-03T10:45:27Z"
    }",
    
    "Timestamp" : "2013-05-03T22:45:27.265Z",
    "SignatureVersion" : "1",
    "Signature" : "WPvufNGD0meAuOf+zNdU+2KOoZE0H005/XCGobaUTgc
    EZ+q6ojeKrDPZ7i7EwLS9GTPGZK3Qjk9VPvsLs49svxSIhzLoebKFBTDOu
    rZzQsxoi2Qr5rvebpNkPe4YZpDsCk+0Z2I6xXQWGgc0QRa6umhiecC7AMV
    nMA8wlvtX6ko=",
    "SigningCertURL" : "https://sns.us-east-1.amazonaws.com/SimpleNotificationService-f3ecfb7224c7233fe7bb5f59f96de52f.pem",
    "UnsubscribeURL" : "https://sns.us-east-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-east-1:598607
    868003:A341L3VCFKNMIYA074997131C7YZGL81KKR:67ea3b4a-c3be-4a2c-80ed-71479c924dee"
    }

Element reference from IPN notification

MerchantIdentifier MerchantID
BatchReferenceID The ID of the feed when you upload a feed.
ReportId The ID of the report that was generated after all the requests in the feed are processed. You can use this ReportId and the Amazon MWS Reports API to get the responses for all of the requests in a feed.
BatchStatus Processing status of the batch. Allowed values are COMPLETED and FAILED
RequestsProcessed Total number of requests from the feed that were processed.
RequestsSuccessful Provides the number of requests in the feed that had a successful synchronous response when sent to the Off-Amazon Payments service.
RequestsFailed Provides the number of requests in the feed that had a failed synchronous response when sent to the Off-Amazon Payments service. Note: Synchronous response implies only the response received from the Off-Amazon Payments API service but not the final processing response from the request.

Note: As the batch processing system executes the submitted requests, the payments system starts sending out IPN notifications regarding processing status of each event, like authorization success or capture success. For more information about when these IPN messages might be generated, see Synchronizing your systems with Amazon Pay.

If you do not need to know the updates on each individual operation, you can ignore these IPNs. The processing result of each transaction is available when you download the processing report. But we strongly recommend that you receive IPN messages and store the information in your own database. IPN messages are sent the instant an update has occurred, ensuring more timely and accurate data. In addition, maintaining a database is tremendously helpful in debugging any issues and preserving valuable data.

Note: If the payment service returns an error as a result of executing an operation, the error isn't sent in an IPN. Instead, you can obtain the error through the processing report outlined in Step 5. Request a processing report.