{"id":15561144,"url":"https://github.com/zfhassaan/payfast","last_synced_at":"2025-04-23T21:49:56.491Z","repository":{"id":61864387,"uuid":"555891084","full_name":"zfhassaan/payfast","owner":"zfhassaan","description":"Integrate Payfast payments into your Laravel 9 \u0026 10 app with ease using this PHP 8.0 compatible package on Github. Fast and secure checkout! #Payfast #Laravel9 #PHP8 #Github","archived":false,"fork":false,"pushed_at":"2024-08-08T12:57:40.000Z","size":136,"stargazers_count":5,"open_issues_count":2,"forks_count":6,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-23T21:49:38.910Z","etag":null,"topics":["laravel","laravel-framework","pakistan","payfast","payment","payment-gateway","payments","transaction"],"latest_commit_sha":null,"homepage":"https://github.com/zfhassaan/payfast","language":"PHP","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/zfhassaan.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-22T15:21:47.000Z","updated_at":"2025-01-13T16:31:08.000Z","dependencies_parsed_at":"2024-02-12T05:23:40.762Z","dependency_job_id":"82720d90-f47f-4879-b87e-7fe1d4c91912","html_url":"https://github.com/zfhassaan/payfast","commit_stats":{"total_commits":22,"total_committers":2,"mean_commits":11.0,"dds":0.09090909090909094,"last_synced_commit":"3c2f7a0f7e2d98b5f2b290b80c31d637581e0ebe"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zfhassaan%2Fpayfast","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zfhassaan%2Fpayfast/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zfhassaan%2Fpayfast/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zfhassaan%2Fpayfast/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zfhassaan","download_url":"https://codeload.github.com/zfhassaan/payfast/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250522293,"owners_count":21444510,"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":["laravel","laravel-framework","pakistan","payfast","payment","payment-gateway","payments","transaction"],"created_at":"2024-10-02T16:05:44.744Z","updated_at":"2025-04-23T21:49:56.472Z","avatar_url":"https://github.com/zfhassaan.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"logo.png\" alt=\"PayFast Payment Gateway\" width=\"300\"/\u003e\u003cbr/\u003e\n  \u003c!-- \u003ch3 align=\"center\"\u003ePayfast\u003c/h3\u003e --\u003e\n\u003c/p\u003e\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/zfhassaan/Payfast.svg?style=flat-square)](https://packagist.org/packages/zfhassaan/payfast)\n[![MIT Licensed](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)\n[![Total Downloads](https://img.shields.io/packagist/dt/zfhassaan/Payfast.svg?style=flat-square)](https://packagist.org/packages/zfhassaan/payfast)\n[![Hits](https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Fzfhassaan%2Fpayfast\u0026count_bg=%2379C83D\u0026title_bg=%23555555\u0026icon=webmoney.svg\u0026icon_color=%23E7E7E7\u0026title=Hits\u0026edge_flat=false)](https://hits.seeyoufarm.com)\n\n\u003ch4\u003e Disclaimer \u003c/h4\u003e\nThis is unofficial Payfast API Payment Gateway. This repository  is only created to help developers in streamlining the integration process. You can Review the Official Payment Gateway \u003ca href=\"https://gopayfast.com/docs/#preface\" \u003ehere.\u003c/a\u003e \n\nThis Package only covers direct checkout and hosted checkout process. There's no Subscription option enabled yet it'll be added in the next build.\n\n\n#### About\nThis document contains detailed explanation about how to integrate with Payfast API's Based transactions functionality. This document also contains the details for online transaction. \n\u003csmall\u003ev1.0.0\u003c/small\u003e\n\n#### Intended Audience \nThis document is for merchants acquires and developers who want to integrate with Payfast to perform a API's based Transaction. \n\n#### Integration Scope\nThe merchant will implement all ecommerce functionality. PayFast service (PayFast) will be used only payment processing. \n\n#### API End Points\nThis section contains the details of all APIs provided by Payfast. These APIs could be called by the merchants, acquirers and/or aggregators. These APIs are based on REST architecture and serve standard HTTP codes for the response payload. \n\n#### Integration Prerequisites\nMerchants will be registered on PayFast prior to integration. After merchant sign up for PayFast account, following two unique values will be provided to merchant to operate: *Merchant_ID* and *Secured_key* , these keys are used to get a one-time authentication token, which is used to authenticate payment requests to the \"PayFast\"payment gateway.\n\n#### Installation\nYou can install the package via composer \n\n````\ncomposer require zfhassaan/payfast\n````\n\n#### Set .env configurations\n\n```\nPAYFAST_API_URL=\nPAYFAST_SANDBOX_URL=\nPAYFAST_GRANT_TYPE=\nPAYFAST_MERCHANT_ID=\nPAYFAST_MODE=\nPAYFAST_SECURED_KEY=\nPAYFAST_RETURN_URL=\n```\n\n#### configuration\nAdd These files in `app/config.php`\n\n```php \n  /*\n    * Package Service Providers...\n    */\n\n  \\zfhassaan\\Payfast\\PayfastServiceProvider::class,\n```\n\n\nand also in alias in `app/config.php`\n\n```php \n  'aliases' =\u003e Facade::defaultAliases()-\u003emerge([\n        'Payfast' =\u003e \\zfhassaan\\Payfast\\Payfastfacade::class,\n    ])-\u003etoArray(),\n```\n\n#### Steps\n##### Direct Checkout\n1. Get Authentication Token\n2. Validate Customer Information.\n3. Initiate Transaction\n\n##### Hosted Checkout\n1. Get Authentication Token\n2. Initiate Transaction on Payfast Page.\n\nThe Direct Checkout and Hosted checkout credentials can be obtained from \u003ca href=\"https://gopayfast.com/\"\u003ePayfast\u003c/a\u003e The following are direct checkout methods that can be used with PCIDSS certified websites. You can read more about how to initiate Hosted checkout on \u003ca href=\"https://github.com/zfhassaan/payfast/wiki/Understanding-the-Hosted-Checkout-Process-for-Payfast\"\u003ethis\u003c/a\u003e wiki page\n\n##### What is PCI DSS Certified.\nPCI certification ensures the security of card data at your business through a set of requirements established by the PCI SSC. These include a number of commonly known best practices, such as: Installation of firewalls. Encryption of data transmissions, use of anti-virus software. In addition businesses must restrict access to cardholder data and monitor access to network resources.\n\nPCI-compliant security provides a valuable asset that informs customers that your business is safe to transact with. Conversely, the cost of noncompliance, both in monetary and reputational terms, should be enough to convince any business owner to take data security seriously.\n\nA data breach that reveals sensitive customer information is likely to have severe repercussions on an enterprise. A breach may result in fines from payment card issuers, lawsuits, diminished sales and a severely damaged reputation.\n\nAfter experiencing a breach, a business may have to cease accepting credit card transactions or be forced to pay higher subsequent charges than the initial cost of security compliance. The investment in PCI security procedures goes a long way toward ensuring that other aspects of your commerce are safe from malicious online actors.\n\n##### Hosted Checkout \nThe Hosted checkout requires to follow following steps;\n1. Get Authentication Token from Payfast\n2. Create signature with md5 standard `md5($merchant_id.':' . $merchant_name.':'.$amount.':'.$order_id)`\n3. Create Payload for website. The website payload will look something like this: \n\n```php \n...\n...\n$backend_callback = \"signature=\".$signature.\"\u0026order_id=\".$order_id;\n...\n...\n$payload = array(\n            'MERCHANT_ID' =\u003e $merchant_id, // Merchant ID received from Payfast\n            'MERCHANT_NAME' =\u003e $merchant_name, // Merchant Name registered with Payfast.\n            'TOKEN' =\u003e $ACCESS_TOKEN, // Access Token received from Payfast.\n            'PROCCODE' =\u003e 00, // status code default is 00\n            'TXNAMT' =\u003e $amount, // Transaction Amount or total amount\n            'CUSTOMER_MOBILE_NO' =\u003e $mobile, // Customer Mobile Number\n            'CUSTOMER_EMAIL_ADDRESS' =\u003e $email, // Customer Email address\n            'SIGNATURE' =\u003e $signature, // Signature as described in above step 2.\n            'VERSION' =\u003e 'WOOCOM-APPS-PAYMENT-0.9', // Optional\n            'TXNDESC' =\u003e 'Products purchased from ' .$merchant_name, // Transaction Description to show on website\n            'SUCCESS_URL' =\u003e urlencode($successUrl), // Success URL where to redirect user after success\n            'FAILURE_URL' =\u003e urlencode($failUrl), // Failure URL where to redirect user after failure\n            'BASKET_ID' =\u003e $order_id, // Order ID from Checkout Page.\n            'ORDER_DATE' =\u003e date('Y-m-d H:i:s', time()), // Order Date \n            'CHECKOUT_URL' =\u003e urlencode($backend_callback), // Encrypted Checkout URL\n        );\n\t\t\n\n```\n\n4. Submit it on Payfast provided URL. \n#### Usage \n\n```php \nuse zfhassaan\\Payfast\\Payfast;\n...\n...\n\n/**\n * Validate Customer and get OTP Screen.\n * Step 1\n */\npublic function checkout(Request $request) {\n  $payfast = new Payfast();\n  $response = $payfast-\u003egetToken();\n  if($response != null \u0026\u0026 $response-\u003ecode == \"00\" ){\n      $payfast-\u003esetAuthToken($response-\u003etoken);\n  } else {\n      abort(403, 'Error: Auth Token Not Generated.');\n  }\n  $show_otp = $payfast-\u003ecustomer_validate($request-\u003eall());\n  return $show_otp;\n}\n\n/**\n * Receive 3ds PaRes from Callback. \n * This will be called on Callback from OTP Screen.\n * You can Show Proceed to Payment Screen or Complete Transaction Screen.\n * Step 2\n */\npublic function callback(Request $request) {\n    return response()-\u003ejson($request-\u003eall());\n}\n\n/**\n * Send a request again with Required Params and complete the transaction\n * Proceed to Payment and complete Transaction\n * Step 3 \n */\npublic function proceed(Request $request) {\n  $payfast = new Payfast();\n  $response = $payfast-\u003einitiate_transaction($request);\n  return $response;\n}\n\n\n/**\n * Mobile Wallet Account Initiate Transaction \n * This is demo function for Easy Paisa. \n * \n */\n\npublic function payfast(Request $request)\n{\n    $payfast = new Payfast();\n    $response = $payfast-\u003egetToken();\n    if($response != null \u0026\u0026 $response-\u003ecode == \"00\" ){\n        $payfast-\u003esetAuthToken($response-\u003etoken);\n    } else {\n        abort(403, 'Error: Auth Token Not Generated.');\n    }\n    $show_otp = $payfast-\u003ewallet($request-\u003eall());\n    return $show_otp;\n}\n\n\n```\n\n#### Changelog\nPlease see Changelog for more information what has changed recently. \n\n#### Security \nThe following lines are taken from [briandk](https://gist.github.com/briandk/3d2e8b3ec8daf5a27a62) repository for contributing in an open source projects.\n\n**Great Bug Reports** tend to have:\n\n- A quick summary and/or background\n- Steps to reproduce\n  - Be specific!\n  - Give sample code if you can. An issue includes sample code that *anyone* with a base R setup can run to reproduce what I was seeing\n- What you expected would happen\n- What actually happens\n- Notes (possibly including why you think this might be happening, or stuff you tried that didn't work)\n\n\n#### License\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzfhassaan%2Fpayfast","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzfhassaan%2Fpayfast","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzfhassaan%2Fpayfast/lists"}