Exemple #1
0
    def setUpClass(cls):
        # Vilkas own key for customer id = 65 but end point must be in test mode
        # customer id = 65
        # 'd4fb618f-1f44-4dc0-bdce-4993f4b91b77'
        # 'b5c95243276d3ff398207f8dea3013fef001e6e5f51fb9cb2252f609608a81'
        #cls.API_KEY = '4f10f3dc-cbc7-47a6-abf7-ec2f8189977f'
        #cls.SECRET = '8b6510ef94f2cb9da3d4320d12ae1cd9c880a71be4e8e983e170a71482d43a278b0d53c4a39ef283'
        cls.API_KEY = '00000000-0000-0000-0000-000000000000'
        cls.SECRET = '1234567890ABCDEF'
        cls.ROUTING_ID = '1464524676'
        cls.ORDER_ALIAS = 'ORDER10002'

        # for special character testing
        if sys.version_info < (3, 0):
            # Python 2.7
            cls._recipient_address = 'Nikinväylä 3 test'.decode(
                'utf-8').encode('utf-8')
            cls._additional_info_text = "ÄOrder no.: " + cls.ORDER_ALIAS + "-- Reference no.: 00001"
            cls._additional_info_text = cls._additional_info_text.decode(
                'utf-8').encode('utf-8')
        else:
            # Python 3.6
            cls._recipient_address = 'Nikinväylä 3 test'
            cls._additional_info_text = "ÄOrder no.: " + cls.ORDER_ALIAS + "-- Reference no.: 00001"

        # when using own account we must ensure that we have enough funds otherwise we will get error message
        cls._merchant = PkMerchant(1, cls.API_KEY, cls.SECRET)
        cls._pk_test_merchant = PkMerchant(1)

        cls.logger = logging.getLogger(__name__)
    def setUpClass(cls):
        # Vilkas own key for customer id = 65 but end point must be in test mode
        cls.API_KEY = 'd4fb618f-1f44-4dc0-bdce-4993f4b91b77'
        cls.SECRET = 'b5c95243276d3ff398207f8dea3013fef001e6e5f51fb9cb2252f609608a81'

        cls._merchant = PkMerchant(1, cls.API_KEY, cls.SECRET)
        cls._test_merchant = PkMerchant(1)
        cls.logger = logging.getLogger(__name__)
 def test_search_pickup_points_with_postal_code_only(self):
     m = PkMerchant(1)
     list_data = m.search_pickup_points(
         **{
             'postal_code': '33100',
             'country_code2': '',
             'street_address': None,
             'service_provider': None,
             'max_result': None,
             'timestamp': None
         })
     self.assertIsNotNone(list_data)
Exemple #4
0
    def test_create_merchant_object_in_live(self):
        creation_ok = 1
        try:
            merchant = PkMerchant(0, 'test api', 'test secret')
        except Exception:
            creation_ok = 0

        self.assertIs(creation_ok, 1)
Exemple #5
0
from pakettikauppa.merchant import PkMerchant

# Vilkas own key for customer id = 65 but end point must be in test mode
API_KEY = 'd4fb618f-1f44-4dc0-bdce-4993f4b91b77'
SECRET = 'b5c95243276d3ff398207f8dea3013fef001e6e5f51fb9cb2252f609608a81'
#TRACKING_CODE = 'JJFITESTLABEL1332'
TRACKING_CODE = 'JJFI64574900000137203'

#m = PkMerchant(1, API_KEY, SECRET)
m = PkMerchant(1)

_api_config = m.get_api_config('get_shipment_status')
print("Hash config: {}".format(_api_config))
print("\n")

m.get_shipment_status(TRACKING_CODE)
Exemple #6
0
 def setUpClass(cls):
     cls._merchant = PkMerchant(1)
     cls.TRACKING_CODE = 'JJFI64574900000137203'
from pakettikauppa.merchant import PkMerchant

m = PkMerchant(1)
h_config = m.get_api_config('get_additional_service_list')
print("Config: " + str(h_config))
print("\n")

m.get_additional_service_list()
Exemple #8
0
                        'Code': 'JJFITESTLABEL1332'
                    }
                }
            }
        }
    }
    return dict_data


if __name__ == '__main__':
    # This uses testing data set
    # m = PkMerchant(1)
    # m.get_create_shipment_test_req_data()

    # test with own define API key and secret
    m = PkMerchant(1, API_KEY, SECRET)

    # test with static test credential
    #m = PkMerchant(1)

    req_input = create_input_data(m)
    print("request input: {}".format(req_input))
    print("\n")

    _api_config = m.get_api_config('create_shipment')
    print("Hash config: {}".format(_api_config))
    print("\n")

    #m.get_xml_shipping_label_req_data(**req_input)

    dict_res_data = m.get_shipping_label(**req_input)
from pakettikauppa.merchant import PkMerchant

merchant = PkMerchant(1)

simple_dict_data = merchant.get_simple_test_data_create_shipment()

req_data = merchant.get_proper_req_data_create_shipment(**simple_dict_data)
print("Request data = {}".format(req_data))

xml_req_data = merchant.get_xml_shipment_req_data(**req_data)
print("\n\n")

expected_xml_req_data = merchant.get_create_shipment_test_req_data()
from pakettikauppa.merchant import PkMerchant

m = PkMerchant(1)
h_config = m.get_api_config('get_shipping_method_list')
print("Config: " + str(h_config))
print("\n")

m.get_shipping_method_list()
Exemple #11
0
                            # this is not really needed in Pakettikauppa but Prinetti
                            'Parcel.ParcelService': None
                        },
                    ]
                } #  end Shipment.Consignment
            }  # end Shipment
        }  # end eChannel
    }

    return dict_data


if __name__ == '__main__':
    # This uses testing data set
    # m = PkMerchant(1)
    m = PkMerchant(1, API_KEY, SECRET)

    _api_config = m.get_api_config('create_shipment')
    print("Hash config: {}".format(_api_config))
    print("\n")

    #req_input = create_shipment_input_data(m)
    req_input = m.get_create_shipment_test_req_data()
    print("request input: {}".format(req_input))
    print("\n")

    # For displaying XML input data
    # m.get_xml_shipment_req_data(**req_input)

    dict_res = m.create_shipment(**req_input)
    status = dict_res['status']
Exemple #12
0
                            #    'contentline.countryoforigin': 'FI',
                            #    'contentline.tariffcode': '9608101000',
                            #},
                            # this is not really needed in Pakettikauppa but Prinetti
                            'Parcel.ParcelService': None
                        },
                    ]
                }  #  end Shipment.Consignment
            }  # end Shipment
        }  # end eChannel
    }

    return dict_data


if __name__ == '__main__':
    # This uses testing data set
    # m = PkMerchant(1)
    # m.get_create_shipment_test_req_data()

    m = PkMerchant(1, API_KEY, SECRET)
    req_input = create_shipment_input_data(m)
    print("request input: {}".format(req_input))
    print("\n")

    _api_config = m.get_api_config('create_shipment')
    print("Hash config: {}".format(_api_config))
    print("\n")

    xml_string = m.get_xml_shipment_req_data(**req_input)
Exemple #13
0
 def setUpClass(cls):
     cls._merchant = PkMerchant(1)
     cls._reseller = PkReseller(1)
Exemple #14
0
 def test_empty_secret_key(self):
     with self.assertRaises(Exception):
         merchant = PkMerchant(0, 'test', None)
Exemple #15
0
 def test_empty_api_key(self):
     with self.assertRaises(Exception):
         merchant = PkMerchant(0, None, 'test')
 def setUpClass(cls):
     cls._merchant = PkMerchant(1)