Push Notification Code Samples

Push notifications are via a form post to a URL that you provide on the Merchant Settings page in the Merchant Portal. The following are examples of capturing Push Notifications using the JAVA Servlet API.

Capturing the Push Notification

public void baseCommercePushNotification( HttpServletRequest vo_request, HttpServletResposne vo_response ) throws Exception {
     String s_merchant_username = vo_request.getParameter("merchant_username");
     String s_push_notification = vo_request.getParameter("push_notification");
     // You will need to use the merchant username to retrieve the password and key from your local database
     String s_merchant_password = getMerchantPasswordFromLocalDatabase();
     String s_merchant_key = getMerchantKeyFromLocalDatabase();
     BaseCommerceClient o_client = new BaseCommerceClient( s_merchant_username, s_merchant_password, s_merchant_key );
     PushNotification o_push_notification = o_client.handlePushNotification( s_push_notification );
     // From this point, you will determine the type of notification that is being sent and handle it accordingly
     if ( o_push_notification.isNotificaionType( PushNotification.XS_PN_TYPE_ACH_CHANGE ) {
          handleACHChangeNotification( o_push_notification );
     } else if ( o_push_notification.isNotificationType( PushNotification.XS_PN_TYPE_SETTLEMENT_BATCH_CHANGE ) {
          handleSettlementBatchChange( o_push_notification );