{"id":37056356,"url":"https://github.com/xshaheen/xdot-paymob","last_synced_at":"2026-01-14T06:21:59.857Z","repository":{"id":37854374,"uuid":"394913852","full_name":"xshaheen/xdot-paymob","owner":"xshaheen","description":".NET SDK to help you integrate with the Paymob’s payment gateway.","archived":false,"fork":false,"pushed_at":"2025-03-17T16:53:52.000Z","size":297,"stargazers_count":31,"open_issues_count":15,"forks_count":6,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-24T01:35:49.144Z","etag":null,"topics":["csharp","dotnet","dotnet-core","payment"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xshaheen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null}},"created_at":"2021-08-11T08:10:09.000Z","updated_at":"2025-08-25T17:00:11.000Z","dependencies_parsed_at":"2023-02-08T19:31:11.093Z","dependency_job_id":"ab5fc284-fbbd-46ab-9ddb-99f7dde8414a","html_url":"https://github.com/xshaheen/xdot-paymob","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/xshaheen/xdot-paymob","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xshaheen%2Fxdot-paymob","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xshaheen%2Fxdot-paymob/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xshaheen%2Fxdot-paymob/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xshaheen%2Fxdot-paymob/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xshaheen","download_url":"https://codeload.github.com/xshaheen/xdot-paymob/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xshaheen%2Fxdot-paymob/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28412206,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T05:26:33.345Z","status":"ssl_error","status_checked_at":"2026-01-14T05:21:57.251Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["csharp","dotnet","dotnet-core","payment"],"created_at":"2026-01-14T06:21:59.778Z","updated_at":"2026-01-14T06:21:59.839Z","avatar_url":"https://github.com/xshaheen.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Xdot.Paymob\n\n[![GitHub Actions Status](https://github.com/xshaheen/xdot-paymob/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/xshaheen/xdot-paymob/actions) [![xdot-paymob NuGet Package Downloads](https://img.shields.io/nuget/dt/Xdot.Paymob.CashIn)](https://www.nuget.org/packages/Xdot.Paymob.CashIn)\n\n.NET SDK to help you integrate with the Paymob’s payment gateway. to help you integrate with the Paymob’s payment gateway.\n\n**if you like this work, please consider give the project star 🌟**\n\n## Features\n\n- Supporting .NET Standard 2.0+, .NET 5+, .NET Core 2.0+, and .NET Framework 4.6.1+.\n- Automatic retries - The library automatically retries requests on intermittent failures.\n- Manage authentication tokens - The library manage authenticate (using the configured ApiKey), token caching and invalidation. \n  so you don't need to provide it for each request and the library provide it in each request need it for you.\n- You can access the full response property.\n- Handle API DateTime responses correctly - all responses use `DateTimeOffset`.\n- Ability to swap the configuration (API key, hmac, ...) during runtime.\n\n## Installation\n\nUsing the [.NET CLI tools][dotnet-core-cli-tools]:\n\n```sh\ndotnet add package Xdot.Paymob.CashIn.DependencyInjection\n```\n\nUsing the [NuGet CLI][nuget-cli]:\n\n```sh\nnuget install Xdot.Paymob.CashIn.DependencyInjection\n```\n\nUsing the [Package Manager Console][package-manager-console]:\n\n```powershell\nInstall-Package Xdot.Paymob.CashIn.DependencyInjection\n```\n\n## Usage\n\n### Configuration Dependency Injection\n\nConfigure the library in `Startup.cs` with these helper methods. This will inject `IPaymobCashInBroker` (used to call\nthe Paymob API),\n`IPaymobCashInAuthenticator` (used to authenticate and manage authentication token), and configure options.\n\n```c#\nservices.AddPaymobCashIn(config =\u003e {\n    config.ApiKey = \"Api Key for your Paymob’s accont\";\n    config.Hmac = \"Hmac secret for your Paymob’s accont\",\n});\n\n// Alert: ApiKey and Hmac is a sensitive settings make sure to store them into\n// a secret manager (Azure key vault for example).\n// DON'T STORE SECRETS IN CODE\n```\n\n- If you don't use Microsoft DI, Use the base package [Xdot.Paymob.CashIn][cash-in-package] and configure your DI to the\n  equivalent to [this configuration][di-config-ref].\n\n---\n\n- Then you can inject `IPaymobCashInBroker` to your service and use to to call the Paymob API.\n\nHere's the details of what the `IPaymobCashInBroker` has to offer:\n\n| Method                       | Description                                                                                                                          |\n| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |\n| CreateOrderAsync             | See: https://docs.paymob.com/docs/accept-standard-redirect#2-order-registration-api                                                  |\n| RequestPaymentKeyAsync       | See: https://docs.paymob.com/docs/accept-standard-redirect#3-payment-key-request                                                     |\n| CreateWalletPayAsync         | See: https://docs.paymob.com/docs/mobile-wallets#pay-request                                                                         |\n| CreateKioskPayAsync          | See: https://docs.paymob.com/docs/kiosk-payments                                                                                     |\n| CreateCashCollectionPayAsync | See: https://docs.paymob.com/docs/cash-collection                                                                                    |\n| CreateSavedTokenPayAsync     | See: https://docs.paymob.com/docs/pay-with-saved-token                                                                               |\n| GetTransactionAsync          | Get transaction by id.                                                                                                               |\n| GetTransactionsPageAsync     | Get transactions page.                                                                                                               |\n| GetOrderAsync                | Get an order by id.                                                                                                                  |\n| GetOrdersPageAsync           | Get orders page.                                                                                                                     |\n| CreateIframeSrc              | Helper method to create iframe src url                                                                                               |\n| Validate                     | Helper method to verify callback content with your hmac secret see: https://docs.paymob.com/docs/transaction-webhooks#hmac-authentication |\n\n### Simple Example\n\n- Create a payment\n\n```c#\npublic class CashInService\n{\n    private readonly IPaymobCashInBroker _broker;\n\n    public CashInService(IPaymobCashInBroker broker)\n    {\n        _broker = broker;\n    }\n\n    public async Task\u003cstring\u003e RequestCardPaymentKey()\n    {\n        // Create order.\n        var amountCents = 1000; // 10 LE\n        var orderRequest = CashInCreateOrderRequest.CreateOrder(amountCents);\n        var orderResponse = await _broker.CreateOrderAsync(orderRequest);\n\n        // Request card payment key.\n        var billingData = new CashInBillingData(\n            firstName: \"Mahmoud\",\n            lastName: \"Shaheen\",\n            phoneNumber: \"010000000\",\n            email: \"someone@gmail.com\");\n\n        var paymentKeyRequest = new CashInPaymentKeyRequest(\n            integrationId: 123, // change this\n            orderId: orderResponse.Id,\n            billingData: billingData,\n            amountCents: amountCents);\n\n        var paymentKeyResponse = await _broker.RequestPaymentKeyAsync(paymentKeyRequest);\n\n        // Create iframe src.\n        return _broker.CreateIframeSrc(iframeId: \"1234\", token: paymentKeyResponse.PaymentKey);\n    }\n}\n```\n\n- Define the callback\n\n```c#\nprivate static readonly JsonSerializerOptions SerializerOptions = new(JsonSerializerDefaults.Web)\n{\n    NumberHandling = JsonNumberHandling.AllowReadingFromString,\n};\n\n[HttpPost(\"cashin-callback\")]\npublic ActionResult CashInCallback(\n    [FromQuery] string hmac,\n    [FromBody] CashInCallback callback,\n    IPaymobCashInBroker broker\n)\n{\n    if (callback.Type is null || callback.Obj is null)\n    {\n        throw new InvalidOperationException(\"Unexpected transaction callback.\");\n    }\n\n    var content = ((JsonElement) callback.Obj).GetRawText();\n\n    switch (callback.Type.ToUpperInvariant())\n    {\n        case CashInCallbackTypes.Transaction:\n        {\n            var transaction = JsonSerializer.Deserialize\u003cCashInCallbackTransaction\u003e(content, SerializerOptions)!;\n            var valid = broker.Validate(transaction, hmac);\n\n            if (!valid)\n            {\n                return BadRequest();\n            }\n\n            // TODO: Handle transaction.\n\n            return Ok();\n        }\n        case CashInCallbackTypes.Token:\n        {\n            var token = JsonSerializer.Deserialize\u003cCashInCallbackToken\u003e(content, SerializerOptions)!;\n            var valid = broker.Validate(token, hmac);\n\n            if (!valid)\n            {\n                return BadRequest();\n            }\n\n            // TODO: Handle token.\n\n            return Ok();\n        }\n        default:\n            throw new InvalidOperationException($\"Unexpected {nameof(CashInCallbackTypes)} = {callback.Type}\");\n    }\n}\n```\n\n## License\n\nThis project is licensed under the Apache 2.0 license.\n\n## Contact\n\nIf you have any suggestions, comments or questions, please feel free to contact me on:\n\nEmail: mxshaheen@gmail.com\n\n[cash-in-package]: https://www.nuget.org/packages/Xdot.Paymob.CashIn/\n[dotnet-core-cli-tools]: https://docs.microsoft.com/en-us/dotnet/core/tools/\n[nuget-cli]: https://docs.microsoft.com/en-us/nuget/tools/nuget-exe-cli-reference\n[package-manager-console]: https://docs.microsoft.com/en-us/nuget/tools/package-manager-console\n[di-config-ref]: https://github.com/xshaheen/xdot-paymob/blob/main/src/CashIn.DependencyInjection/ServiceCollectionExtensions.cs#L58\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxshaheen%2Fxdot-paymob","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxshaheen%2Fxdot-paymob","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxshaheen%2Fxdot-paymob/lists"}