Skip to content

Commit b2da38a

Browse files
committed
Added Payment Feedback API
1 parent eecc457 commit b2da38a

8 files changed

Lines changed: 111 additions & 3 deletions

File tree

docs/source/code.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ Retrieve geolocation information for an IP address.
111111
| username | string | (optional) User's username. |
112112
| email | string | (optional) User's email address. |
113113
| phone | string | (optional) User's phone number. |
114+
| bill_to | string | (optional) Billing details such as company name. |
114115
| bill_addr | string | (optional) Street address of billing address. |
115116
| bill_city | string | (optional) City of billing address. |
116117
| bill_state | string | (optional) State of billing address. It supports state codes, e.g. NY (New York), for state or province of United States or Canada.|
@@ -246,4 +247,33 @@ Get SMS Verification result.
246247
| Parameter | Type | Description |
247248
|-------------------|--------|-------------|
248249
| result | string | Indicates if the input parameters matched a valid OTP. Y if a valid OTP is found and N if no valid OTP found. |
249-
```
250+
```
251+
252+
## Payment Class
253+
```{py:class} Payment(config_object)
254+
Initiate Payment class.
255+
256+
:param object config_object: (Required) The configuration object returned by Configuration Class.
257+
```
258+
259+
```{py:function} feedback(params)
260+
Report the final payment status back to the system, helping improve fraud detection and risk assessment
261+
262+
:param str params: (Required) Parameters of feedback details.
263+
264+
| Parameter | Type | Description |
265+
|--------------|---------|---------------------|
266+
| email | string | (required) Email address of the payment order. |
267+
| status | string | (required) Status of the payment order. |
268+
| message | string | (required) Message returned from the payment gateway for the payment order. |
269+
| fraudlabspro_id | string | (optional) Unique transaction Id generated by Fraud Check API. |
270+
271+
272+
:return: Returns the details about the feedback in JSON object.
273+
:rtype: Object
274+
275+
| Parameter | Type | Description |
276+
|-------------------|--------|-------------|
277+
| result | string | Indicates if submission is successful. |
278+
279+
```

docs/source/quickstart.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,21 @@ result = FraudlabsproRuby::Api::SMSVerification.verifySMS(
119119
tran_id: 'UNIQUE_TRANS_ID',
120120
otp: 'OTP_RECEIVED'
121121
)
122+
```
123+
124+
### Payment Feedback
125+
126+
You can report payment gateway feedback as below:
127+
128+
```ruby
129+
require 'fraudlabspro_ruby'
130+
131+
FraudlabsproRuby::Configuration.api_key = 'YOUR_API_KEY'
132+
133+
result = FraudlabsproRuby::Api::Payment.feedback(
134+
135+
status: 'declined',
136+
message: 'Call Issuer. Pick Up Card. (2047)',
137+
fraudlabspro_id: '20260131-O263CR'
138+
)
122139
```

fraudlabspro_ruby.gemspec

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@ Gem::Specification.new do |s|
2929
"lib/fraudlabspro_ruby/api.rb",
3030
"lib/fraudlabspro_ruby/api/order.rb",
3131
"lib/fraudlabspro_ruby/api/smsverification.rb",
32+
"lib/fraudlabspro_ruby/api/payment.rb",
3233
"lib/fraudlabspro_ruby/configuration.rb",
3334
"lib/fraudlabspro_ruby/version.rb",
3435
"spec/spec_helper.rb",
3536
"spec/fraudlabspro_ruby_fraudvalidation_spec.rb",
36-
"spec/fraudlabspro_ruby_smsverification_spec.rb"
37+
"spec/fraudlabspro_ruby_smsverification_spec.rb",
38+
"spec/fraudlabspro_ruby_payment_spec.rb"
3739
]
3840
if s.respond_to?(:metadata=)
3941
s.metadata = {

lib/fraudlabspro_ruby.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
require "fraudlabspro_ruby/api"
22
require "fraudlabspro_ruby/api/order"
33
require "fraudlabspro_ruby/api/smsverification"
4+
require "fraudlabspro_ruby/api/payment"
45
require "fraudlabspro_ruby/configuration"
56
require "fraudlabspro_ruby/version"
67

lib/fraudlabspro_ruby/api/order.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ def self.validate(params = {})
6565
'email' => params[:email] || '',
6666
'email_domain' => email_domain || '',
6767
'user_phone' => params[:phone] || '',
68+
'bill_to' => params[:bill_to] || '',
6869
'bill_addr' => params[:bill_addr] || '',
6970
'bill_city' => params[:bill_city] || '',
7071
'bill_state' => params[:bill_state] || '',
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
require 'uri'
2+
require 'net/http'
3+
require "fraudlabspro_ruby/configuration"
4+
require "fraudlabspro_ruby/version"
5+
6+
module FraudlabsproRuby
7+
module Api
8+
class Payment
9+
10+
# Report the final payment status back to the system, helping improve fraud detection and risk assessment.
11+
def self.feedback(params = {})
12+
uri = URI.parse("https://api.fraudlabspro.com/v2/payment/feedback")
13+
http = Net::HTTP.new(uri.host, uri.port)
14+
http.use_ssl = true
15+
request = Net::HTTP::Post.new(uri.request_uri)
16+
request.set_form_data({
17+
'key' => FraudlabsproRuby::Configuration.api_key,
18+
'format' => 'json',
19+
'source' => 'sdk-ruby',
20+
'source_version' => FraudlabsproRuby::VERSION,
21+
'email' => params[:email],
22+
'status' => params[:status],
23+
'message' => params[:message],
24+
'fraudlabspro_id' => params[:fraudlabspro_id] || ''
25+
})
26+
27+
response = http.request(request)
28+
29+
if response == nil
30+
return false
31+
else
32+
return response
33+
end
34+
end
35+
36+
end
37+
end
38+
end

lib/fraudlabspro_ruby/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module FraudlabsproRuby
2-
VERSION = "4.0.1"
2+
VERSION = "4.1.0"
33
end
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2+
3+
describe "FraudlabsproRuby" do
4+
it "work correctly with payment feedback" do
5+
FraudlabsproRuby::Configuration.api_key = $test_api_key
6+
result = FraudlabsproRuby::Api::Payment.feedback(
7+
email: '',
8+
status: 'declined',
9+
message: 'Call Issuer. Pick Up Card. (2047)'
10+
)
11+
data = JSON.parse(result.body)
12+
if $test_api_key == 'YOUR_API_KEY'
13+
expect(data['error']['error_message']).to eq 'INVALID API KEY'
14+
else
15+
expect(data['error']['error_message']).to eq 'INVALID EMAIL ADDRESS'
16+
end
17+
end
18+
19+
end

0 commit comments

Comments
 (0)