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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5a6f5a5b16ce72d474b8b250b142131d6f216922159ea7356ba69a294fb1804
|
4
|
+
data.tar.gz: 8c59abe214f2abccb269bc7281f29598aec666fa75cbac8ce8b25bfe9c06e1b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
5
|
-
|
4
|
+
module Generators
|
5
|
+
class InstallGenerator < Rails::Generators::Base
|
6
|
+
source_root File.expand_path("templates", __dir__)
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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
|
-
|
15
|
-
|
16
|
-
|
15
|
+
def create_controller
|
16
|
+
template "controller.rb", File.join("app/controllers", "#{controller_file_name}_controller.rb")
|
17
|
+
end
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
-
|
25
|
-
|
26
|
-
|
25
|
+
def create_view_helper
|
26
|
+
template "helper.rb", "app/helpers/carts_helper.rb"
|
27
|
+
end
|
27
28
|
|
28
|
-
|
29
|
-
|
30
|
-
|
29
|
+
def create_migration
|
30
|
+
template "migration.rb", "db/migrate/#{timestamp}_create_carts.rb"
|
31
|
+
end
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
|
33
|
+
def create_config_file
|
34
|
+
template "config.yml", "config/payfast.yml"
|
35
|
+
end
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
|
37
|
+
def create_model
|
38
|
+
template "model.rb", "app/models/cart.rb"
|
39
|
+
end
|
39
40
|
|
40
|
-
|
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
|
-
|
43
|
-
|
44
|
-
|
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
|
-
|
47
|
-
Time.now.strftime("%Y%m%d%H%M%S")
|
48
|
-
end
|
56
|
+
private
|
49
57
|
|
50
|
-
|
51
|
-
|
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
|
-
|
3
|
-
|
4
|
-
|
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
|
-
|
13
|
-
|
14
|
-
|
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
|
37
|
+
redirect_to carts_path, notice: "Transcation Successful"
|
36
38
|
end
|
37
39
|
|
38
40
|
def failure
|
39
|
-
redirect_to
|
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
|
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
|
-
//
|
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.
|
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-
|
11
|
+
date: 2023-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|