def _buy_postage(self, data):
        """
        Generate the SCAN Form for the current shipment record
        """
        res = data['form']
        company_obj = self.pool.get('company.company')
        # Getting the api credentials to be used in refund request generation
        # endicia credentials are in the format : 
        # (account_id, requester_id, passphrase, is_test)
        endicia_credentials = company_obj.get_endicia_credentials()

        buy_postage_api = BuyingPostageAPI(
           request_id = Transaction().user,
           recredit_amount = res['amount'],
           requesterid = endicia_credentials.requester_id,
           accountid = endicia_credentials.account_id,
           passphrase = endicia_credentials.passphrase,
           test = endicia_credentials.usps_test,
        )
        response = buy_postage_api.send_request()

        result = objectify_response(response)
        res['response'] = str(result.ErrorMessage) \
            if hasattr(result, 'ErrorMessage') else 'Success'
        return res
예제 #2
0
 def test0010_recredit_request(self):
     recredit_request_api = BuyingPostageAPI(
         request_id='098765',
         recredit_amount=500.00,
         requesterid=REQUESTER_ID,
         accountid=ACCOUNT_ID,
         passphrase=PASSPHRASE,
         test=True,
     )
     print recredit_request_api.to_xml()
     response = recredit_request_api.send_request()
     print objectify_response(response)
예제 #3
0
 def test0010_recredit_request(self):
     recredit_request_api = BuyingPostageAPI(
         request_id='098765',
         recredit_amount=500.00,
         requesterid=REQUESTER_ID,
         accountid=ACCOUNT_ID,
         passphrase=PASSPHRASE,
         test=True,
     )
     print recredit_request_api.to_xml()
     response = recredit_request_api.send_request()
     print objectify_response(response)
예제 #4
0
    def default_buy_postage(self, data):
        """
        Generate the SCAN Form for the current shipment record
        """
        default = {}

        buy_postage_api = BuyingPostageAPI(
            request_id=Transaction().user,
            recredit_amount=self.start.amount,
            requesterid=self.start.carrier.endicia_requester_id,
            accountid=self.start.carrier.endicia_account_id,
            passphrase=self.start.carrier.endicia_passphrase,
            test=self.start.carrier.endicia_is_test,
        )
        try:
            response = buy_postage_api.send_request()
        except RequestError, error:
            self.raise_user_error('error_label', error_args=(error.message,))
예제 #5
0
    def default_buy_postage(self, data):
        """
        Generate the SCAN Form for the current shipment record
        """
        default = {}

        buy_postage_api = BuyingPostageAPI(
            request_id=Transaction().user,
            recredit_amount=self.start.amount,
            requesterid=self.start.carrier.endicia_requester_id,
            accountid=self.start.carrier.endicia_account_id,
            passphrase=self.start.carrier.endicia_passphrase,
            test=self.start.carrier.endicia_is_test,
        )
        try:
            response = buy_postage_api.send_request()
        except RequestError, error:
            self.raise_user_error('error_label', error_args=(error, ))
예제 #6
0
    def default_buy_postage(self, data):
        """
        Generate the SCAN Form for the current shipment record
        """
        EndiciaConfiguration = Pool().get('endicia.configuration')

        default = {}
        endicia_credentials = EndiciaConfiguration(1).get_endicia_credentials()

        buy_postage_api = BuyingPostageAPI(
            request_id=Transaction().user,
            recredit_amount=self.start.amount,
            requesterid=endicia_credentials.requester_id,
            accountid=endicia_credentials.account_id,
            passphrase=endicia_credentials.passphrase,
            test=endicia_credentials.is_test,
        )
        try:
            response = buy_postage_api.send_request()
        except RequestError, error:
            self.raise_user_error('error_label', error_args=(error,))
예제 #7
0
    def default_buy_postage(self, data):
        """
        Generate the SCAN Form for the current shipment record
        """
        EndiciaConfiguration = Pool().get('endicia.configuration')

        default = {}
        endicia_credentials = EndiciaConfiguration(1).get_endicia_credentials()

        buy_postage_api = BuyingPostageAPI(
            request_id=Transaction().user,
            recredit_amount=self.start.amount,
            requesterid=endicia_credentials.requester_id,
            accountid=endicia_credentials.account_id,
            passphrase=endicia_credentials.passphrase,
            test=endicia_credentials.is_test,
        )
        try:
            response = buy_postage_api.send_request()
        except RequestError, error:
            self.raise_user_error('error_label', error_args=(error, ))
예제 #8
0
    def default_buy_postage(self, data):
        """
        Generate the SCAN Form for the current shipment record
        """
        default = {}
        company = self.start.company
        endicia_credentials = company.get_endicia_credentials()

        buy_postage_api = BuyingPostageAPI(
            request_id=Transaction().user,
            recredit_amount=self.start.amount,
            requesterid=endicia_credentials.requester_id,
            accountid=endicia_credentials.account_id,
            passphrase=endicia_credentials.passphrase,
            test=endicia_credentials.usps_test,
        )
        response = buy_postage_api.send_request()

        result = objectify_response(response)
        default['company'] = self.start.company
        default['amount'] = self.start.amount
        default['response'] = str(result.ErrorMessage) \
            if hasattr(result, 'ErrorMessage') else 'Success'
        return default
    def default_buy_postage(self, data):
        """
        Generate the SCAN Form for the current shipment record
        """
        default = {}
        company = self.start.company
        endicia_credentials = company.get_endicia_credentials()

        buy_postage_api = BuyingPostageAPI(
            request_id=Transaction().user,
            recredit_amount=self.start.amount,
            requesterid=endicia_credentials.requester_id,
            accountid=endicia_credentials.account_id,
            passphrase=endicia_credentials.passphrase,
            test=endicia_credentials.usps_test,
        )
        response = buy_postage_api.send_request()

        result = objectify_response(response)
        default['company'] = self.start.company
        default['amount'] = self.start.amount
        default['response'] = str(result.ErrorMessage) \
            if hasattr(result, 'ErrorMessage') else 'Success'
        return default
예제 #10
0
print shipping_label_api.to_xml()
response = shipping_label_api.send_request()
xyz = objectify_response(response)
filename = '/tmp/' + str(xyz.PIC) + '.png'
f = open(filename, 'wb')
f.write(base64.decodestring(str(xyz.Base64LabelImage)))
f.close()
print "New Label at: %s" % filename
pic_number = xyz['PIC']
#
#Buying postage API
#
recredit_request_api = BuyingPostageAPI(
                                   request_id='098765',
                                   recredit_amount=500.00,
                                   requesterid=REQUESTER_ID,
                                   accountid=ACCOUNT_ID,
                                   passphrase=PASSPHRASE,
                                   test=True,
                                   )
recredit_request_api.to_xml()
response = recredit_request_api.send_request()
objectify_response(response)
#
#Change passphrase API
#
change_pp_api = ChangingPassPhraseAPI(
                                   request_id='098765',
                                   new_pass_phrase='my new password',
                                   requesterid=REQUESTER_ID,
                                   accountid=ACCOUNT_ID,
                                   passphrase=PASSPHRASE,