payfast 1.0.5 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b5a6f5a5b16ce72d474b8b250b142131d6f216922159ea7356ba69a294fb1804
4
- data.tar.gz: 8c59abe214f2abccb269bc7281f29598aec666fa75cbac8ce8b25bfe9c06e1b8
3
+ metadata.gz: 7881858525522efec041474ecc6b4ee78bb427e75cc22fc2137638491c17f687
4
+ data.tar.gz: 2f391494ef6d8758c149ebed0b2cf955e2554abf5edde05bcb6774d6f8fbf4f2
5
5
  SHA512:
6
- metadata.gz: ed5e16433177c3c510b5a857e9944e54522b87d80b5070263e697ec68cacb342fba2434fb0b6866b790738a8b7b034daa2f59b0f86a1325e623ab89b518b92b1
7
- data.tar.gz: da9667701f2163b90e99da953cc32797142e5cec49f825d312e1e7950811e4b5f3ae35d14279c23155acf20442c5d265a631507868fe5707e59c5e17f196bce7
6
+ metadata.gz: bd69900dbb2bef5c308bbd3e6358008aed5462b7003340211f4d3fcc3471976f2f9ac0ad7de7e01588d9c12473053d545fe7924c8390f13df9c5f49616c260fb
7
+ data.tar.gz: 0bed2c849e943af30df1e9812e7e712464976a05fae61613559a043e384bfe943c861d62fcb2fe062211e3192e5927e606f50fd9b37fe9f0ab23f4b34c0a6a6c
data/README.md CHANGED
@@ -0,0 +1,129 @@
1
+ # Payfast
2
+
3
+ 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.
4
+
5
+ ## Demo
6
+ ![Peek 2023-08-24 12-15](https://github.com/mactunechy/payfast/assets/37017264/270cf0ab-d453-43ca-9a9a-8b8195dc6b8f)
7
+
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```bash
14
+ bundle add payfast
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ ```bash
20
+ rails generate payfast:install
21
+ ```
22
+
23
+ ## This generator will perform the following actions:
24
+
25
+ insert config/routes.rb
26
+ create app/controllers/carts_controller.rb
27
+ create app/views/carts/index.html.erb
28
+ create app/views/carts/make_payment.html.erb
29
+ create app/helpers/carts_helper.rb
30
+ create db/migrate/20230824105530_create_carts.rb
31
+ create config/payfast.yml
32
+ create app/models/cart.rb
33
+ insert app/views/layouts/application.html.erb
34
+ insert config/environments/development.rb
35
+
36
+
37
+
38
+ ## Additional configuration
39
+
40
+ Setup payfast credentials for your environment
41
+
42
+ rails EDITOR="code --wait" bin/rails credentials:edit
43
+
44
+ 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.
45
+
46
+ payfast:
47
+ merchant_id: {your_merchant_id}
48
+ merchant_key: {your_merchant_key}
49
+ passphrase: {{your_passphrase}}
50
+
51
+ ## Update your `payfast.yml` config file
52
+ - setup the credentials to be use by the rails app
53
+ - uncomment `Rails.application.credentials.payfast.merchant_id ` and wrap it in erb tags as instructed in the comments.
54
+
55
+
56
+ ## Templates
57
+ Update the `make_payment.html.erb` as instructed in the file. it should look like so:
58
+
59
+ ```js
60
+ <script>
61
+ // set the uuid to uuid = @cart.payment_uid. surround @carts.payment_uid with erb tags
62
+ const uuid = `<%= @cart.payment_uuid %>`
63
+ window.payfast_do_onsite_payment({uuid}, function (result) {
64
+ if (result === true) {
65
+ // redirect success_path(@cart)
66
+ window.location.href = `<%= success_cart_path(@cart) %>`
67
+ }
68
+ else {
69
+ // Redirect to failure_path(@cart)
70
+ window.location.href = `<%= failure_cart_path(@cart) %>`
71
+ }
72
+ });
73
+ </script>
74
+ ```
75
+
76
+ ## Testing
77
+ - payfast api allows only SSL communication from your server. inorder to test locally. you will have to use a tunneling service that allows you to expose your local development server to the internet.
78
+
79
+ your rails development config has was modified by the generator to allow ngrok hosts to hit your rails server
80
+
81
+ ```ruby
82
+ config.hosts << /[a-z0-9-]+\.ngrok-free\.app/
83
+ ```
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+ ## Contributing
92
+
93
+ Thank you for considering contributing to our project! We welcome contributions from the community to help improve this project and make it better for everyone.
94
+
95
+ ### Issues
96
+
97
+ If you encounter any issues or bugs while using our project, please [open a new issue](https://github.com/mactunechy/payfast/issues) on GitHub. Please make sure to include detailed information about the problem, steps to reproduce it, and the environment in which you encountered it.
98
+
99
+ ### Pull Requests
100
+
101
+ We encourage pull requests from the community! If you have an improvement or new feature you'd like to contribute, please follow these steps:
102
+
103
+ 1. Fork the repository and create a new branch for your feature or bug fix.
104
+ 2. Make your changes and write tests to cover any new functionality.
105
+ 3. Ensure that the existing tests pass and write additional tests for any bug fixes.
106
+ 4. Commit your changes and push the new branch to your forked repository.
107
+ 5. Submit a pull request to our main repository, including a detailed description of the changes you made and any relevant information.
108
+
109
+ We will review your pull request as soon as possible and provide feedback if needed. We value your contributions and will work with you to ensure your changes are integrated smoothly.
110
+ d
111
+
112
+ Your contributions are essential to the success of this project, and we are grateful for your help in making it better for everyone. If you have any questions or need further assistance, feel free to reach out to us.
113
+
114
+ Happy coding!
115
+
116
+
117
+
118
+
119
+
120
+
121
+
122
+
123
+
124
+
125
+
126
+
127
+
128
+
129
+
@@ -1,17 +1,16 @@
1
- require "net/http"
2
- require "uri"
1
+ require 'net/http'
2
+ require 'uri'
3
3
 
4
4
  module Payfast
5
+ # Encaspulates the utils for makeing payfast payments using their onsite feature
5
6
  class OnsitePayments
6
7
  def self.generate_signature(payload)
7
8
  passphrase = Rails.application.config_for(:payfast).passphrase
8
9
 
9
- if passphrase
10
- payload[:passphrase] = passphrase
11
- end
10
+ payload[:passphrase] = passphrase if passphrase
12
11
 
13
12
  url_encoded = data_to_string(payload)
14
- create_hash(url_encoded, "md5")
13
+ create_hash(url_encoded, 'md5')
15
14
  end
16
15
 
17
16
  def self.requestPayment(payload)
@@ -20,7 +19,7 @@ module Payfast
20
19
  merchant_key: Rails.application.config_for(:payfast).merchant_key,
21
20
  return_url: Rails.application.config_for(:payfast).return_url,
22
21
  cancel_url: Rails.application.config_for(:payfast).cancel_url,
23
- notify_url: Rails.application.config_for(:payfast).notify_url,
22
+ notify_url: Rails.application.config_for(:payfast).notify_url
24
23
  }.merge(payload)
25
24
 
26
25
  puts payload_with_config
@@ -35,7 +34,7 @@ module Payfast
35
34
 
36
35
  uri = URI.parse(base_url)
37
36
  http = Net::HTTP.new(uri.host, uri.port)
38
- http.use_ssl = true if uri.scheme == "https"
37
+ http.use_ssl = true if uri.scheme == 'https'
39
38
 
40
39
  request = Net::HTTP::Post.new(uri.path)
41
40
  request.body = pf_param_string
@@ -45,12 +44,10 @@ module Payfast
45
44
  JSON.parse(response.body)
46
45
  rescue StandardError => e
47
46
  puts "Error: #{e.message}"
48
- return false
47
+ false
49
48
  end
50
49
  end
51
50
 
52
- private
53
-
54
51
  def self.data_to_string(payload)
55
52
  URI.encode_www_form(payload)
56
53
  end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Payfast
4
+ VERSION = '1.0.7'
5
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: payfast
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dellan Muchengapadare
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-24 00:00:00.000000000 Z
11
+ date: 2024-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,7 +52,56 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 7.0.7
55
- description: ''
55
+ description: "# Payfast\n\nPayfast is a Ruby gem that simplifies the process of integrating
56
+ the PayFast payment gateway into your Ruby on Rails application. It provides a generator
57
+ that helps scaffold the necessary configuration, routes, models, and controllers
58
+ required to integrate PayFast seamlessly.\n\n## Demo \n![Peek 2023-08-24 12-15](https://github.com/mactunechy/payfast/assets/37017264/270cf0ab-d453-43ca-9a9a-8b8195dc6b8f)\n\n\n##
59
+ Installation\n\nAdd this line to your application's Gemfile:\n\n```bash\n bundle
60
+ add payfast\n```\n\n## Usage\n\n```bash\n rails generate payfast:install\n```\n\n##
61
+ This generator will perform the following actions:\n\n insert config/routes.rb\n
62
+ \ create app/controllers/carts_controller.rb\n create app/views/carts/index.html.erb\n
63
+ \ create app/views/carts/make_payment.html.erb\n create app/helpers/carts_helper.rb\n
64
+ \ create db/migrate/20230824105530_create_carts.rb\n create config/payfast.yml\n
65
+ \ create app/models/cart.rb\n insert app/views/layouts/application.html.erb\n
66
+ \ insert config/environments/development.rb\n\n\n\n## Additional configuration\n\nSetup
67
+ payfast credentials for your environment\n\n rails EDITOR=\"code --wait\" bin/rails
68
+ credentials:edit\n \n This will allow you to securely edit and store your credentials.
69
+ once you save and exit the file, the credentials will be encrypted and can only
70
+ be accessed withe rails master key.\n\n payfast: \n merchant_id: {your_merchant_id}\n
71
+ \ merchant_key: {your_merchant_key}\n passphrase: {{your_passphrase}}\n\n##
72
+ Update your `payfast.yml` config file\n- setup the credentials to be use by the
73
+ rails app\n- uncomment `Rails.application.credentials.payfast.merchant_id ` and
74
+ wrap it in erb tags as instructed in the comments.\n\n\n## Templates\n Update the
75
+ `make_payment.html.erb` as instructed in the file. it should look like so:\n\n```js\n<script>\n//
76
+ set the uuid to uuid = @cart.payment_uid. surround @carts.payment_uid with erb
77
+ tags\nconst uuid = `<%= @cart.payment_uuid %>`\nwindow.payfast_do_onsite_payment({uuid},
78
+ function (result) {\n if (result === true) {\n // redirect success_path(@cart)\n
79
+ \ window.location.href = `<%= success_cart_path(@cart) %>`\n }\n else {\n //
80
+ Redirect to failure_path(@cart)\n window.location.href = `<%= failure_cart_path(@cart)
81
+ %>`\n }\n});\n</script>\n```\n\n## Testing\n- payfast api allows only SSL communication
82
+ from your server. inorder to test locally. you will have to use a tunneling service
83
+ that allows you to expose your local development server to the internet. \n\nyour
84
+ rails development config has was modified by the generator to allow ngrok hosts
85
+ to hit your rails server\n\n```ruby\n config.hosts << /[a-z0-9-]+\\.ngrok-free\\.app/\n```\n\n\n\n\n\n\n\n##
86
+ Contributing\n\nThank you for considering contributing to our project! We welcome
87
+ contributions from the community to help improve this project and make it better
88
+ for everyone.\n\n### Issues\n\nIf you encounter any issues or bugs while using our
89
+ project, please [open a new issue](https://github.com/mactunechy/payfast/issues)
90
+ on GitHub. Please make sure to include detailed information about the problem, steps
91
+ to reproduce it, and the environment in which you encountered it.\n\n### Pull Requests\n\nWe
92
+ encourage pull requests from the community! If you have an improvement or new feature
93
+ you'd like to contribute, please follow these steps:\n\n1. Fork the repository and
94
+ create a new branch for your feature or bug fix.\n2. Make your changes and write
95
+ tests to cover any new functionality.\n3. Ensure that the existing tests pass and
96
+ write additional tests for any bug fixes.\n4. Commit your changes and push the new
97
+ branch to your forked repository.\n5. Submit a pull request to our main repository,
98
+ including a detailed description of the changes you made and any relevant information.\n\nWe
99
+ will review your pull request as soon as possible and provide feedback if needed.
100
+ We value your contributions and will work with you to ensure your changes are integrated
101
+ smoothly.\nd\n\nYour contributions are essential to the success of this project,
102
+ and we are grateful for your help in making it better for everyone. If you have
103
+ any questions or need further assistance, feel free to reach out to us.\n\nHappy
104
+ coding!\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
56
105
  email: mactunechy@gmail.com
57
106
  executables: []
58
107
  extensions: []
@@ -70,11 +119,12 @@ files:
70
119
  - lib/generators/payfast/templates/model.rb
71
120
  - lib/generators/payfast/templates/routes.rb
72
121
  - lib/payfast/onsite_payments.rb
73
- homepage: https://github.com/mactunechy/payfast-gem
122
+ - lib/payfast/version.rb
123
+ homepage: https://github.com/mactunechy/payfast
74
124
  licenses:
75
125
  - MIT
76
126
  metadata: {}
77
- post_install_message:
127
+ post_install_message:
78
128
  rdoc_options: []
79
129
  require_paths:
80
130
  - lib
@@ -82,15 +132,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
82
132
  requirements:
83
133
  - - ">="
84
134
  - !ruby/object:Gem::Version
85
- version: '0'
135
+ version: 2.7.0
86
136
  required_rubygems_version: !ruby/object:Gem::Requirement
87
137
  requirements:
88
138
  - - ">="
89
139
  - !ruby/object:Gem::Version
90
140
  version: '0'
91
141
  requirements: []
92
- rubygems_version: 3.3.26
93
- signing_key:
142
+ rubygems_version: 3.3.27
143
+ signing_key:
94
144
  specification_version: 4
95
145
  summary: A light weight gem to setup payfast payment gateway
96
146
  test_files: []