khipu-api-client 2.1.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +66 -11
- data/lib/khipu-api-client/api_client.rb +1 -1
- data/lib/khipu-api-client/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f3b1dd67d2d2f7fa65933cfe213bc1347b8b74b
|
4
|
+
data.tar.gz: 34800d25548638e9f9b3c540ba5daf23a8448bff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f94742a27a6a1356fa4e2d0de3b23e4009e6648ec66801d0b6aa7d632a8742d72567af1d87d49c51318661418657d4c0c475f27d1f0f27767cf9cfb1a3f49ad2
|
7
|
+
data.tar.gz: 9547c77ce0960fb8b7adb408843f1d9e4819418ba4006ca85dca94b255ab9899b9358abcb4a37cf9b841f28870992b4cf4d98c695b2ac9dc117937648df22f8f
|
data/README.md
CHANGED
@@ -1,26 +1,81 @@
|
|
1
1
|
## Installation
|
2
2
|
|
3
|
-
```
|
3
|
+
```sh
|
4
4
|
gem install khipu-api-client
|
5
5
|
```
|
6
6
|
|
7
7
|
## Usage
|
8
8
|
|
9
|
-
### Basic
|
9
|
+
### Basic configuration
|
10
10
|
```ruby
|
11
11
|
require 'khipu-api-client'
|
12
12
|
|
13
13
|
Khipu.configure do |c|
|
14
|
-
c.secret
|
14
|
+
c.secret = 'abc123'
|
15
15
|
c.receiver_id = 1234
|
16
16
|
end
|
17
|
+
```
|
18
|
+
|
19
|
+
### Basic usage
|
20
|
+
|
21
|
+
#### Create a new payment
|
22
|
+
```ruby
|
23
|
+
api = Khipu::PaymentsApi.new()
|
24
|
+
options = {
|
25
|
+
expires_date: 1.day.from_now.to_datetime, # DateTime.new(2016,1,1)
|
26
|
+
send_email: true,
|
27
|
+
payer_name: "payer",
|
28
|
+
payer_email: "payer@mail.com"
|
29
|
+
}
|
30
|
+
response = api.payments_post("Test de api nueva", "CLP", 1, options)
|
31
|
+
|
32
|
+
print response
|
33
|
+
# response keys:
|
34
|
+
# [:payment_id, :payment_url, :simplified_transfer_url, :transfer_url, :app_url]
|
35
|
+
|
36
|
+
```
|
37
|
+
|
38
|
+
There are a more params you can send in each request. You might want to consider adding these to the options:
|
39
|
+
|
40
|
+
```
|
41
|
+
transaction_id # transaction id in your system
|
42
|
+
return_url # after (potential) success, the client will be redirected to this url
|
43
|
+
cancel_url # if the payment is canceled, the client will be redirected to this url
|
44
|
+
notify_url # khipu will send a notification to this url - the client will not see this request
|
45
|
+
notify_api_version # "1.3"
|
46
|
+
```
|
47
|
+
|
48
|
+
#### Ask for payment status
|
49
|
+
```
|
50
|
+
api = Khipu::PaymentsApi.new()
|
51
|
+
status = api.payments_id_get(response.payment_id)
|
52
|
+
print status
|
53
|
+
```
|
54
|
+
|
55
|
+
|
56
|
+
#### Confirm a payment
|
57
|
+
If you send a notification_url when creating the payment or if you have set it up on your account configuration, Khipu will sent you a request with a notification_token and a api_version. You can use the notification_token param to get the payment information from the khipu service.
|
58
|
+
|
59
|
+
```
|
60
|
+
notification_token = params["notification_token"]
|
61
|
+
client = Khipu::PaymentsApi.new
|
62
|
+
response = client.payments_get(notification_token)
|
63
|
+
if response.status == 'done'
|
64
|
+
# order = get_order(response.transaction_id)
|
65
|
+
# if order != nil and is_valid?(order, response)
|
66
|
+
# setPurchased(order)
|
67
|
+
# end
|
68
|
+
end
|
17
69
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
70
|
+
print response
|
71
|
+
# response keys:
|
72
|
+
# [
|
73
|
+
# :payment_id, :payment_url, :simplified_transfer_url, :transfer_url,
|
74
|
+
# :app_url, :ready_for_terminal, :subject, :amount, :currency, :status,
|
75
|
+
# :status_detail, :body, :picture_url, :receipt_url, :return_url,
|
76
|
+
# :cancel_url, :notify_url, :notify_api_version, :expires_date,
|
77
|
+
# :attachment_urls, :bank, :bank_id, :payer_name, :payer_email,
|
78
|
+
# :personal_identifier, :bank_account_number, :out_of_date_conciliation,
|
79
|
+
# :transaction_id, :custom, :responsible_user_email, :send_reminders, :send_email
|
80
|
+
# ]
|
26
81
|
```
|
@@ -24,7 +24,7 @@ module Khipu
|
|
24
24
|
def initialize(host = nil)
|
25
25
|
@host = host || Configuration.base_url
|
26
26
|
@format = 'json'
|
27
|
-
@user_agent = "khipu-api-ruby-client/#{VERSION}" + "|" + Configuration.platform + "/" + Configuration.platform_version
|
27
|
+
@user_agent = "khipu-api-ruby-client/#{VERSION}" + "|" + (Configuration.platform || '') + "/" + (Configuration.platform_version || '')
|
28
28
|
@default_headers = {
|
29
29
|
'Content-Type' => "application/#{@format.downcase}",
|
30
30
|
'User-Agent' => @user_agent
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: khipu-api-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- khipu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|