payfast 1.0.4 → 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
|
@@ -38,6 +38,21 @@ module Payfast
|
|
38
38
|
template "model.rb", "app/models/cart.rb"
|
39
39
|
end
|
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
|
47
|
+
|
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
|
55
|
+
|
41
56
|
private
|
42
57
|
|
43
58
|
def controller_file_name
|
@@ -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
|
});
|