Categories: None [Edit]
payfast
# Payfast
Payfast is a Ruby gem that simplifies the process of integrating the PayFast payment gateway into your Ruby on Rails application. It provides a generator that helps scaffold the necessary configuration, routes, models, and controllers required to integrate PayFast seamlessly.
## Demo

## Installation
Add this line to your application's Gemfile:
```bash
bundle add payfast
```
## Usage
```bash
rails generate payfast:install
```
## This generator will perform the following actions:
insert config/routes.rb
create app/controllers/carts_controller.rb
create app/views/carts/index.html.erb
create app/views/carts/make_payment.html.erb
create app/helpers/carts_helper.rb
create db/migrate/20230824105530_create_carts.rb
create config/payfast.yml
create app/models/cart.rb
insert app/views/layouts/application.html.erb
insert config/environments/development.rb
## Additional configuration
Setup payfast credentials for your environment
rails EDITOR="code --wait" bin/rails credentials:edit
This will allow you to securely edit and store your credentials. once you save and exit the file, the credentials will be encrypted and can only be accessed withe rails master key.
payfast:
merchant_id: {your_merchant_id}
merchant_key: {your_merchant_key}
passphrase: {{your_passphrase}}
## Update your `payfast.yml` config file
- setup the credentials to be use by the rails app
- uncomment `Rails.application.credentials.payfast.merchant_id ` and wrap it in erb tags as instructed in the comments.
## Templates
Update the `make_payment.html.erb` as instructed in the file. it should look like so:
```js