malipojsts-mpesa
v0.0.3
Published
A TypeScript and javascript M-Pesa payments library
Maintainers
Readme
��#� �m�a�l�i�p�o�j�s�t�s�-�m�p�e�s�a�
�
�
�
�A� �m�o�d�e�r�n� �T�y�p�e�S�c�r�i�p�t�/�J�a�v�a�S�c�r�i�p�t� �l�i�b�r�a�r�y� �f�o�r� �M�-�P�e�s�a� �p�a�y�m�e�n�t� �i�n�t�e�g�r�a�t�i�o�n�s� �w�i�t�h� �r�e�a�l�-�t�i�m�e� �p�a�y�m�e�n�t� �u�p�d�a�t�e�s� �v�i�a� �W�e�b�S�o�c�k�e�t�.�
�
�
�
�[�!�[�n�p�m� �v�e�r�s�i�o�n�]�(�h�t�t�p�s�:�/�/�b�a�d�g�e�.�f�u�r�y�.�i�o�/�j�s�/�m�a�l�i�p�o�j�s�t�s�-�m�p�e�s�a�.�s�v�g�)�]�(�h�t�t�p�s�:�/�/�w�w�w�.�n�p�m�j�s�.�c�o�m�/�p�a�c�k�a�g�e�/�m�a�l�i�p�o�j�s�t�s�-�m�p�e�s�a�)�
�
�[�!�[�L�i�c�e�n�s�e�:� �M�I�T�]�(�h�t�t�p�s�:�/�/�i�m�g�.�s�h�i�e�l�d�s�.�i�o�/�b�a�d�g�e�/�L�i�c�e�n�s�e�-�M�I�T�-�y�e�l�l�o�w�.�s�v�g�)�]�(�h�t�t�p�s�:�/�/�o�p�e�n�s�o�u�r�c�e�.�o�r�g�/�l�i�c�e�n�s�e�s�/�M�I�T�)�
�
�
�
�#�#� �F�e�a�t�u�r�e�s�
�
�
�
�(' ���M�o�d�e�r�n� �&� �T�y�p�e�-�S�a�f�e��� �-� �B�u�i�l�t� �w�i�t�h� �T�y�p�e�S�c�r�i�p�t�,� �f�u�l�l�y� �t�y�p�e�d�
�
�=� ���E�a�s�y� �t�o� �U�s�e��� �-� �S�i�m�p�l�e�,� �i�n�t�u�i�t�i�v�e� �A�P�I�
�
�=�� ���R�e�a�l�-�t�i�m�e� �U�p�d�a�t�e�s��� �-� �W�e�b�S�o�c�k�e�t� �s�u�p�p�o�r�t� �f�o�r� �i�n�s�t�a�n�t� �p�a�y�m�e�n�t� �c�o�n�f�i�r�m�a�t�i�o�n�s�
�
�=��� ���P�h�o�n�e� �V�a�l�i�d�a�t�i�o�n��� �-� �A�u�t�o�m�a�t�i�c� �p�h�o�n�e� �n�u�m�b�e�r� �n�o�r�m�a�l�i�z�a�t�i�o�n� �a�n�d� �v�a�l�i�d�a�t�i�o�n�
�
��& ���F�r�a�m�e�w�o�r�k� �A�g�n�o�s�t�i�c��� �-� �W�o�r�k�s� �w�i�t�h� �R�e�a�c�t�,� �V�u�e�,� �N�o�d�e�.�j�s�,� �a�n�d� �m�o�r�e�
�
�<�� ���U�n�i�v�e�r�s�a�l��� �-� �W�o�r�k�s� �i�n� �b�o�t�h� �b�r�o�w�s�e�r� �a�n�d� �N�o�d�e�.�j�s� �e�n�v�i�r�o�n�m�e�n�t�s�
�
�=���� ���E�r�r�o�r� �H�a�n�d�l�i�n�g��� �-� �C�o�m�p�r�e�h�e�n�s�i�v�e� �e�r�r�o�r� �h�a�n�d�l�i�n�g� �a�n�d� �t�i�m�e�o�u�t� �s�u�p�p�o�r�t�
�
�=�� ���A�u�t�o�-�r�e�c�o�n�n�e�c�t��� �-� �A�u�t�o�m�a�t�i�c� �W�e�b�S�o�c�k�e�t� �r�e�c�o�n�n�e�c�t�i�o�n�
�
�
�
�#�#� �I�n�s�t�a�l�l�a�t�i�o�n�
�
�
�
����b�a�s�h�
�
�n�p�m� �i�n�s�t�a�l�l� �m�a�l�i�p�o�j�s�t�s�-�m�p�e�s�a�
�
����
�
�
�
�o�r�
�
�
�
����b�a�s�h�
�
�y�a�r�n� �a�d�d� �m�a�l�i�p�o�j�s�t�s�-�m�p�e�s�a�
�
����
�
�
�
�o�r�
�
�
�
����b�a�s�h�
�
�p�n�p�m� �a�d�d� �m�a�l�i�p�o�j�s�t�s�-�m�p�e�s�a�
�
����
�
�
�
�#�#� �Q�u�i�c�k� �S�t�a�r�t�
�
�
�
����t�y�p�e�s�c�r�i�p�t�
�
�i�m�p�o�r�t� �{� �c�r�e�a�t�e�M�p�e�s�a�C�l�i�e�n�t� �}� �f�r�o�m� �'�m�a�l�i�p�o�j�s�t�s�-�m�p�e�s�a�'�;�
�
�
�
�/�/� �I�n�i�t�i�a�l�i�z�e� �t�h�e� �c�l�i�e�n�t�
�
�c�o�n�s�t� �m�p�e�s�a� �=� �c�r�e�a�t�e�M�p�e�s�a�C�l�i�e�n�t�(�{�
�
� � �b�a�s�e�U�r�l�:� �'�h�t�t�p�:�/�/�1�2�7�.�0�.�0�.�1�:�8�0�0�0�'�,�
�
� � �a�p�i�K�e�y�:� �'�y�o�u�r�-�a�p�i�-�k�e�y�'�,�
�
� � �t�i�m�e�o�u�t�:� �3�0�0�0�0� �/�/� �o�p�t�i�o�n�a�l�
�
�}�)�;�
�
�
�
�/�/� �I�n�i�t�i�a�t�e� �a�n� �S�T�K� �P�u�s�h� �p�a�y�m�e�n�t�
�
�c�o�n�s�t� �r�e�s�p�o�n�s�e� �=� �a�w�a�i�t� �m�p�e�s�a�.�s�t�k�P�u�s�h�(�{�
�
� � �s�e�n�d�e�r�P�h�o�n�e�N�u�m�b�e�r�:� �'�0�7�1�2�3�4�5�6�7�8�'�,�
�
� � �a�m�o�u�n�t�:� �'�1�0�0�'�,�
�
� � �t�r�a�n�s�a�c�t�i�o�n�D�e�s�c�r�i�p�t�i�o�n�:� �'�P�a�y�m�e�n�t� �f�o�r� �g�o�o�d�s�'�
�
�}�)�;�
�
�
�
�c�o�n�s�o�l�e�.�l�o�g�(�'�P�a�y�m�e�n�t� �i�n�i�t�i�a�t�e�d�:�'�,� �r�e�s�p�o�n�s�e�.�C�h�e�c�k�o�u�t�R�e�q�u�e�s�t�I�D�)�;�
�
����
�
�
�
�#�#� �A�P�I� �R�e�f�e�r�e�n�c�e�
�
�
�
�#�#�#� �C�l�i�e�n�t� �I�n�i�t�i�a�l�i�z�a�t�i�o�n�
�
�
�
�#�#�#�#� ��c�r�e�a�t�e�M�p�e�s�a�C�l�i�e�n�t�(�c�o�n�f�i�g�:� �M�p�e�s�a�C�l�i�e�n�t�C�o�n�f�i�g�)�:� �M�p�e�s�a�C�l�i�e�n�t��
�
�
�
�C�r�e�a�t�e�s� �a� �n�e�w� �M�-�P�e�s�a� �c�l�i�e�n�t� �i�n�s�t�a�n�c�e�.�
�
�
�
���P�a�r�a�m�e�t�e�r�s�:���
�
�-� ��b�a�s�e�U�r�l�� �(�s�t�r�i�n�g�,� �r�e�q�u�i�r�e�d�)�:� �Y�o�u�r� �F�a�s�t�A�P�I� �b�a�c�k�e�n�d� �U�R�L�
�
�-� ��a�p�i�K�e�y�� �(�s�t�r�i�n�g�,� �r�e�q�u�i�r�e�d�)�:� �Y�o�u�r� �A�P�I� �a�u�t�h�e�n�t�i�c�a�t�i�o�n� �k�e�y�
�
�-� ��t�i�m�e�o�u�t�� �(�n�u�m�b�e�r�,� �o�p�t�i�o�n�a�l�)�:� �R�e�q�u�e�s�t� �t�i�m�e�o�u�t� �i�n� �m�i�l�l�i�s�e�c�o�n�d�s� �(�d�e�f�a�u�l�t�:� �3�0�0�0�0�)�
�
�
�
����t�y�p�e�s�c�r�i�p�t�
�
�c�o�n�s�t� �m�p�e�s�a� �=� �c�r�e�a�t�e�M�p�e�s�a�C�l�i�e�n�t�(�{�
�
� � �b�a�s�e�U�r�l�:� �'�h�t�t�p�:�/�/�1�2�7�.�0�.�0�.�1�:�8�0�0�0�'�,�
�
� � �a�p�i�K�e�y�:� �'�m�e�r�c�h�a�n�t�_�1�2�3�'�,�
�
� � �t�i�m�e�o�u�t�:� �3�0�0�0�0�
�
�}�)�;�
�
����
�
�
�
�#�#�#� �S�T�K� �P�u�s�h� �P�a�y�m�e�n�t�
�
�
�
�#�#�#�#� ��s�t�k�P�u�s�h�(�r�e�q�u�e�s�t�:� �S�t�k�P�u�s�h�R�e�q�u�e�s�t�)�:� �P�r�o�m�i�s�e�<�S�t�k�P�u�s�h�R�e�s�p�o�n�s�e�>��
�
�
�
�I�n�i�t�i�a�t�e�s� �a�n� �S�T�K� �P�u�s�h� �p�a�y�m�e�n�t� �r�e�q�u�e�s�t�.�
�
�
�
���P�a�r�a�m�e�t�e�r�s�:���
�
����t�y�p�e�s�c�r�i�p�t�
�
�i�n�t�e�r�f�a�c�e� �S�t�k�P�u�s�h�R�e�q�u�e�s�t� �{�
�
� � �s�e�n�d�e�r�P�h�o�n�e�N�u�m�b�e�r�:� �s�t�r�i�n�g�;�
�
� � �a�m�o�u�n�t�:� �s�t�r�i�n�g�;�
�
� � �r�e�c�e�i�v�e�r�B�a�n�k�P�a�y�b�i�l�l�?�:� �s�t�r�i�n�g� �|� �n�u�l�l�;�
�
� � �r�e�c�e�i�v�e�r�B�a�n�k�A�c�c�o�u�n�t�N�u�m�b�e�r�?�:� �s�t�r�i�n�g� �|� �n�u�l�l�;�
�
� � �t�r�a�n�s�a�c�t�i�o�n�D�e�s�c�r�i�p�t�i�o�n�?�:� �s�t�r�i�n�g�;�
�
�}�
�
����
�
�
�
���R�e�t�u�r�n�s�:���
�
����t�y�p�e�s�c�r�i�p�t�
�
�i�n�t�e�r�f�a�c�e� �S�t�k�P�u�s�h�R�e�s�p�o�n�s�e� �{�
�
� � �M�e�r�c�h�a�n�t�R�e�q�u�e�s�t�I�D�:� �s�t�r�i�n�g�;�
�
� � �C�h�e�c�k�o�u�t�R�e�q�u�e�s�t�I�D�:� �s�t�r�i�n�g�;�
�
� � �R�e�s�p�o�n�s�e�C�o�d�e�:� �s�t�r�i�n�g�;�
�
� � �R�e�s�p�o�n�s�e�D�e�s�c�r�i�p�t�i�o�n�:� �s�t�r�i�n�g�;�
�
� � �C�u�s�t�o�m�e�r�M�e�s�s�a�g�e�:� �s�t�r�i�n�g�;�
�
�}�
�
����
�
�
�
���E�x�a�m�p�l�e�:���
�
����t�y�p�e�s�c�r�i�p�t�
�
�c�o�n�s�t� �r�e�s�p�o�n�s�e� �=� �a�w�a�i�t� �m�p�e�s�a�.�s�t�k�P�u�s�h�(�{�
�
� � �s�e�n�d�e�r�P�h�o�n�e�N�u�m�b�e�r�:� �'�0�7�1�2�3�4�5�6�7�8�'�,�
�
� � �a�m�o�u�n�t�:� �'�1�0�0�'�,�
�
� � �t�r�a�n�s�a�c�t�i�o�n�D�e�s�c�r�i�p�t�i�o�n�:� �'�P�r�o�d�u�c�t� �p�u�r�c�h�a�s�e�'�
�
�}�)�;�
�
����
�
�
�
�#�#�#� �B�2�C� �T�r�a�n�s�a�c�t�i�o�n�
�
�
�
�#�#�#�#� ��b�2�c�(�r�e�q�u�e�s�t�:� �B�2�C�R�e�q�u�e�s�t�)�:� �P�r�o�m�i�s�e�<�a�n�y�>��
�
�
�
�I�n�i�t�i�a�t�e�s� �a� �B�u�s�i�n�e�s�s�-�t�o�-�C�u�s�t�o�m�e�r� �t�r�a�n�s�a�c�t�i�o�n�.�
�
�
�
���P�a�r�a�m�e�t�e�r�s�:���
�
����t�y�p�e�s�c�r�i�p�t�
�
�i�n�t�e�r�f�a�c�e� �B�2�C�R�e�q�u�e�s�t� �{�
�
� � �a�m�o�u�n�t�:� �s�t�r�i�n�g�;�
�
� � �p�h�o�n�e�N�u�m�b�e�r�:� �s�t�r�i�n�g�;�
�
� � �r�e�m�a�r�k�s�?�:� �s�t�r�i�n�g�;�
�
� � �o�c�c�a�s�i�o�n�?�:� �s�t�r�i�n�g�;�
�
�}�
�
����
�
�
�
���E�x�a�m�p�l�e�:���
�
����t�y�p�e�s�c�r�i�p�t�
�
�c�o�n�s�t� �r�e�s�p�o�n�s�e� �=� �a�w�a�i�t� �m�p�e�s�a�.�b�2�c�(�{�
�
� � �p�h�o�n�e�N�u�m�b�e�r�:� �'�0�7�1�2�3�4�5�6�7�8�'�,�
�
� � �a�m�o�u�n�t�:� �'�5�0�0�'�,�
�
� � �r�e�m�a�r�k�s�:� �'�S�a�l�a�r�y� �p�a�y�m�e�n�t�'�,�
�
� � �o�c�c�a�s�i�o�n�:� �'�M�o�n�t�h�l�y� �s�a�l�a�r�y�'�
�
�}�)�;�
�
����
�
�
�
�#�#�#� �W�e�b�S�o�c�k�e�t� �C�o�n�n�e�c�t�i�o�n�
�
�
�
�#�#�#�#� ��c�o�n�n�e�c�t�W�e�b�S�o�c�k�e�t�(�o�p�t�i�o�n�s�?�:� �W�e�b�S�o�c�k�e�t�O�p�t�i�o�n�s�)�:� �v�o�i�d��
�
�
�
�C�o�n�n�e�c�t�s� �t�o� �t�h�e� �W�e�b�S�o�c�k�e�t� �s�e�r�v�e�r� �f�o�r� �r�e�a�l�-�t�i�m�e� �p�a�y�m�e�n�t� �u�p�d�a�t�e�s�.�
�
�
�
���P�a�r�a�m�e�t�e�r�s�:���
�
����t�y�p�e�s�c�r�i�p�t�
�
�i�n�t�e�r�f�a�c�e� �W�e�b�S�o�c�k�e�t�O�p�t�i�o�n�s� �{�
�
� � �o�n�O�p�e�n�?�:� �(�)� �=�>� �v�o�i�d�;�
�
� � �o�n�C�l�o�s�e�?�:� �(�)� �=�>� �v�o�i�d�;�
�
� � �o�n�E�r�r�o�r�?�:� �(�e�r�r�o�r�:� �E�v�e�n�t�)� �=�>� �v�o�i�d�;�
�
� � �o�n�M�e�s�s�a�g�e�?�:� �(�d�a�t�a�:� �P�a�y�m�e�n�t�C�a�l�l�b�a�c�k�)� �=�>� �v�o�i�d�;�
�
� � �r�e�c�o�n�n�e�c�t�?�:� �b�o�o�l�e�a�n�;�
�
� � �r�e�c�o�n�n�e�c�t�I�n�t�e�r�v�a�l�?�:� �n�u�m�b�e�r�;�
�
�}�
�
����
�
�
�
���E�x�a�m�p�l�e�:���
�
����t�y�p�e�s�c�r�i�p�t�
�
�m�p�e�s�a�.�c�o�n�n�e�c�t�W�e�b�S�o�c�k�e�t�(�{�
�
� � �o�n�M�e�s�s�a�g�e�:� �(�d�a�t�a�)� �=�>� �{�
�
� � � � �c�o�n�s�o�l�e�.�l�o�g�(�'�P�a�y�m�e�n�t� �u�p�d�a�t�e�:�'�,� �d�a�t�a�)�;�
�
� � � � �i�f� �(�d�a�t�a�.�r�e�s�u�l�t�_�c�o�d�e� �=�=�=� �0�)� �{�
�
� � � � � � �c�o�n�s�o�l�e�.�l�o�g�(�'�P�a�y�m�e�n�t� �s�u�c�c�e�s�s�f�u�l�!�'�)�;�
�
� � � � �}�
�
� � �}�,�
�
� � �r�e�c�o�n�n�e�c�t�:� �t�r�u�e�,�
�
� � �r�e�c�o�n�n�e�c�t�I�n�t�e�r�v�a�l�:� �3�0�0�0�
�
�}�)�;�
�
����
�
�
�
�#�#�#�#� ��d�i�s�c�o�n�n�e�c�t�W�e�b�S�o�c�k�e�t�(�)�:� �v�o�i�d��
�
�
�
�D�i�s�c�o�n�n�e�c�t�s� �f�r�o�m� �t�h�e� �W�e�b�S�o�c�k�e�t� �s�e�r�v�e�r�.�
�
�
�
����t�y�p�e�s�c�r�i�p�t�
�
�m�p�e�s�a�.�d�i�s�c�o�n�n�e�c�t�W�e�b�S�o�c�k�e�t�(�)�;�
�
����
�
�
�
�#�#�#�#� ��i�s�W�e�b�S�o�c�k�e�t�C�o�n�n�e�c�t�e�d�(�)�:� �b�o�o�l�e�a�n��
�
�
�
�C�h�e�c�k� �i�f� �W�e�b�S�o�c�k�e�t� �i�s� �c�u�r�r�e�n�t�l�y� �c�o�n�n�e�c�t�e�d�.�
�
�
�
����t�y�p�e�s�c�r�i�p�t�
�
�i�f� �(�m�p�e�s�a�.�i�s�W�e�b�S�o�c�k�e�t�C�o�n�n�e�c�t�e�d�(�)�)� �{�
�
� � �c�o�n�s�o�l�e�.�l�o�g�(�'�C�o�n�n�e�c�t�e�d� �t�o� �W�e�b�S�o�c�k�e�t�'�)�;�
�
�}�
�
����
�
�
�
�#�#�#� �U�t�i�l�i�t�y� �M�e�t�h�o�d�s�
�
�
�
�#�#�#�#� ��g�e�t�A�u�t�h�T�o�k�e�n�(�)�:� �P�r�o�m�i�s�e�<�a�n�y�>��
�
�
�
�R�e�t�r�i�e�v�e�s� �t�h�e� �a�u�t�h�e�n�t�i�c�a�t�i�o�n� �t�o�k�e�n� �f�r�o�m� �t�h�e� �s�e�r�v�e�r�.�
�
�
�
����t�y�p�e�s�c�r�i�p�t�
�
�c�o�n�s�t� �t�o�k�e�n� �=� �a�w�a�i�t� �m�p�e�s�a�.�g�e�t�A�u�t�h�T�o�k�e�n�(�)�;�
�
����
�
�
�
�#�#� �P�h�o�n�e� �N�u�m�b�e�r� �F�o�r�m�a�t�s�
�
�
�
�T�h�e� �l�i�b�r�a�r�y� �a�u�t�o�m�a�t�i�c�a�l�l�y� �n�o�r�m�a�l�i�z�e�s� �p�h�o�n�e� �n�u�m�b�e�r�s�.� �A�l�l� �t�h�e�s�e� �f�o�r�m�a�t�s� �a�r�e� �v�a�l�i�d�:�
�
�
�
�-� ��0�7�1�2�3�4�5�6�7�8�� �(�1�0� �d�i�g�i�t�s�)�
�
�-� ��2�5�4�7�1�2�3�4�5�6�7�8�� �(�1�2� �d�i�g�i�t�s�)�
�
�-� ��+�2�5�4�7�1�2�3�4�5�6�7�8�� �(�1�3� �c�h�a�r�a�c�t�e�r�s�)�
�
�
�
�A�l�l� �a�r�e� �n�o�r�m�a�l�i�z�e�d� �t�o� ��2�5�4�7�1�2�3�4�5�6�7�8��.�
�
�
�
�#�#� �C�o�m�p�l�e�t�e� �P�a�y�m�e�n�t� �F�l�o�w� �E�x�a�m�p�l�e�
�
�
�
����t�y�p�e�s�c�r�i�p�t�
�
�i�m�p�o�r�t� �{� �c�r�e�a�t�e�M�p�e�s�a�C�l�i�e�n�t� �}� �f�r�o�m� �'�m�a�l�i�p�o�j�s�t�s�-�m�p�e�s�a�'�;�
�
�
�
�c�o�n�s�t� �m�p�e�s�a� �=� �c�r�e�a�t�e�M�p�e�s�a�C�l�i�e�n�t�(�{�
�
� � �b�a�s�e�U�r�l�:� �'�h�t�t�p�:�/�/�1�2�7�.�0�.�0�.�1�:�8�0�0�0�'�,�
�
� � �a�p�i�K�e�y�:� �'�m�e�r�c�h�a�n�t�_�1�2�3�'�
�
�}�)�;�
�
�
�
�a�s�y�n�c� �f�u�n�c�t�i�o�n� �p�r�o�c�e�s�s�P�a�y�m�e�n�t�(�p�h�o�n�e�N�u�m�b�e�r�:� �s�t�r�i�n�g�,� �a�m�o�u�n�t�:� �s�t�r�i�n�g�)� �{�
�
� � �l�e�t� �c�h�e�c�k�o�u�t�R�e�q�u�e�s�t�I�d� �=� �'�'�;�
�
�
�
� � �/�/� �S�t�e�p� �1�:� �C�o�n�n�e�c�t� �t�o� �W�e�b�S�o�c�k�e�t� �f�o�r� �r�e�a�l�-�t�i�m�e� �u�p�d�a�t�e�s�
�
� � �m�p�e�s�a�.�c�o�n�n�e�c�t�W�e�b�S�o�c�k�e�t�(�{�
�
� � � � �o�n�M�e�s�s�a�g�e�:� �(�d�a�t�a�)� �=�>� �{�
�
� � � � � � �i�f� �(�d�a�t�a�.�C�h�e�c�k�o�u�t�R�e�q�u�e�s�t�I�D� �=�=�=� �c�h�e�c�k�o�u�t�R�e�q�u�e�s�t�I�d�)� �{�
�
� � � � � � � � �i�f� �(�d�a�t�a�.�r�e�s�u�l�t�_�c�o�d�e� �=�=�=� �0�)� �{�
�
� � � � � � � � � � �c�o�n�s�o�l�e�.�l�o�g�(�'�' �P�a�y�m�e�n�t� �s�u�c�c�e�s�s�f�u�l�!�'�)�;�
�
� � � � � � � � � � �c�o�n�s�o�l�e�.�l�o�g�(�'�M�e�t�a�d�a�t�a�:�'�,� �d�a�t�a�.�m�e�t�a�d�a�t�a�)�;�
�
� � � � � � � � � � �/�/� �P�r�o�c�e�s�s� �s�u�c�c�e�s�s�f�u�l� �p�a�y�m�e�n�t�
�
� � � � � � � � �}� �e�l�s�e� �{�
�
� � � � � � � � � � �c�o�n�s�o�l�e�.�l�o�g�(�'�L' �P�a�y�m�e�n�t� �f�a�i�l�e�d�:�'�,� �d�a�t�a�.�r�e�s�u�l�t�_�d�e�s�c�r�i�p�t�i�o�n�)�;�
�
� � � � � � � � � � �/�/� �H�a�n�d�l�e� �f�a�i�l�e�d� �p�a�y�m�e�n�t�
�
� � � � � � � � �}�
�
� � � � � � �}�
�
� � � � �}�,�
�
� � � � �o�n�E�r�r�o�r�:� �(�e�r�r�o�r�)� �=�>� �{�
�
� � � � � � �c�o�n�s�o�l�e�.�e�r�r�o�r�(�'�W�e�b�S�o�c�k�e�t� �e�r�r�o�r�:�'�,� �e�r�r�o�r�)�;�
�
� � � � �}�
�
� � �}�)�;�
�
�
�
� � �/�/� �S�t�e�p� �2�:� �I�n�i�t�i�a�t�e� �S�T�K� �P�u�s�h�
�
� � �t�r�y� �{�
�
� � � � �c�o�n�s�t� �r�e�s�p�o�n�s�e� �=� �a�w�a�i�t� �m�p�e�s�a�.�s�t�k�P�u�s�h�(�{�
�
� � � � � � �s�e�n�d�e�r�P�h�o�n�e�N�u�m�b�e�r�:� �p�h�o�n�e�N�u�m�b�e�r�,�
�
� � � � � � �a�m�o�u�n�t�:� �a�m�o�u�n�t�,�
�
� � � � � � �t�r�a�n�s�a�c�t�i�o�n�D�e�s�c�r�i�p�t�i�o�n�:� �'�O�r�d�e�r� �P�a�y�m�e�n�t�'�
�
� � � � �}�)�;�
�
�
�
� � � � �c�h�e�c�k�o�u�t�R�e�q�u�e�s�t�I�d� �=� �r�e�s�p�o�n�s�e�.�C�h�e�c�k�o�u�t�R�e�q�u�e�s�t�I�D�;�
�
� � � � �c�o�n�s�o�l�e�.�l�o�g�(�'��# �P�a�y�m�e�n�t� �i�n�i�t�i�a�t�e�d�.� �W�a�i�t�i�n�g� �f�o�r� �c�o�n�f�i�r�m�a�t�i�o�n�.�.�.�'�)�;�
�
� � � � �c�o�n�s�o�l�e�.�l�o�g�(�'�C�h�e�c�k�o�u�t�R�e�q�u�e�s�t�I�D�:�'�,� �c�h�e�c�k�o�u�t�R�e�q�u�e�s�t�I�d�)�;�
�
� � �}� �c�a�t�c�h� �(�e�r�r�o�r�)� �{�
�
� � � � �c�o�n�s�o�l�e�.�e�r�r�o�r�(�'�F�a�i�l�e�d� �t�o� �i�n�i�t�i�a�t�e� �p�a�y�m�e�n�t�:�'�,� �e�r�r�o�r�)�;�
�
� � �}�
�
�}�
�
�
�
�/�/� �U�s�a�g�e�
�
�p�r�o�c�e�s�s�P�a�y�m�e�n�t�(�'�0�7�1�2�3�4�5�6�7�8�'�,� �'�1�0�0�'�)�;�
�
����
�
�
�
�#�#� �F�r�a�m�e�w�o�r�k� �E�x�a�m�p�l�e�s�
�
�
�
�#�#�#� �R�e�a�c�t�
�
�
�
����t�s�x�
�
�i�m�p�o�r�t� �{� �u�s�e�E�f�f�e�c�t�,� �u�s�e�S�t�a�t�e� �}� �f�r�o�m� �'�r�e�a�c�t�'�;�
�
�i�m�p�o�r�t� �{� �c�r�e�a�t�e�M�p�e�s�a�C�l�i�e�n�t� �}� �f�r�o�m� �'�m�a�l�i�p�o�j�s�t�s�-�m�p�e�s�a�'�;�
�
�
�
�c�o�n�s�t� �m�p�e�s�a� �=� �c�r�e�a�t�e�M�p�e�s�a�C�l�i�e�n�t�(�{�
�
� � �b�a�s�e�U�r�l�:� �'�h�t�t�p�:�/�/�1�2�7�.�0�.�0�.�1�:�8�0�0�0�'�,�
�
� � �a�p�i�K�e�y�:� �'�m�e�r�c�h�a�n�t�_�1�2�3�'�
�
�}�)�;�
�
�
�
�f�u�n�c�t�i�o�n� �P�a�y�m�e�n�t�B�u�t�t�o�n�(�)� �{�
�
� � �c�o�n�s�t� �[�s�t�a�t�u�s�,� �s�e�t�S�t�a�t�u�s�]� �=� �u�s�e�S�t�a�t�e�(�'�i�d�l�e�'�)�;�
�
�
�
� � �u�s�e�E�f�f�e�c�t�(�(�)� �=�>� �{�
�
� � � � �m�p�e�s�a�.�c�o�n�n�e�c�t�W�e�b�S�o�c�k�e�t�(�{�
�
� � � � � � �o�n�M�e�s�s�a�g�e�:� �(�d�a�t�a�)� �=�>� �{�
�
� � � � � � � � �s�e�t�S�t�a�t�u�s�(�d�a�t�a�.�r�e�s�u�l�t�_�c�o�d�e� �=�=�=� �0� �?� �'�s�u�c�c�e�s�s�'� �:� �'�f�a�i�l�e�d�'�)�;�
�
� � � � � � �}�
�
� � � � �}�)�;�
�
�
�
� � � � �r�e�t�u�r�n� �(�)� �=�>� �m�p�e�s�a�.�d�i�s�c�o�n�n�e�c�t�W�e�b�S�o�c�k�e�t�(�)�;�
�
� � �}�,� �[�]�)�;�
�
�
�
� � �c�o�n�s�t� �h�a�n�d�l�e�P�a�y�m�e�n�t� �=� �a�s�y�n�c� �(�)� �=�>� �{�
�
� � � � �s�e�t�S�t�a�t�u�s�(�'�l�o�a�d�i�n�g�'�)�;�
�
� � � � �t�r�y� �{�
�
� � � � � � �a�w�a�i�t� �m�p�e�s�a�.�s�t�k�P�u�s�h�(�{�
�
� � � � � � � � �s�e�n�d�e�r�P�h�o�n�e�N�u�m�b�e�r�:� �'�0�7�1�2�3�4�5�6�7�8�'�,�
�
� � � � � � � � �a�m�o�u�n�t�:� �'�1�0�0�'�
�
� � � � � � �}�)�;�
�
� � � � � � �s�e�t�S�t�a�t�u�s�(�'�p�e�n�d�i�n�g�'�)�;�
�
� � � � �}� �c�a�t�c�h� �(�e�r�r�o�r�)� �{�
�
� � � � � � �s�e�t�S�t�a�t�u�s�(�'�e�r�r�o�r�'�)�;�
�
� � � � �}�
�
� � �}�;�
�
�
�
� � �r�e�t�u�r�n� �(�
�
� � � � �<�b�u�t�t�o�n� �o�n�C�l�i�c�k�=�{�h�a�n�d�l�e�P�a�y�m�e�n�t�}� �d�i�s�a�b�l�e�d�=�{�s�t�a�t�u�s� �=�=�=� �'�l�o�a�d�i�n�g�'�}�>�
�
� � � � � � �{�s�t�a�t�u�s� �=�=�=� �'�l�o�a�d�i�n�g�'� �?� �'�P�r�o�c�e�s�s�i�n�g�.�.�.�'� �:� �'�P�a�y� �N�o�w�'�}�
�
� � � � �<�/�b�u�t�t�o�n�>�
�
� � �)�;�
�
�}�
�
����
�
�
�
�#�#�#� �N�o�d�e�.�j�s� �E�x�p�r�e�s�s�
�
�
�
����j�a�v�a�s�c�r�i�p�t�
�
�c�o�n�s�t� �e�x�p�r�e�s�s� �=� �r�e�q�u�i�r�e�(�'�e�x�p�r�e�s�s�'�)�;�
�
�c�o�n�s�t� �{� �c�r�e�a�t�e�M�p�e�s�a�C�l�i�e�n�t� �}� �=� �r�e�q�u�i�r�e�(�'�m�a�l�i�p�o�j�s�t�s�-�m�p�e�s�a�'�)�;�
�
�
�
�c�o�n�s�t� �a�p�p� �=� �e�x�p�r�e�s�s�(�)�;�
�
�a�p�p�.�u�s�e�(�e�x�p�r�e�s�s�.�j�s�o�n�(�)�)�;�
�
�
�
�c�o�n�s�t� �m�p�e�s�a� �=� �c�r�e�a�t�e�M�p�e�s�a�C�l�i�e�n�t�(�{�
�
� � �b�a�s�e�U�r�l�:� �'�h�t�t�p�:�/�/�1�2�7�.�0�.�0�.�1�:�8�0�0�0�'�,�
�
� � �a�p�i�K�e�y�:� �p�r�o�c�e�s�s�.�e�n�v�.�M�P�E�S�A�_�A�P�I�_�K�E�Y�
�
�}�)�;�
�
�
�
�a�p�p�.�p�o�s�t�(�'�/�a�p�i�/�p�a�y�m�e�n�t�'�,� �a�s�y�n�c� �(�r�e�q�,� �r�e�s�)� �=�>� �{�
�
� � �t�r�y� �{�
�
� � � � �c�o�n�s�t� �r�e�s�p�o�n�s�e� �=� �a�w�a�i�t� �m�p�e�s�a�.�s�t�k�P�u�s�h�(�{�
�
� � � � � � �s�e�n�d�e�r�P�h�o�n�e�N�u�m�b�e�r�:� �r�e�q�.�b�o�d�y�.�p�h�o�n�e�N�u�m�b�e�r�,�
�
� � � � � � �a�m�o�u�n�t�:� �r�e�q�.�b�o�d�y�.�a�m�o�u�n�t�,�
�
� � � � � � �t�r�a�n�s�a�c�t�i�o�n�D�e�s�c�r�i�p�t�i�o�n�:� �'�P�a�y�m�e�n�t�'�
�
� � � � �}�)�;�
�
�
�
� � � � �r�e�s�.�j�s�o�n�(�{� �s�u�c�c�e�s�s�:� �t�r�u�e�,� �d�a�t�a�:� �r�e�s�p�o�n�s�e� �}�)�;�
�
� � �}� �c�a�t�c�h� �(�e�r�r�o�r�)� �{�
�
� � � � �r�e�s�.�s�t�a�t�u�s�(�4�0�0�)�.�j�s�o�n�(�{� �s�u�c�c�e�s�s�:� �f�a�l�s�e�,� �e�r�r�o�r�:� �e�r�r�o�r�.�m�e�s�s�a�g�e� �}�)�;�
�
� � �}�
�
�}�)�;�
�
�
�
�a�p�p�.�l�i�s�t�e�n�(�3�0�0�0�)�;�
�
����
�
�
�
�#�#� �E�r�r�o�r� �H�a�n�d�l�i�n�g�
�
�
�
����t�y�p�e�s�c�r�i�p�t�
�
�t�r�y� �{�
�
� � �c�o�n�s�t� �r�e�s�p�o�n�s�e� �=� �a�w�a�i�t� �m�p�e�s�a�.�s�t�k�P�u�s�h�(�{�
�
� � � � �s�e�n�d�e�r�P�h�o�n�e�N�u�m�b�e�r�:� �'�0�7�1�2�3�4�5�6�7�8�'�,�
�
� � � � �a�m�o�u�n�t�:� �'�1�0�0�'�
�
� � �}�)�;�
�
�}� �c�a�t�c�h� �(�e�r�r�o�r�)� �{�
�
� � �i�f� �(�e�r�r�o�r�.�m�e�s�s�a�g�e�.�i�n�c�l�u�d�e�s�(�'�P�h�o�n�e� �m�u�s�t� �s�t�a�r�t� �w�i�t�h�'�)�)� �{�
�
� � � � �/�/� �I�n�v�a�l�i�d� �p�h�o�n�e� �f�o�r�m�a�t�
�
� � �}� �e�l�s�e� �i�f� �(�e�r�r�o�r�.�m�e�s�s�a�g�e� �=�=�=� �'�R�e�q�u�e�s�t� �t�i�m�e�o�u�t�'�)� �{�
�
� � � � �/�/� �R�e�q�u�e�s�t� �t�o�o�k� �t�o�o� �l�o�n�g�
�
� � �}� �e�l�s�e� �{�
�
� � � � �/�/� �O�t�h�e�r� �e�r�r�o�r�s�
�
� � � � �c�o�n�s�o�l�e�.�e�r�r�o�r�(�e�r�r�o�r�.�m�e�s�s�a�g�e�)�;�
�
� � �}�
�
�}�
�
����
�
�
�
�#�#� �T�y�p�e�S�c�r�i�p�t� �S�u�p�p�o�r�t�
�
�
�
�T�h�e� �l�i�b�r�a�r�y� �i�s� �f�u�l�l�y� �t�y�p�e�d�.� �I�m�p�o�r�t� �t�y�p�e�s� �a�s� �n�e�e�d�e�d�:�
�
�
�
����t�y�p�e�s�c�r�i�p�t�
�
�i�m�p�o�r�t� �t�y�p�e� �{�
�
� � �M�p�e�s�a�C�l�i�e�n�t�C�o�n�f�i�g�,�
�
� � �S�t�k�P�u�s�h�R�e�q�u�e�s�t�,�
�
� � �S�t�k�P�u�s�h�R�e�s�p�o�n�s�e�,�
�
� � �B�2�C�R�e�q�u�e�s�t�,�
�
� � �P�a�y�m�e�n�t�C�a�l�l�b�a�c�k�,�
�
� � �W�e�b�S�o�c�k�e�t�O�p�t�i�o�n�s�
�
�}� �f�r�o�m� �'�m�a�l�i�p�o�j�s�t�s�-�m�p�e�s�a�'�;�
�
����
�
�
�
�#�#� �B�r�o�w�s�e�r� �S�u�p�p�o�r�t�
�
�
�
�-� �M�o�d�e�r�n� �b�r�o�w�s�e�r�s� �w�i�t�h� �W�e�b�S�o�c�k�e�t� �s�u�p�p�o�r�t�
�
�-� �N�o�d�e�.�j�s� �1�8�+� �(�w�i�t�h� �n�a�t�i�v�e� �f�e�t�c�h� �s�u�p�p�o�r�t�)�
�
�-� �R�e�a�c�t�,� �V�u�e�,� �A�n�g�u�l�a�r�,� �a�n�d� �o�t�h�e�r� �f�r�a�m�e�w�o�r�k�s�
�
�-� �W�o�r�k�s� �w�i�t�h� �b�u�n�d�l�e�r�s� �l�i�k�e� �W�e�b�p�a�c�k�,� �V�i�t�e�,� �a�n�d� �R�o�l�l�u�p�
�
�
�
�#�#� �C�o�n�t�r�i�b�u�t�i�n�g�
�
�
�
�C�o�n�t�r�i�b�u�t�i�o�n�s� �a�r�e� �w�e�l�c�o�m�e�!� �P�l�e�a�s�e� �f�e�e�l� �f�r�e�e� �t�o� �s�u�b�m�i�t� �a� �P�u�l�l� �R�e�q�u�e�s�t�.�
�
�
�
�#�#� �L�i�c�e�n�s�e�
�
�
�
�M�I�T� �L�i�c�e�n�s�e� �-� �s�e�e� �t�h�e� �[�L�I�C�E�N�S�E�]�(�L�I�C�E�N�S�E�)� �f�i�l�e� �f�o�r� �d�e�t�a�i�l�s�.�
�
�
�
�#�#� �A�u�t�h�o�r�
�
�
�
�M�a�d�e�g�w�a� �K�i�d�i�i�
�
�
�
�#�#� �S�u�p�p�o�r�t�
�
�
�
�F�o�r� �i�s�s�u�e�s� �a�n�d� �q�u�e�s�t�i�o�n�s�:�
�
�-� �G�i�t�H�u�b� �I�s�s�u�e�s�:� �[�h�t�t�p�s�:�/�/�g�i�t�h�u�b�.�c�o�m�/�m�a�d�e�g�w�a�-�k�i�d�i�i�/�m�a�l�i�p�o�j�s�t�s�-�m�p�e�s�a�/�i�s�s�u�e�s�]�(�h�t�t�p�s�:�/�/�g�i�t�h�u�b�.�c�o�m�/�m�a�d�e�g�w�a�-�k�i�d�i�i�/�m�a�l�i�p�o�j�s�t�s�-�m�p�e�s�a�/�i�s�s�u�e�s�)�
�
�-� �D�o�c�u�m�e�n�t�a�t�i�o�n�:� �S�e�e� �e�x�a�m�p�l�e�s�.�m�d� �f�o�r� �m�o�r�e� �d�e�t�a�i�l�e�d� �e�x�a�m�p�l�e�s�
�
�
�
�#�#� �C�h�a�n�g�e�l�o�g�
�
�
�
�#�#�#� �0�.�0�.�2�
�
�-� �I�n�i�t�i�a�l� �r�e�l�e�a�s�e�
�
�-� �S�T�K� �P�u�s�h� �s�u�p�p�o�r�t�
�
�-� �B�2�C� �t�r�a�n�s�a�c�t�i�o�n� �s�u�p�p�o�r�t�
�
�-� �W�e�b�S�o�c�k�e�t� �r�e�a�l�-�t�i�m�e� �u�p�d�a�t�e�s�
�
�-� �A�u�t�o�m�a�t�i�c� �p�h�o�n�e� �n�u�m�b�e�r� �v�a�l�i�d�a�t�i�o�n�
�
�-� �T�y�p�e�S�c�r�i�p�t� �s�u�p�p�o�r�t�
