payfast 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e7600cac11c5e9e6093e1ae5bf21cb197dc661cff76e5cc16993aa32475e104a
4
- data.tar.gz: 95cd4bc5539cd3bd4dcb25671d3af0b77ee6712bad80d17a0c7bef23d65eca09
3
+ metadata.gz: b5a6f5a5b16ce72d474b8b250b142131d6f216922159ea7356ba69a294fb1804
4
+ data.tar.gz: 8c59abe214f2abccb269bc7281f29598aec666fa75cbac8ce8b25bfe9c06e1b8
5
5
  SHA512:
6
- metadata.gz: a686d46ee883626b1789efb1cfee13dcb6e05f4af9f0f7a179c665fa171672e8a3a9ff7b92f5f5bf02912e4930e7dcd7800ccb024c15f813b4f00355af7ba813
7
- data.tar.gz: 8d0fa3c627b47e34266364bb251827ee361b42f3e5da98fa6543c0c4feecdbc9c86e9af35aed367e60324c77399c19e2759648cc340fd1f190650220f84c9654
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
- 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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: payfast
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dellan Muchengapadare