{"id":21823810,"url":"https://github.com/onel/mobilpy","last_synced_at":"2025-04-14T04:41:19.203Z","repository":{"id":57442520,"uuid":"164325590","full_name":"onel/mobilpy","owner":"onel","description":"Library that helps you interact with MobilPay (online payments processor)","archived":false,"fork":false,"pushed_at":"2019-12-18T09:55:07.000Z","size":13,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-27T18:50:04.951Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/onel.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-06T16:36:40.000Z","updated_at":"2019-12-18T09:55:09.000Z","dependencies_parsed_at":"2022-09-26T17:21:03.455Z","dependency_job_id":null,"html_url":"https://github.com/onel/mobilpy","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onel%2Fmobilpy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onel%2Fmobilpy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onel%2Fmobilpy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/onel%2Fmobilpy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/onel","download_url":"https://codeload.github.com/onel/mobilpy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248824655,"owners_count":21167343,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-27T17:38:01.793Z","updated_at":"2025-04-14T04:41:19.178Z","avatar_url":"https://github.com/onel.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"mobilPy\n=======\n\nmobilPy helps you with everything you need to implement\n`mobilPay \u003chttps://www.mobilpay.ro/public/en/\u003e`__'s online payment\nsolution. Steps: - create an account - get approved - create a merchant\n- download keys (private and public) - copy the signature (just a\nstring)\n\n*NOTE* You will have two private keys: for testing and production. The\npublic key is the same.\n\nInstall\n-------\n\nTo install the library, run:\n\n.. code:: sh\n\n    pip install mobilpy\n\nUsage\n-----\n\n.. code:: python\n\n    from mobilpy import Client\n\n    # the signature for your account\n    signature = 'DLAN-1R5V-19EN-XXXX-NFJA'\n    # the path to the public key\n    public_key = \"./sandbox.DLAN-1R5V-19EN-XXXX-NFJA.public.cer\"\n    # the private_key\n    private_key = \"./sandbox.DLAN-1R5V-19EN-XXXX-NFJA.private.key\"\n\n    client = Client(signature=signature, public_key=public_key, private_key=private_key)\n\n    # optional dict containing details about the customer\n    # if they are sent, the customer will have a short checkout by skipping the second step in the payment flow\n    billing_details = {\n        \"first_name\": \"\",\n        \"last_name\": \"\",\n        \"address\": \"\",\n        \"phone\": \"\",\n        \"email\": \"\"\n    }\n    # optional dict with details that you would need internally\n    # these are returned when the webhook is called\n    params = {\n        \"subscription_id\": \"\",\n        \"basket_id\": \"\",\n        etc.\n    }\n\n    options = {\n        \"order_id\": \"\" # int/string, max 64 length\n        \"currency\": \"RON\", # string, RON or other\n        \"amount\": 1, # float, between 0.10 and 99999\n        \"customer_id\": \"\", # int/string\n        \"details\": \"\",  # string, description for this transaction\n        \"billing\": billing_details, # dict, OPTIONAL\n        \"params\": params, # dict, OPTIONAL,\n        \n        # the webhook where the response from mobilPay will be sent\n        \"confirm_url\": \"\",\n        # the url where the user will be redirected\n        \"return_url\": \"\"\n    }\n    response = client.create_payment_data(**options)\n\nThe ``response`` is an dict that has two keys: ``env_key`` and ``data``.\nThese need to be used in the front end and make the request to mobilPay.\n\nFor example, the HTML might look like this:\n\n.. code:: html\n\n    \u003cform action=\"http://sandboxsecure.mobilpay.ro\" method=\"post\"\u003e\n        \u003cinput type=\"hidden\" name=\"env_key\" value=\"{{ env_key }}\"\u003e\n        \u003cinput type=\"hidden\" name=\"data\" value=\"{{ data }}\"\u003e\n        \n        \u003cinput type=\"submit\" value=\"Send\"\u003e\n    \u003c/form\u003e\n\nThe POST urls for the form are:\n\ntesting:\n  ``http://sandboxsecure.mobilpay.ro`` \nproduction:\n  ``https://secure.mobilpay.ro``\n\nWebhook\n-------\n\nmobilPay will make a ``POST`` request to the url you set as\n``confirm_url``. mobilPy has methods to help you parse it and offer a\nresponse.\n\n.. code:: python\n\n    post = # get the post data\n    env_key = post.get('env_key')\n    data = post.get('data')\n\n    client = Client(signature=signature, public_key=public_key, private_key=private_key)\n\n    request_xml = client.decrypt_message(env_key, data)\n    request_object = client.parse_webhook_request(request_xml)\n\n    # do some magic\n\nIn order to check if the transaction was successful you need to check\n``error_code`` AND ``action``:\n\n.. code:: python\n\n    transaction_successful = request_object.get('error_code') == '0' and request_object.get('action') == 'confirmed'\n    if transaction_successful:\n      # everything is ok\n\nCreating a response\n-------------------\n\nYou need to let mobilPay know if everything is ok on your end or if\nsomething weird happened. If everything is ok you can create a response\nlike this:\n\n.. code:: python\n\n    message = \"All good captain\"\n    response_xml = client.create_reponse(message=message)\n\nIf you had an error:\n\n.. code:: python\n\n    # message that will help you debug. it will appear in your dashboard\n    message = \"Everything is on fire\"\n    # this can be \"1\" (temporary error) or \"2\" (permanent error)\n    error_type = \"1\"\n    # your internal error code. a number maybe. OPTIONAL\n    error_code = ''\n    response_xml = client.create_reponse(message=message, error_type=error_type, error_code=error_code)\n\nThe response doesn't need to be encrypted. Just respond with the xml.\n\nCrediting\n---------\n\nIf a transaction was credited from the Dashboard, mobilPay will make a\nnew webhook ``POST``. You can check for that:\n\n.. code:: python\n\n    # if the transaction was credited from mobilpay\n    if request_object.get('action') == 'credit':\n      # do something\n      # return a reponse\n\nTODO\n====\n\nSome things that still need to be done:\n\n- tests\n- add support for: instalements, recurrence\n- maybe add prefilled credit card data payments?\n\n\nDisclaimer\n----------\nThis library is not associated in any way with mobilPay\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonel%2Fmobilpy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fonel%2Fmobilpy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonel%2Fmobilpy/lists"}