koduc_express_paypal 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +96 -32
- data/koduc_express_paypal.gemspec +5 -2
- data/lib/koduc_express_paypal.rb +6 -3
- data/lib/koduc_express_paypal/koduc_response.rb +1 -1
- data/lib/koduc_express_paypal/version.rb +2 -1
- data/lib/koduc_refund/koduc_refund.rb +87 -0
- data/lib/koduc_refund/koduc_refund_validation.rb +111 -0
- metadata +11 -7
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NjI5OTZjOTgyMWExMTg2NDQ2M2ZhZjA4NTFmOWI3M2U3NTBjOTA1NA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YzNlYTNiNDkwNzIwNmI1NjdiYTg3NjExY2M4ZTdkMTk0OGM0OTViYg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YmYxYjFiNGY4MmVhYjIwMmUyNWM5NmNmMjRkZDIwYmM3NGQ1NjNlYTA1MjZl
|
10
|
+
NGMxMDYzMzJkMzYyNmM0OWI5OWVkMTRkMzE1MzYyOWMyOGE0YTYzMTBiNDhk
|
11
|
+
NzE2MWMwN2M1ZmU5NjkzYjk2YTMzMTJhMTMwMjI3M2RhMTA4ZDM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZGY4M2YwMmI5YWE5YTc5YTA5Yjc1NDM1MmEzMWM5ODY1Yzk2YzFhMTc2Y2E0
|
14
|
+
M2M5YjYxZmE1MDA0MjlkZjI3MTdkOGUzODYzNGI0MWIyMDA4YTEwOTZmM2Rm
|
15
|
+
ZmI5NTBmODYxYjBhNzQzMWI0ZGEwYjc5MTFlZTZmZmQ0NWZhYmU=
|
data/README.md
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
# KoducExpressPaypal
|
2
2
|
|
3
|
-
|
3
|
+
> Gem used for Paypal Express Checkout integration using NVP with both Full and Partial refunds.
|
4
|
+
|
5
|
+
### Description
|
6
|
+
KoducExpressPaypal is a simple gem used for fulfilling the requirement of one time Paypal Express Checkout integration using NVP(Name Value Pair). One can also make refunds (both full and partial) with the help of the gem. The chief principle of designing this library is the involvement of different internal Express Checkout Paypal APIs.
|
4
7
|
|
5
8
|
It is developed for the usage in Ruby on Rails web applications and integrates as a Rails plugin.
|
6
9
|
|
7
|
-
It is developed in November 2015 by [
|
10
|
+
It is developed in November 2015 by [Koduc](http://koduc.com/) team with the help of valuable contributors.
|
8
11
|
|
9
12
|
## Installation
|
10
13
|
|
@@ -28,18 +31,19 @@ Or install it yourself as:
|
|
28
31
|
$ gem install koduc_express_paypal
|
29
32
|
|
30
33
|
## Usage
|
31
|
-
|
32
|
-
This simple example demonstrates how a purchase can be made using the
|
34
|
+
### Payment Gateway Integration
|
35
|
+
>This simple example demonstrates how a purchase can be made using the koduc_express_paypal gem.
|
33
36
|
|
34
37
|
```ruby
|
38
|
+
# Require the gem in the controller
|
35
39
|
require 'koduc_express_paypal'
|
36
40
|
|
37
|
-
# Declare the following
|
41
|
+
# Declare the following API credentials in the same format in the environment files present in the config folder. Use development.rb for sandbox (test) credentials and production.rb for live credentials. The API credentials can be found from the paypal account created.
|
38
42
|
|
39
43
|
config.paypal_credentials = {
|
40
|
-
:USER => <
|
41
|
-
:PWD => <
|
42
|
-
:SIGNATURE => <
|
44
|
+
:USER => <Username>,
|
45
|
+
:PWD => <Password>,
|
46
|
+
:SIGNATURE => <Signature>
|
43
47
|
}
|
44
48
|
|
45
49
|
# Set the environment in the format given below.
|
@@ -51,70 +55,130 @@ KsCheckEnvironment::ks_sandbox(true)
|
|
51
55
|
# For Live mode use
|
52
56
|
KsCheckEnvironment::ks_sandbox(false)
|
53
57
|
|
58
|
+
# Parameters required for payment
|
59
|
+
# payment_amount => payment amount (Integers and float values are allowed else it will throw error message)
|
60
|
+
# payment_action => type of transaction (Only alphabets are allowed)
|
61
|
+
# payment_currency => payment currency code (Only alphabets are allowed in capital letters)
|
62
|
+
# cancel_url => redirect URL for use if the customer does not authorize payment
|
63
|
+
# return_url => redirect URL for use if the customer authorizes payment
|
64
|
+
|
54
65
|
# Form a hash of the required parameters in the format given below.
|
55
66
|
# All the fields are mandatory
|
56
|
-
# payment_amount => payment amount (Integers and float values are allowed else it will throw error message )
|
57
|
-
# payment_action => type of transaction (Only alphabets are allowed.)
|
58
|
-
# payment_currency => payment currency code (Only alphabets are allowed in capital letters.)
|
59
|
-
# cancel_url => redirect URL for use if the customer does not authorize payment
|
60
|
-
# return_url => redirect URL for use if the customer authorizes payment
|
61
67
|
# Pass the parameters in string
|
62
|
-
|
63
68
|
hash = {:payment_amount =><paymentAmount>,:payment_action=><paymentAction>,:payment_currency=><paymentCurrency>,:cancel_url=><cancelURL>,:return_url=><returnURL>}
|
64
69
|
|
65
|
-
# Form an object
|
66
|
-
|
70
|
+
# Form an object of the class KsRequest present in KsExpressPaypal module with the hash of the parameters formed above
|
67
71
|
obj = KsExpressPaypal::KsRequest.new(hash)
|
68
72
|
|
69
73
|
# Check if the passed parameters are valid using the object formed above
|
70
|
-
|
71
74
|
validity = obj.valid?
|
72
75
|
|
73
76
|
# The format of the response obtained is {success: true/false ,response:[Error Array]}
|
74
77
|
# The value of success is true is the parameters are verified completely else it will be false.
|
75
|
-
# The value of response will be an Array consisting of the error messages in case the validation of the parameters
|
76
|
-
|
77
|
-
# If the success is true call the following method with the same object formed above
|
78
|
+
# The value of the response will either be an Array consisting of the error messages in case the validation of the parameters fails else it will be an empty array.
|
78
79
|
|
80
|
+
# If the value of success in the above call is true call the following method with the same object formed above
|
79
81
|
set_checkout = obj.ks_set_express_checkout
|
80
82
|
|
81
83
|
# The format of the response in case of success is {success: true ,response:[Response returned from Paypal]}
|
82
84
|
# The format of the response in case of failure is {success: false ,response:[Error Message returned from Paypal]}
|
83
85
|
# If the above call is successful the response will contain the TOKEN.
|
84
|
-
# If the above call is a failure refer the paypal errors.
|
85
86
|
|
86
|
-
# In case of success, using the token valued returned from above, redirect the customer to PayPal so they can approve the transaction:
|
87
|
+
# In case of success, using the token valued returned from above call, redirect the customer to PayPal so they can approve the transaction:
|
87
88
|
|
88
|
-
# For sandbox
|
89
|
+
# For sandbox redirect the customer to
|
89
90
|
https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=<tokenValue>
|
90
91
|
|
91
92
|
# For LIVE redirect the customer to
|
92
93
|
https://www.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=<tokenValue>
|
93
94
|
|
94
95
|
# The redirect presents the customer with a PayPal log-in page. After the customer logs in, PayPal displays the transaction details on the Payments Review page. The customer approves the payment on this page by clicking Continue.
|
95
|
-
|
96
|
-
# If the customer approves the payment, PayPal directs the customer to the payment confirmation page (the return URL specified above in the parameters described above). If the customer doesn't authorize the payment, PayPal directs the customer to the cancel URL that you also specified in the parameters described above, and you can attempt to re-initiate the checkout.
|
97
|
-
|
96
|
+
# If the customer approves the payment, PayPal directs the customer to the payment confirmation page (the return URL specified above in the parameters described above). If the customer doesn't authorize the payment, PayPal directs the customer to the cancel URL, also specified in the parameters described above, and you can attempt to re-initiate the checkout.
|
98
97
|
# If the customer approves the payment, find the checkout details using the following method by passing the TOKEN obtained above with the same object.
|
99
98
|
# It is advisable to display the details on the payment confirmation page using the below method
|
100
|
-
|
101
99
|
checkout_details = KsExpressPaypal::KsRequest.ks_checkout_details(<tokenValue>)
|
102
100
|
|
103
101
|
# The format of the response in case of success is {success: true ,response:[Response returned from Paypal]}
|
104
102
|
# The format of the response in case of failure is {success: false ,response:[Error Message returned from Paypal]}
|
105
|
-
# If the above call is successful the response will contain the TOKEN and the various other details with the PAYERID if the customer has verified the payment.
|
106
|
-
#
|
107
|
-
|
108
|
-
# In addition to the transaction details, your payment confirmation page should include a Confirm button. When the customer confirms the payment, call the below method to capture (collect) the payment. The following sample shows how to specify the PayerID and token value returned from the previous call. Provide the Payment Action with token and payerId:
|
109
|
-
|
103
|
+
# If the above call is successful the response will contain the TOKEN and the various other details with the PAYERID if the customer has verified the payment.
|
104
|
+
# In addition to the transaction details, your payment confirmation page should include a Confirm button. When the customer confirms the payment, call the below method to capture (collect) the payment. The following sample shows how to specify the PayerID and token value returned from the previous call. Provide the Payment Action with token and payerId.
|
110
105
|
do_checkout = KsExpressPaypal::KsRequest.ks_do_checkout(<tokenValue>,<paymentAction>,<payerId>)
|
111
106
|
|
112
107
|
# When PayPal processes the above call, it captures the payment by transferring the funds from the customer account to the appropriate merchant account and sends a confirmation e-mail to the customer.
|
108
|
+
# The format of the response in case of success is {success: true ,response:[Response returned from Paypal]}
|
109
|
+
# The format of the response in case of failure is {success: false ,response:[Error Message returned from Paypal]}
|
110
|
+
# Refer the paypal errors in case of failure.
|
111
|
+
```
|
112
|
+
## Refund
|
113
|
+
>This simple example demonstrates how a refund can be made using the koduc_express_paypal gem.
|
114
|
+
|
115
|
+
```ruby
|
116
|
+
# Require the gem in the controller
|
117
|
+
require 'koduc_express_paypal'
|
118
|
+
|
119
|
+
# Declare the following API credentials (if not declared) in the same format in the environment files present in the config folder. Use development.rb for sandbox (test) credentials and production.rb for live credentials. The API credentials can be found from the paypal account created.
|
120
|
+
|
121
|
+
config.paypal_credentials = {
|
122
|
+
:USER => <Username>,
|
123
|
+
:PWD => <Password>,
|
124
|
+
:SIGNATURE => <Signature>
|
125
|
+
}
|
126
|
+
|
127
|
+
# Set the environment in the format given below.
|
128
|
+
# Default it will be a sandbox mode.
|
129
|
+
|
130
|
+
# For Sandbox mode use
|
131
|
+
KsCheckEnvironment::ks_sandbox(true)
|
113
132
|
|
133
|
+
# For Live mode use
|
134
|
+
KsCheckEnvironment::ks_sandbox(false)
|
135
|
+
|
136
|
+
# Parameters for Refund
|
137
|
+
# In case of Full refund, pass only the transaction id as a parameter else the refund will be considered as partial.
|
138
|
+
# transaction_id => id of the transaction for which refund is to be made (mandatory)
|
139
|
+
# amount => amount of transaction (conditional: only required in case of partial payment)
|
140
|
+
# currency_code => payment currency code (Only alphabets are allowed in capital letters, conditional: Only required in case of partial payment.)
|
141
|
+
# note => description of the partial payment (conditional:Only required in case of partial payment.)
|
142
|
+
|
143
|
+
# Pass the parameters in string
|
144
|
+
# In case of full refund form the hash in the following format
|
145
|
+
hash = {:transaction_id => <TransactionId>}
|
146
|
+
|
147
|
+
# In case of partial refund form the hash in the following format
|
148
|
+
hash = {:transaction_id => <TransactionId>, :amount=><AmountToBeRefunded> , :currency_code=><PaymentCurrencyCode>,:note=><DescriptionOfThePartialPayment>}
|
149
|
+
|
150
|
+
# Form an object of the class KsRefund present in KsAPIRefund module with the hash of the parameters formed above
|
151
|
+
obj = KsAPIRefund::KsRefund.new(hash)
|
152
|
+
|
153
|
+
# Call the below method with the object formed above.
|
154
|
+
obj.ks_refund
|
155
|
+
|
156
|
+
# When PayPal processes the above call, it refunds the funds (either 'Full' or 'Partial') from the merchant account to the appropriate customer account.
|
114
157
|
# The format of the response in case of success is {success: true ,response:[Response returned from Paypal]}
|
115
158
|
# The format of the response in case of failure is {success: false ,response:[Error Message returned from Paypal]}
|
116
159
|
# Refer the paypal errors in case of failure.
|
117
160
|
```
|
161
|
+
|
162
|
+
## Response format
|
163
|
+
>Success :
|
164
|
+
```
|
165
|
+
{
|
166
|
+
:success => true,
|
167
|
+
:response => [<Response return by Paypal>]
|
168
|
+
}
|
169
|
+
```
|
170
|
+
|
171
|
+
> Error :
|
172
|
+
```
|
173
|
+
{
|
174
|
+
:success => false,
|
175
|
+
:response => [<Error messages separated by commas>]
|
176
|
+
}
|
177
|
+
```
|
178
|
+
## Important points
|
179
|
+
* In case the response is failure refer the [Paypal Errors](https://developer.paypal.com/docs/classic/api/errorcodes/) for more details.
|
180
|
+
* All the parameters should be passed in string.
|
181
|
+
|
118
182
|
## Queries and Issues
|
119
183
|
|
120
184
|
Your valuable queries and suggestions are welcomed. Please report the issues on GitHub at https://github.com/kartiksolves/koduc-paypal-express
|
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Koduc"]
|
10
10
|
spec.email = ["ratan@ksolves.com"]
|
11
11
|
|
12
|
-
spec.summary = "Gem deals with express checkout one time Paypal Payment using NVP Gateway."
|
13
|
-
spec.description = "
|
12
|
+
spec.summary = "Gem deals with express checkout one time Paypal Payment using NVP Gateway with partial and full refunds."
|
13
|
+
spec.description = "koduc_express_paypal is a simple gem used for Paypal Payment Gateway integration with partial and full refunds. This gem is written by KSolves. The main aim of this project is to deal with the one time Paypal payment using express checkout method using NVP(Name Value Pair). One can also make partial and full refunds."
|
14
14
|
spec.homepage = "https://github.com/kartiksolves/koduc-paypal-express"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
@@ -27,6 +27,9 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
28
|
spec.require_paths = ["lib"]
|
29
29
|
|
30
|
+
# Specify the minimum version of the ruby
|
31
|
+
spec.required_ruby_version = '>= 1.9.3'
|
32
|
+
|
30
33
|
spec.add_development_dependency "bundler", "~> 1.10"
|
31
34
|
spec.add_development_dependency "rake", "~> 10.0"
|
32
35
|
spec.add_development_dependency "rspec"
|
data/lib/koduc_express_paypal.rb
CHANGED
@@ -1,12 +1,15 @@
|
|
1
|
-
#
|
2
|
-
#
|
1
|
+
# First file to be loaded when the gem is invoked.
|
2
|
+
# Need to require everything here
|
3
|
+
# Fetch all the configuration values here
|
3
4
|
|
4
5
|
require "koduc_express_paypal/version"
|
5
6
|
require "koduc_express_paypal/koduc_check_environment"
|
6
7
|
require "koduc_express_paypal/koduc_request"
|
7
8
|
require "koduc_express_paypal/koduc_validation"
|
8
|
-
require "koduc_exception_handling/koduc_api_errors"
|
9
9
|
require "koduc_express_paypal/koduc_response"
|
10
|
+
require "koduc_exception_handling/koduc_api_errors"
|
11
|
+
require "koduc_refund/koduc_refund"
|
12
|
+
require "koduc_refund/koduc_refund_validation"
|
10
13
|
require "active_support"
|
11
14
|
require "active_support/core_ext"
|
12
15
|
require "rest_client"
|
@@ -1,7 +1,8 @@
|
|
1
1
|
# Version of the gems are described here as a constant
|
2
2
|
# Change the VERSION before submitting to rubygems.org
|
3
3
|
# For initial phase keep it as it is
|
4
|
+
# For every update change the version before submitting to Rubygems.org
|
4
5
|
|
5
6
|
module KoducExpressPaypal
|
6
|
-
VERSION = "1.
|
7
|
+
VERSION = "1.1.0"
|
7
8
|
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# The file is loaded so as to refund the transaction
|
2
|
+
# Initialize the object's constructor first
|
3
|
+
# Refund could be Full or Partial
|
4
|
+
# transaction_id => The transaction id for which the refund is to be made(required in both Full and Partial payments)
|
5
|
+
# amount => The amount in case of partial refund
|
6
|
+
# currency_code => The currency code required in case of partial refund
|
7
|
+
# note => The description of the partial refund
|
8
|
+
# refund_type => The refund type 'Full' or 'Partial'
|
9
|
+
|
10
|
+
module KsAPIRefund
|
11
|
+
|
12
|
+
class KsRefund
|
13
|
+
|
14
|
+
attr_accessor :transaction_id, :params, :amount, :currency_code, :note, :refund_type
|
15
|
+
|
16
|
+
# Class default constructor
|
17
|
+
def initialize(params)
|
18
|
+
@transaction_id = params[:transaction_id]
|
19
|
+
@amount = params[:amount]
|
20
|
+
@currency_code = params[:payment_currency]
|
21
|
+
@note = params[:note]
|
22
|
+
@refund_type = ''
|
23
|
+
end
|
24
|
+
|
25
|
+
# Method will check the validity of the parameters initialised with the help of the constructor
|
26
|
+
# Form a new object of the RefundValidation class
|
27
|
+
# Returns the response fetched from the check_validity method
|
28
|
+
def valid?
|
29
|
+
obj= RefundValidation.new(transaction_id,amount,currency_code,note)
|
30
|
+
response = obj.check_validity
|
31
|
+
return response
|
32
|
+
end
|
33
|
+
|
34
|
+
# Check for the refund type
|
35
|
+
# If amount, currency code and note are blank, it will be 'Full'
|
36
|
+
# Else it will be partial
|
37
|
+
# Returns the refund type
|
38
|
+
def refund_type?
|
39
|
+
if amount.blank? && currency_code.blank? && note.blank?
|
40
|
+
refund_type = 'Full'
|
41
|
+
else
|
42
|
+
refund_type = 'Partial'
|
43
|
+
end
|
44
|
+
return refund_type
|
45
|
+
end
|
46
|
+
|
47
|
+
# Returns the parameters for the partial payment
|
48
|
+
def partial_params
|
49
|
+
partial_params = {
|
50
|
+
:AMT => amount,
|
51
|
+
:CURRENCYCODE => currency_code,
|
52
|
+
:NOTE => note
|
53
|
+
}
|
54
|
+
return partial_params
|
55
|
+
end
|
56
|
+
|
57
|
+
# Returns the transaction id in the hash format
|
58
|
+
def transaction
|
59
|
+
transaction = {
|
60
|
+
:TRANSACTIONID=>transaction_id
|
61
|
+
}
|
62
|
+
return transaction
|
63
|
+
end
|
64
|
+
|
65
|
+
# Method to invoke the refund functionality
|
66
|
+
# If the refund type is 'full' dont merge the amount, currency code and note
|
67
|
+
# Check the validity of the parameters first
|
68
|
+
# If response[:success] is true call the Refund API
|
69
|
+
# Else return the response obtained from the valid? method
|
70
|
+
def ks_refund
|
71
|
+
env = KsCheckEnvironment::ks_sandbox(false)
|
72
|
+
response = valid?
|
73
|
+
if response[:success]
|
74
|
+
refund_type = refund_type?
|
75
|
+
case refund_type
|
76
|
+
when 'Full'
|
77
|
+
ks_response = KsExpressPaypal::KsRequest.ks_request :RefundTransaction,KsExpressPaypal.ks_merchants_details.merge(transaction).merge(:REFUNDTYPE=>refund_type)
|
78
|
+
else
|
79
|
+
ks_response = KsExpressPaypal::KsRequest.ks_request :RefundTransaction,KsExpressPaypal.ks_merchants_details.merge(transaction).merge(:REFUNDTYPE=>refund_type).merge(partial_params)
|
80
|
+
end
|
81
|
+
else
|
82
|
+
return response
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
# To validate the refund parameters
|
2
|
+
# transaction_id => id of the transaction that needs to be refunded (mandatory for both partial and full refund)
|
3
|
+
# amount => The amount to be refunded in case of partial payments
|
4
|
+
# currency_code => The currency code required only in case of partial paymanets
|
5
|
+
# note => Description of the partial payment
|
6
|
+
# ks_error => Array that will hold the error messages.
|
7
|
+
|
8
|
+
class RefundValidation
|
9
|
+
|
10
|
+
attr_accessor :transaction_id, :amount, :currency_code, :note, :ks_error
|
11
|
+
|
12
|
+
# Default constructor of the class
|
13
|
+
def initialize(transaction_id,amount,currency_code,note)
|
14
|
+
@transaction_id = transaction_id
|
15
|
+
@amount = amount
|
16
|
+
@currency_code = currency_code
|
17
|
+
@note = note
|
18
|
+
@ks_error = []
|
19
|
+
end
|
20
|
+
|
21
|
+
# Method invoke so as to check the validity of the parameters passed
|
22
|
+
def check_validity
|
23
|
+
success = true
|
24
|
+
if !empty_transaction_id?
|
25
|
+
success = false
|
26
|
+
else
|
27
|
+
if !amount.blank? && !currency_code.blank?
|
28
|
+
success = false if !check_payment_amount?
|
29
|
+
success = false if !payment_number?
|
30
|
+
success = false if !currency_code?
|
31
|
+
end
|
32
|
+
end
|
33
|
+
response = validate_response(success)
|
34
|
+
return response
|
35
|
+
end
|
36
|
+
|
37
|
+
# It returns the response in both the cases (success or failure)
|
38
|
+
# The format of response is {success: true/false, error_messages: array of the error messages(blank if success is true)}
|
39
|
+
# Check the uniqueness of the array of the error messages with uniq keyword
|
40
|
+
def validate_response(success)
|
41
|
+
unique_errors = ks_error.uniq
|
42
|
+
response = {success:success,response:unique_errors}
|
43
|
+
return response
|
44
|
+
end
|
45
|
+
|
46
|
+
# Check for the empty transaction id
|
47
|
+
# Returns true for the success if verified else false with error message
|
48
|
+
def empty_transaction_id?
|
49
|
+
if transaction_id.blank?
|
50
|
+
ks_error << "Missing Parameters : Transaction Id can not be blank."
|
51
|
+
puts "Check for transaction id is failed."
|
52
|
+
success = false
|
53
|
+
else
|
54
|
+
puts "Check for transaction id is successful."
|
55
|
+
success = true
|
56
|
+
end
|
57
|
+
return success
|
58
|
+
end
|
59
|
+
|
60
|
+
# Invoke the below method to check if the payment amount is smaller than or equals to zero
|
61
|
+
# Returns the value of success accordingly
|
62
|
+
def check_payment_amount?
|
63
|
+
if !amount.blank?
|
64
|
+
payment_amount = amount.to_i
|
65
|
+
if !(payment_amount <= 0)
|
66
|
+
success = true
|
67
|
+
puts "Check for payment amount is successful"
|
68
|
+
else
|
69
|
+
ks_error << "Payment Amount is invalid."
|
70
|
+
success = false
|
71
|
+
puts "Check for payment Amount is failed."
|
72
|
+
end
|
73
|
+
return success
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
# Check if the string passed consists of only numbers and the decimal values
|
78
|
+
# Returns true and false accordingly
|
79
|
+
# Returns the error message if success is false
|
80
|
+
def payment_number?
|
81
|
+
if !amount.blank?
|
82
|
+
if amount =~ /\A[-+]?\d*\.?\d+\z/
|
83
|
+
success = true
|
84
|
+
puts "Check for payment amount is successful."
|
85
|
+
else
|
86
|
+
ks_error << "Payment Amount is invalid."
|
87
|
+
success = false
|
88
|
+
puts "Check for payment amount is failed."
|
89
|
+
end
|
90
|
+
return success
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
# Check if the currency code is invalid (contains capital letters)
|
95
|
+
# Returns true and false accordingly
|
96
|
+
# Returns the error message
|
97
|
+
def currency_code?
|
98
|
+
if !currency_code.blank?
|
99
|
+
if currency_code.match(/^[A-Z]+$/)
|
100
|
+
success = true
|
101
|
+
puts "Check for currency code is successful."
|
102
|
+
else
|
103
|
+
ks_error << 'Currency Code is invalid'
|
104
|
+
success = false
|
105
|
+
puts "Check for currency code is failed."
|
106
|
+
end
|
107
|
+
return success
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: koduc_express_paypal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Koduc
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,9 +80,10 @@ dependencies:
|
|
80
80
|
- - ~>
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '1.4'
|
83
|
-
description:
|
84
|
-
This gem is written by KSolves. The main
|
85
|
-
one time Paypal payment using express checkout
|
83
|
+
description: koduc_express_paypal is a simple gem used for Paypal Payment Gateway
|
84
|
+
integration with partial and full refunds. This gem is written by KSolves. The main
|
85
|
+
aim of this project is to deal with the one time Paypal payment using express checkout
|
86
|
+
method using NVP(Name Value Pair). One can also make partial and full refunds.
|
86
87
|
email:
|
87
88
|
- ratan@ksolves.com
|
88
89
|
executables: []
|
@@ -107,6 +108,8 @@ files:
|
|
107
108
|
- lib/koduc_express_paypal/koduc_response.rb
|
108
109
|
- lib/koduc_express_paypal/koduc_validation.rb
|
109
110
|
- lib/koduc_express_paypal/version.rb
|
111
|
+
- lib/koduc_refund/koduc_refund.rb
|
112
|
+
- lib/koduc_refund/koduc_refund_validation.rb
|
110
113
|
homepage: https://github.com/kartiksolves/koduc-paypal-express
|
111
114
|
licenses:
|
112
115
|
- MIT
|
@@ -119,7 +122,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
119
122
|
requirements:
|
120
123
|
- - ! '>='
|
121
124
|
- !ruby/object:Gem::Version
|
122
|
-
version:
|
125
|
+
version: 1.9.3
|
123
126
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
127
|
requirements:
|
125
128
|
- - ! '>='
|
@@ -130,6 +133,7 @@ rubyforge_project:
|
|
130
133
|
rubygems_version: 2.4.3
|
131
134
|
signing_key:
|
132
135
|
specification_version: 4
|
133
|
-
summary: Gem deals with express checkout one time Paypal Payment using NVP Gateway
|
136
|
+
summary: Gem deals with express checkout one time Paypal Payment using NVP Gateway
|
137
|
+
with partial and full refunds.
|
134
138
|
test_files: []
|
135
139
|
has_rdoc:
|