khipu-api-client 2.1.0 → 2.1.1

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: 921ecdf7f73df0184edab322a2f6a92f9c8f2728
4
- data.tar.gz: c789b369dbc547d31bcf3940316271d5c54efe51
3
+ metadata.gz: 2f3b1dd67d2d2f7fa65933cfe213bc1347b8b74b
4
+ data.tar.gz: 34800d25548638e9f9b3c540ba5daf23a8448bff
5
5
  SHA512:
6
- metadata.gz: 216e2b50d3011b2514cdc172e39bf9f28928ffb72ada0c04ae14497dc2f03931fcb1c681efc486ce1c6c3c6c36fe183e0ed1ab249b1ad48e46603f1494bc0c4d
7
- data.tar.gz: be0aaee7971a357391de50117f4cd4e656d04a569ba9eaa8136e60097c6f29a2889be56887055995932d7d860bb30f3288fdb4775ab787bf25b3258fe02fc50d
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 usage
9
+ ### Basic configuration
10
10
  ```ruby
11
11
  require 'khipu-api-client'
12
12
 
13
13
  Khipu.configure do |c|
14
- c.secret = 'abc123'
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
- api = Khipu::PaymentsApi.new()
19
- r1 = api.payments_post("Test de api nueva", "CLP", 1,
20
- {expires_date: DateTime.new(2016,4,4),
21
- send_email: true, payer_name: "payer",
22
- payer_email: "payer@mail.com"})
23
- print r1
24
- r2 = api.payments_id_get(r1.payment_id)
25
- print r2
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
@@ -1,3 +1,3 @@
1
1
  module Khipu
2
- VERSION = "2.1.0"
2
+ VERSION = "2.1.1"
3
3
  end
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.0
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-09 00:00:00.000000000 Z
11
+ date: 2015-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus