payfast 1.0.2 → 1.0.5

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: 3a4574ba86a681658b8f23c60ffd4139e6d59d6abc5017a78042f05b302624e4
4
- data.tar.gz: 47ed239d23fcd5966db19cefdb119ad8b0366e61dfed31c21d80ad848508f4e9
3
+ metadata.gz: b5a6f5a5b16ce72d474b8b250b142131d6f216922159ea7356ba69a294fb1804
4
+ data.tar.gz: 8c59abe214f2abccb269bc7281f29598aec666fa75cbac8ce8b25bfe9c06e1b8
5
5
  SHA512:
6
- metadata.gz: 3398d67e68303c866e80d60bafe730ee3093d9bddb18ab499d0f50017dc5fb3300ac512597fc7f8d49d73b1cbfdd74c362f881778d314e4845ddc47eb8727661
7
- data.tar.gz: ab136a269460fb4d03de079ea2195a5aa9be3d5bea253c3046f948da648ef2e7992b2aa6849a9ddd4832d9d6a8b5c75477834c2cdf0b448a05c049a0446c2847
6
+ metadata.gz: ed5e16433177c3c510b5a857e9944e54522b87d80b5070263e697ec68cacb342fba2434fb0b6866b790738a8b7b034daa2f59b0f86a1325e623ab89b518b92b1
7
+ data.tar.gz: da9667701f2163b90e99da953cc32797142e5cec49f825d312e1e7950811e4b5f3ae35d14279c23155acf20442c5d265a631507868fe5707e59c5e17f196bce7
@@ -1,54 +1,71 @@
1
1
  require "rails/generators"
2
2
 
3
3
  module Payfast
4
- class InstallGenerator < Rails::Generators::Base
5
- source_root File.expand_path("templates", __dir__)
4
+ module Generators
5
+ class InstallGenerator < Rails::Generators::Base
6
+ source_root File.expand_path("templates", __dir__)
6
7
 
7
- def modify_routes
8
- insert_into_file "config/routes.rb", after: "Rails.application.routes.draw do\n" do
9
- # Read and insert the contents of your routes template file
10
- File.read(File.join(__dir__, "templates", "routes.rb"))
8
+ def modify_routes
9
+ insert_into_file "config/routes.rb", after: "Rails.application.routes.draw do\n" do
10
+ # Read and insert the contents of your routes template file
11
+ File.read(File.join(__dir__, "templates", "routes.rb"))
12
+ end
11
13
  end
12
- end
13
14
 
14
- def create_controller
15
- template "controller.rb", File.join("app/controllers", "#{controller_file_name}_controller.rb")
16
- end
15
+ def create_controller
16
+ template "controller.rb", File.join("app/controllers", "#{controller_file_name}_controller.rb")
17
+ end
17
18
 
18
- def create_views
19
- actions.each do |action|
20
- template "#{action}.html.erb", File.join("app/views", controller_file_name, "#{action}.html.erb")
19
+ def create_views
20
+ actions.each do |action|
21
+ template "#{action}.html.erb", File.join("app/views", controller_file_name, "#{action}.html.erb")
22
+ end
21
23
  end
22
- end
23
24
 
24
- def create_view_helper
25
- template "helper.rb", "app/helpers/carts_helper.rb"
26
- end
25
+ def create_view_helper
26
+ template "helper.rb", "app/helpers/carts_helper.rb"
27
+ end
27
28
 
28
- def create_migration
29
- template "migration.rb", "db/migrate/#{timestamp}_create_carts.rb"
30
- end
29
+ def create_migration
30
+ template "migration.rb", "db/migrate/#{timestamp}_create_carts.rb"
31
+ end
31
32
 
32
- def create_config_file
33
- template "config.yml", "config/payfast.yml"
34
- end
33
+ def create_config_file
34
+ template "config.yml", "config/payfast.yml"
35
+ end
35
36
 
36
- def create_model
37
- template "model.rb", "app/models/cart.rb"
38
- end
37
+ def create_model
38
+ template "model.rb", "app/models/cart.rb"
39
+ end
39
40
 
40
- private
41
+ def add_erb_tag
42
+ # Append an ERB tag to the application.html.erb file
43
+ insert_into_file "app/views/layouts/application.html.erb", before: "</head>" do
44
+ "<%= payfast_script_tag %>"
45
+ end
46
+ end
41
47
 
42
- def controller_file_name
43
- "carts"
44
- end
48
+ def configure_development
49
+ insert_into_file "config/environments/development.rb", before: /^end/ do
50
+ <<-RUBY.strip_heredoc.indent(2)
51
+ config.hosts << /[a-z0-9-]+\.ngrok-free\.app/
52
+ RUBY
53
+ end
54
+ end
45
55
 
46
- def timestamp
47
- Time.now.strftime("%Y%m%d%H%M%S")
48
- end
56
+ private
49
57
 
50
- def actions
51
- %w(index make_payment)
58
+ def controller_file_name
59
+ "carts"
60
+ end
61
+
62
+ def timestamp
63
+ Time.now.strftime("%Y%m%d%H%M%S")
64
+ end
65
+
66
+ def actions
67
+ %w(index make_payment)
68
+ end
52
69
  end
53
70
  end
54
71
  end
@@ -1,7 +1,19 @@
1
+
2
+ # Run rails EDITOR="code --wait" bin/rails credentials:edit
3
+
4
+ # Add the following credentials from your payfast account.
5
+ # payfast:
6
+ # merchant_id: {your_merchant_id}
7
+ # merchant_key: {your_merchant_key}
8
+ # passphrase: {{your_passphrase}}
9
+
10
+
11
+
1
12
  development:
2
- merchant_id: <%#= Rails.application.credentials.payfast.merchant_id %>
3
- merchant_key: <%#= Rails.application.credentials.payfast.merchant_key %>
4
- passphrase: <%#= Rails.application.credentials.payfast.passphrase %>
13
+ # Remove the comments below and wrap with erb tags
14
+ merchant_id: # Rails.application.credentials.payfast.merchant_id
15
+ merchant_key: # Rails.application.credentials.payfast.merchant_key
16
+ passphrase: # Rails.application.credentials.payfast.passphrase
5
17
  base_url: https://sandbox.payfast.co.za/onsite/process
6
18
  # Replace with your own urls
7
19
  return_url: https://1c8e-102-69-134-39.ngrok-free.app/carts/return_url
@@ -9,9 +21,10 @@ development:
9
21
  notify_url: https://1c8e-102-69-134-39.ngrok-free.app/carts/notify
10
22
  js_bundle: https://sandbox.payfast.co.za/onsite/engine.js
11
23
  production:
12
- merchant_id: <%#= Rails.application.credentials.payfast_merchant_id %>
13
- merchant_key: <%#= Rails.application.credentials.payfast_merchant_key %>
14
- passphrase: <%#= Rails.application.credentials.passphrase %>
24
+ # Remove the comments below and wrap with erb tags
25
+ merchant_id: # Rails.application.credentials.payfast.merchant_id
26
+ merchant_key: # Rails.application.credentials.payfast.merchant_key
27
+ passphrase: # Rails.application.credentials.payfast.passphrase
15
28
  base_url: https://www.payfast.co.za/onsite/process
16
29
  # Replace with your own urls
17
30
  return_url: https://1c8e-102-69-134-39.ngrok-free.app/carts/return_url
@@ -1,3 +1,5 @@
1
+ require "payfast/onsite_payments"
2
+
1
3
  class CartsController < ApplicationController
2
4
  def index
3
5
  end
@@ -32,11 +34,11 @@ class CartsController < ApplicationController
32
34
  def success
33
35
  @cart = Cart.find(params[:id])
34
36
  @cart.is_paid = true
35
- redirect_to root_path, notice: "Transcation Successful"
37
+ redirect_to carts_path, notice: "Transcation Successful"
36
38
  end
37
39
 
38
40
  def failure
39
- redirect_to root_path, notice: "Transcation Canceled"
41
+ redirect_to carts_path, notice: "Transcation Canceled"
40
42
  end
41
43
 
42
44
  private
@@ -1,14 +1,14 @@
1
1
 
2
2
  <script>
3
- // set the uuid to uuid = @cart.payment_uuid. surround @carts.payment_uuid with erb tags
3
+ // set the uuid to uuid = @cart.payment_uuid wrap @carts.payment_uuid with erb tags
4
4
  const uuid = ``
5
5
  window.payfast_do_onsite_payment({uuid}, function (result) {
6
6
  if (result === true) {
7
- // redirect success_cart_path(@cart)
7
+ // wrap success_cart_path(@cart) with erb tags and paste into the literal below
8
8
  window.location.href = ``
9
9
  }
10
10
  else {
11
- // Redirect to failure_cart_path(@cart)
11
+ // Redirect to failure_cart_path(@cart) with erb tags and paste into the literal below
12
12
  window.location.href = ``
13
13
  }
14
14
  });
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.2
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dellan Muchengapadare
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-23 00:00:00.000000000 Z
11
+ date: 2023-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler