paycorp_rails 0.0.2 → 1.0.0

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
  SHA1:
3
- metadata.gz: a63189707f47bab9a6c24542e8fa9e10718d2d63
4
- data.tar.gz: cf0b68164aa41a69383c1bee1ddf986afdc84eb0
3
+ metadata.gz: 5c5adb753a0431799db86d9e308d2329d4ea91e2
4
+ data.tar.gz: 14873d08e5d8c2a2cb10df423e95d7724238e15d
5
5
  SHA512:
6
- metadata.gz: 054ebaf42bb247fe0db9eb46b0a2c89dd05b162c5346c1db725caae5efaef840a989fbe6953c941ba5e5750ff5470c13cd7bbf0527f0768cd0006f99480b5785
7
- data.tar.gz: 47d5e2b6ab181a53006ab464b0ac970596ee3dede7ae5a89844ff9421d9199ec3532bdd8bb3f2dcfb28035512ec811543f395ce5c70c45bfc1f291e085166174
6
+ metadata.gz: 4a184e1e7c6d249becd3ca4556dbc4f7ee13e0b676db84f8eee56e8f72e63f2e6163fc0782b58873bbd1766ddd850c2f557ded1caeaa7244f1cd636f77233dcf
7
+ data.tar.gz: 64cceed991392d09b98b0b6a942a15d8e521cc132ce94127483c651d21233b5e53e1a83ba472e693cb3078dfd8c191c205b5709a437b849ac556d3856e3e78af
data/README.md CHANGED
@@ -1,11 +1,9 @@
1
1
  # PaycorpRails
2
+ [![Gem Version](https://badge.fury.io/rb/paycorp_rails.svg)](https://badge.fury.io/rb/paycorp_rails)
2
3
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/paycorp_rails`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
4
+ This gem will integrate the Paycorp payment gateway with your Rails app. If you face any issues, place them here : [github.com/LeafyCode/paycorp_rails/issues](https://github.com/LeafyCode/paycorp_rails/issues). You can also contact us directly : [leafycode.com/contact](http://leafycode.com/contact)
6
5
 
7
6
  ## Installation
8
-
9
7
  Add this line to your application's Gemfile:
10
8
 
11
9
  ```ruby
@@ -14,28 +12,91 @@ gem 'paycorp_rails'
14
12
 
15
13
  And then execute:
16
14
 
17
- $ bundle
15
+ ```
16
+ $ bundle
17
+ ```
18
18
 
19
19
  Or install it yourself as:
20
20
 
21
- $ gem install paycorp_rails
21
+ ```
22
+ $ gem install paycorp_rails
23
+ ```
22
24
 
23
25
  ## Usage
26
+ ### Initialize the Gateway
27
+ To initialize the gateway, in your `config/application.rb` place the following code and make the necessary changes :
24
28
 
25
- TODO: Write usage instructions here
29
+ ```ruby
30
+ config.after_initialize do
31
+ paycorp_options = {
32
+ client_id: 'CLIENT_ID',
33
+ hmac: 'HMAC',
34
+ auth_token: 'AUTH_TOKEN',
35
+ endpoint: 'ENDPOINT'
36
+ }
37
+ ::PAYCORP_GATEWAY = PaycorpRails.new(paycorp_options)
38
+ end
39
+ ```
26
40
 
27
- ## Development
41
+ Note : The `CLIENT_ID`, `HMAC`, `AUTH_TOKEN` and the `ENDPOINT` will be given to you by Paycorp.
42
+
43
+ ### Initiate Payment
44
+ First, you need to send the transaction details to Paycorp and initiate the payment :
45
+
46
+ ```ruby
47
+ payment_options = {
48
+ msg_id: SecureRandom.uuid, # Better generate this and store in the model and then use that in here
49
+ amount: AMOUNT_IN_CENTS,
50
+ currency: 'LKR', # Currency
51
+ return_url: "RETURN_URL",
52
+ user_id: USER_ID, # For reference
53
+ css_url: 'ADDITIONAL_CSS'
54
+ }
55
+
56
+ response = PAYCORP_GATEWAY.initiate_payment(payment_options)
57
+ ```
58
+
59
+ **amount** should be in cents. **css_url** : If you are using the iframe version, you can pass a css file to style the iframe. Make sure the file is served with HTTPS.
60
+
61
+ Store the `response` data in the model (Specially the `reqid` and the `paymentPageUrl`)
62
+
63
+ If you use the iframe method, use the `paymentPageUrl` for the iframe. If not, redirect the user to that url.
64
+
65
+ ### Complete Payment
66
+ When the user complete the order, the Gateway will redirect to the `return_url` you provided earlier. The gateway will post some data to this url. Capture them and store the necessary ones. You can pick the right order using the `reqid` they send like this :
28
67
 
68
+ ```ruby
69
+ Order.find_by(reqid: params[:reqid])
70
+ ```
71
+
72
+ Now the payment is ready to process but it's not complete and the user haven't been charged. You need to send a request to Paycorp and tell them to complete the order :
73
+
74
+ ```ruby
75
+ payment_options = {
76
+ msg_id: @order.msg_id, # Change @order as necessary
77
+ reqid: @order.reqid
78
+ }
79
+
80
+ response = PAYCORP_GATEWAY.complete_payment(payment_options)
81
+ ```
82
+
83
+ Store the necessary information in the `response`. If the returned `responseCode` (`response['responseData']['responseCode']`) is `00`, the order is successful! Otherwise, there's an issue. You can find the response text in the response.
84
+
85
+ **Warning** When on testing, Paycorp will change the response code according to the amount of cents in your transaction amount. If you want to see a failing transaction, send a non 0 value as cents.
86
+
87
+ For example, if the order's amount is 100.00, the response code will be `00`. If the amount is 100.01, the response code will be `01`. This happens only during development.
88
+
89
+ ## Development
29
90
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake false` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
91
 
31
92
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
93
 
33
94
  ## Contributing
34
-
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/paycorp_rails. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
36
-
95
+ Bug reports and pull requests are welcome on GitHub at [https://github.com/LeafyCode/paycorp_rails](https://github.com/LeafyCode/paycorp_rails). This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
37
96
 
38
97
  ## License
39
-
40
98
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
99
 
100
+ ## Built by
101
+
102
+ [LeafyCode.com](http://leafycode.com/)
@@ -1,3 +1,3 @@
1
1
  class PaycorpRails
2
- VERSION = "0.0.2"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paycorp_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pubudu Kodikara