pagseguro-oficial 2.5.0 → 2.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -1
- data/CONTRIBUTING.md +39 -0
- data/Dockerfile +20 -0
- data/README.md +22 -0
- data/docker-compose.yml +5 -0
- data/examples/checkout/create_payment_request.rb +1 -1
- data/examples/direct/create_transaction_using_boleto.rb +1 -1
- data/examples/direct/create_transaction_using_credit_card.rb +1 -1
- data/examples/direct/create_transaction_using_online_debit.rb +1 -1
- data/examples/preapproval/cancel_preapproval.rb +26 -0
- data/examples/preapproval/change_preapproval_payment.rb +50 -0
- data/examples/preapproval/change_preapproval_status.rb +29 -0
- data/examples/preapproval/charge_preapproval.rb +36 -0
- data/examples/preapproval/create_preapproval.rb +68 -0
- data/examples/preapproval/create_preapproval_auto.rb +53 -0
- data/examples/preapproval/create_preapproval_discount.rb +30 -0
- data/examples/preapproval/create_preapproval_manual.rb +58 -0
- data/examples/preapproval/create_preapproval_transparent.rb +41 -0
- data/examples/preapproval/preapproval_retry.rb +29 -0
- data/examples/preapproval/search/search_by_date_interval.rb +45 -0
- data/examples/preapproval/search/search_by_days_interval.rb +46 -0
- data/examples/preapproval/search/search_by_notification_code.rb +50 -0
- data/examples/preapproval/search/search_by_subscription_code.rb +50 -0
- data/examples/preapproval/search/search_subscription_payment_orders.rb +53 -0
- data/examples/split_payment/create_payment_request.rb +1 -1
- data/examples/split_payment/create_transaction_using_boleto.rb +118 -0
- data/examples/split_payment/create_transaction_using_credit_card.rb +152 -0
- data/lib/pagseguro.rb +33 -1
- data/lib/pagseguro/credit_card_transaction_request.rb +1 -1
- data/lib/pagseguro/document.rb +8 -0
- data/lib/pagseguro/holder.rb +8 -0
- data/lib/pagseguro/manual_subscription_charger.rb +59 -0
- data/lib/pagseguro/manual_subscription_charger/request_serializer.rb +50 -0
- data/lib/pagseguro/manual_subscription_charger/response.rb +36 -0
- data/lib/pagseguro/manual_subscription_charger/response_serializer.rb +17 -0
- data/lib/pagseguro/payment_request/request_serializer.rb +25 -1
- data/lib/pagseguro/receiver.rb +3 -0
- data/lib/pagseguro/request.rb +32 -2
- data/lib/pagseguro/sender.rb +21 -3
- data/lib/pagseguro/subscription.rb +132 -0
- data/lib/pagseguro/subscription/request_serializer.rb +129 -0
- data/lib/pagseguro/subscription/response.rb +49 -0
- data/lib/pagseguro/subscription/response_serializer.rb +62 -0
- data/lib/pagseguro/subscription/subscription_search.rb +135 -0
- data/lib/pagseguro/subscription_canceller.rb +30 -0
- data/lib/pagseguro/subscription_canceller/response.rb +34 -0
- data/lib/pagseguro/subscription_change_payment.rb +46 -0
- data/lib/pagseguro/subscription_change_payment/request_serializer.rb +80 -0
- data/lib/pagseguro/subscription_change_payment/response.rb +26 -0
- data/lib/pagseguro/subscription_change_status.rb +50 -0
- data/lib/pagseguro/subscription_change_status/request_serializer.rb +28 -0
- data/lib/pagseguro/subscription_change_status/response.rb +26 -0
- data/lib/pagseguro/subscription_discount.rb +41 -0
- data/lib/pagseguro/subscription_discount/request_serializer.rb +34 -0
- data/lib/pagseguro/subscription_discount/response.rb +34 -0
- data/lib/pagseguro/subscription_payment_method.rb +21 -0
- data/lib/pagseguro/subscription_payment_order.rb +57 -0
- data/lib/pagseguro/subscription_payment_order/response.rb +37 -0
- data/lib/pagseguro/subscription_payment_order/response_serializer.rb +51 -0
- data/lib/pagseguro/subscription_plan.rb +69 -0
- data/lib/pagseguro/subscription_plan/request_serializer.rb +81 -0
- data/lib/pagseguro/subscription_plan/response.rb +36 -0
- data/lib/pagseguro/subscription_plan/response_serializer.rb +17 -0
- data/lib/pagseguro/subscription_retry.rb +35 -0
- data/lib/pagseguro/subscription_retry/response.rb +34 -0
- data/lib/pagseguro/subscription_search_payment_orders.rb +131 -0
- data/lib/pagseguro/subscription_transaction.rb +29 -0
- data/lib/pagseguro/subscription_transactions.rb +5 -0
- data/lib/pagseguro/transaction.rb +0 -10
- data/lib/pagseguro/transaction/serializer.rb +19 -2
- data/lib/pagseguro/transaction_request.rb +26 -1
- data/lib/pagseguro/transaction_request/request_serializer.rb +164 -1
- data/lib/pagseguro/version.rb +1 -1
- data/spec/fixtures/manual_subscription_charger/fail.xml +6 -0
- data/spec/fixtures/manual_subscription_charger/success.xml +4 -0
- data/spec/fixtures/subscription/fail.xml +6 -0
- data/spec/fixtures/subscription/find_success.xml +28 -0
- data/spec/fixtures/subscription/search_success.xml +18 -0
- data/spec/fixtures/subscription/success.xml +4 -0
- data/spec/fixtures/subscription_canceller/fail.xml +6 -0
- data/spec/fixtures/subscription_change_payment/fail.xml +7 -0
- data/spec/fixtures/subscription_change_status/fail.xml +7 -0
- data/spec/fixtures/subscription_discount/fail.xml +6 -0
- data/spec/fixtures/subscription_payment_order/success.xml +18 -0
- data/spec/fixtures/subscription_plan/fail.xml +6 -0
- data/spec/fixtures/subscription_plan/success.xml +4 -0
- data/spec/fixtures/subscription_retry/fail.xml +7 -0
- data/spec/fixtures/subscription_search_payment_orders/success.xml +43 -0
- data/spec/fixtures/transactions/without_status_and_type.xml +71 -0
- data/spec/pagseguro/credit_card_transaction_request_spec.rb +1 -1
- data/spec/pagseguro/document_spec.rb +15 -0
- data/spec/pagseguro/holder_spec.rb +1 -0
- data/spec/pagseguro/manual_subscription_charger/request_serializer_spec.rb +79 -0
- data/spec/pagseguro/manual_subscription_charger/response_serializer_spec.rb +10 -0
- data/spec/pagseguro/manual_subscription_charger/response_spec.rb +65 -0
- data/spec/pagseguro/manual_subscription_charger_spec.rb +68 -0
- data/spec/pagseguro/payment_request/request_serializer_spec.rb +54 -22
- data/spec/pagseguro/receiver_spec.rb +1 -0
- data/spec/pagseguro/sender_spec.rb +16 -2
- data/spec/pagseguro/subscription/request_serializer_spec.rb +233 -0
- data/spec/pagseguro/subscription/response_serializer_spec.rb +46 -0
- data/spec/pagseguro/subscription/response_spec.rb +79 -0
- data/spec/pagseguro/subscription/subscription_search_spec.rb +154 -0
- data/spec/pagseguro/subscription_canceller/response_spec.rb +58 -0
- data/spec/pagseguro/subscription_canceller_spec.rb +57 -0
- data/spec/pagseguro/subscription_change_payment/request_serializer_spec.rb +150 -0
- data/spec/pagseguro/subscription_change_payment/response_spec.rb +41 -0
- data/spec/pagseguro/subscription_change_payment_spec.rb +60 -0
- data/spec/pagseguro/subscription_change_status/request_serializer_spec.rb +19 -0
- data/spec/pagseguro/subscription_change_status/response_spec.rb +41 -0
- data/spec/pagseguro/subscription_change_status_spec.rb +53 -0
- data/spec/pagseguro/subscription_discount/request_serializer_spec.rb +27 -0
- data/spec/pagseguro/subscription_discount/response_spec.rb +58 -0
- data/spec/pagseguro/subscription_discount_spec.rb +60 -0
- data/spec/pagseguro/subscription_payment_method_spec.rb +10 -0
- data/spec/pagseguro/subscription_payment_order/response_serializer_spec.rb +24 -0
- data/spec/pagseguro/subscription_payment_order/response_spec.rb +55 -0
- data/spec/pagseguro/subscription_payment_order_spec.rb +27 -0
- data/spec/pagseguro/subscription_plan/request_serializer_spec.rb +253 -0
- data/spec/pagseguro/subscription_plan/response_serializer_spec.rb +10 -0
- data/spec/pagseguro/subscription_plan/response_spec.rb +65 -0
- data/spec/pagseguro/subscription_plan_spec.rb +118 -0
- data/spec/pagseguro/subscription_retry/response_spec.rb +58 -0
- data/spec/pagseguro/subscription_retry_spec.rb +62 -0
- data/spec/pagseguro/subscription_search_payment_order_spec.rb +129 -0
- data/spec/pagseguro/subscription_spec.rb +137 -0
- data/spec/pagseguro/subscription_transaction_spec.rb +24 -0
- data/spec/pagseguro/subscription_transactions_spec.rb +37 -0
- data/spec/pagseguro/transaction/response_spec.rb +0 -42
- data/spec/pagseguro/transaction/serializer_spec.rb +5 -6
- data/spec/pagseguro/transaction_request/request_serializer_spec.rb +623 -159
- data/spec/pagseguro/transaction_request_spec.rb +26 -0
- data/spec/pagseguro/transaction_spec.rb +0 -48
- data/spec/spec_helper.rb +1 -0
- metadata +154 -8
- data/examples/checkout/search/search_transaction_status_history.rb +0 -22
- data/lib/pagseguro/transaction/status_collection.rb +0 -20
- data/spec/fixtures/transactions/status_history.xml +0 -12
- data/spec/pagseguro/transaction/status_collection_spec.rb +0 -43
@@ -0,0 +1,58 @@
|
|
1
|
+
require_relative '../boot'
|
2
|
+
|
3
|
+
# Create a Subscription Plan (Manual charge)
|
4
|
+
#
|
5
|
+
# You need to set your AccountCredentials (EMAIL, TOKEN) in the application config
|
6
|
+
#
|
7
|
+
# P.S: See the boot file example for more details.
|
8
|
+
|
9
|
+
email = 'EMAIL'
|
10
|
+
token = 'TOKEN'
|
11
|
+
|
12
|
+
plan = PagSeguro::SubscriptionPlan.new(
|
13
|
+
charge: 'manual', # Manual Subscription Plan must always use manual charge type.
|
14
|
+
redirect_url: 'http://www.lojateste.com.br/redirect',
|
15
|
+
review_url: 'http://www.lojateste.com.br/review',
|
16
|
+
reference: 'REFERENCE',
|
17
|
+
|
18
|
+
sender: {
|
19
|
+
name: 'Nome do Cliente',
|
20
|
+
email: 'client@example.com',
|
21
|
+
phone: { area_code: 11, number: 123456 },
|
22
|
+
address: {
|
23
|
+
street: 'Av Brigadeira Faria Lima',
|
24
|
+
number: '1384',
|
25
|
+
complement: '3 andar',
|
26
|
+
district: 'Jd Paulistano',
|
27
|
+
city: 'Sao Paulo',
|
28
|
+
state: 'SP',
|
29
|
+
country: 'BRA',
|
30
|
+
postal_code: '01452002'
|
31
|
+
}
|
32
|
+
},
|
33
|
+
|
34
|
+
name: 'Insurance',
|
35
|
+
details: 'Payment of 100.',
|
36
|
+
amount: 100.0,
|
37
|
+
period: 'Monthly',
|
38
|
+
max_payments_per_period: 2,
|
39
|
+
max_amount_per_period: 200.0,
|
40
|
+
initial_date: Time.new(2016, 4, 19, 0, 0),
|
41
|
+
final_date: Time.new(2017, 1, 1, 0, 0),
|
42
|
+
max_total_amount: 2_400.0
|
43
|
+
)
|
44
|
+
|
45
|
+
# Edit the lines above.
|
46
|
+
|
47
|
+
plan.credentials = PagSeguro::AccountCredentials.new(email, token)
|
48
|
+
plan.create
|
49
|
+
|
50
|
+
if plan.errors.any?
|
51
|
+
puts '=> ERRORS'
|
52
|
+
puts plan.errors.join('\n')
|
53
|
+
else
|
54
|
+
print '=> Subscription Plan correct created, its code is '
|
55
|
+
puts plan.code
|
56
|
+
puts '=> And your client can finish the subscription using this url:'
|
57
|
+
puts plan.url
|
58
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require_relative '../boot'
|
2
|
+
|
3
|
+
# Create a Subscription Plan (Transparent Checkout).
|
4
|
+
#
|
5
|
+
# You need to set your AccountCredentials (EMAIL, TOKEN) in the application config
|
6
|
+
#
|
7
|
+
# P.S: See the boot file example for more details.
|
8
|
+
|
9
|
+
email = 'EMAIL'
|
10
|
+
token = 'TOKEN'
|
11
|
+
|
12
|
+
plan = PagSeguro::SubscriptionPlan.new(
|
13
|
+
charge: 'auto',
|
14
|
+
|
15
|
+
redirect_url: 'http://www.lojateste.com.br/redirect',
|
16
|
+
review_url: 'http://www.lojateste.com.br/review',
|
17
|
+
|
18
|
+
name: 'Test',
|
19
|
+
period: 'Monthly',
|
20
|
+
amount: 100.0,
|
21
|
+
max_total_amount: 2400.0,
|
22
|
+
final_date: Time.new(2017, 2, 28, 20, 20),
|
23
|
+
membership_fee: 150.0,
|
24
|
+
trial_duration: 28,
|
25
|
+
)
|
26
|
+
|
27
|
+
# Edit the lines above.
|
28
|
+
|
29
|
+
plan.credentials = PagSeguro::AccountCredentials.new(email, token)
|
30
|
+
plan.create
|
31
|
+
|
32
|
+
if plan.errors.any?
|
33
|
+
puts '=> ERRORS'
|
34
|
+
puts plan.errors.join('\n')
|
35
|
+
else
|
36
|
+
print '=> Subscription Plan correct created, its code is '
|
37
|
+
puts plan.code
|
38
|
+
|
39
|
+
puts %[=> Now you need to subscribe your client to this plan (see
|
40
|
+
examples/preapproval/create_preapproval.rb).]
|
41
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require_relative "../boot"
|
2
|
+
|
3
|
+
# Retry a subscription payment.
|
4
|
+
#
|
5
|
+
# P.S: Take a look at the boot file example for more details
|
6
|
+
|
7
|
+
email = 'EMAIL'
|
8
|
+
token = 'TOKEN'
|
9
|
+
subscription_code = 'CODE'
|
10
|
+
payment_order_code = 'PAYMENT'
|
11
|
+
|
12
|
+
# Edit the lines above
|
13
|
+
|
14
|
+
credentials = PagSeguro::AccountCredentials.new(email, token)
|
15
|
+
|
16
|
+
subscription_retry = PagSeguro::SubscriptionRetry.new(
|
17
|
+
subscription_code: subscription_code,
|
18
|
+
payment_order_code: payment_order_code
|
19
|
+
)
|
20
|
+
subscription_retry.credentials = credentials
|
21
|
+
subscription_retry.save
|
22
|
+
|
23
|
+
if subscription_retry.errors.any?
|
24
|
+
puts "ERRORS: "
|
25
|
+
puts subscription_retry.errors.inspect
|
26
|
+
else
|
27
|
+
puts "SUCCESS"
|
28
|
+
puts subscription_retry.inspect
|
29
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require_relative '../../boot'
|
2
|
+
|
3
|
+
# Search Subscriptions by date interval
|
4
|
+
#
|
5
|
+
# You need to give AccountCredentials (EMAIL, TOKEN) and some date interval
|
6
|
+
#
|
7
|
+
# P.S: See the boot file example for more details.
|
8
|
+
|
9
|
+
email = 'user@example.com'
|
10
|
+
token = 'TOKEN'
|
11
|
+
|
12
|
+
credentials = PagSeguro::AccountCredentials.new(email, token)
|
13
|
+
options = {
|
14
|
+
credentials: credentials,
|
15
|
+
starts_at: Time.new(2016,3,15),
|
16
|
+
ends_at: Time.new(2016,3,24),
|
17
|
+
per_page: 10
|
18
|
+
}
|
19
|
+
report = PagSeguro::Subscription.search_by_date_interval(options)
|
20
|
+
|
21
|
+
if report.valid?
|
22
|
+
puts "====== Report ======"
|
23
|
+
|
24
|
+
while report.next_page?
|
25
|
+
report.next_page!
|
26
|
+
|
27
|
+
puts "=> Page #{report.page}/#{report.total_pages}"
|
28
|
+
report.subscriptions.each_with_index do |subscription, index|
|
29
|
+
puts "Subscription #{index+1}/#{report.results}:"
|
30
|
+
puts " code: #{subscription.code}"
|
31
|
+
puts " name: #{subscription.name}"
|
32
|
+
puts " date: #{subscription.date}"
|
33
|
+
puts " tracker: #{subscription.tracker}"
|
34
|
+
puts " status: #{subscription.status}"
|
35
|
+
puts " last event date: #{subscription.last_event_date}"
|
36
|
+
puts " charge: #{subscription.charge}"
|
37
|
+
puts " reference: #{subscription.reference}"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
puts "- End page"
|
42
|
+
else
|
43
|
+
puts "Errors:"
|
44
|
+
puts report.errors.join("\n")
|
45
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require_relative '../../boot'
|
2
|
+
|
3
|
+
# Search Subscriptions by days interval
|
4
|
+
# PS: Since it has receipt some notification in the interval
|
5
|
+
#
|
6
|
+
# You need to give AccountCredentials (EMAIL, TOKEN) and some days interval
|
7
|
+
#
|
8
|
+
# P.S: See the boot file example for more details.
|
9
|
+
|
10
|
+
email = 'user@example.com'
|
11
|
+
token = 'TOKEN'
|
12
|
+
interval = 30
|
13
|
+
|
14
|
+
credentials = PagSeguro::AccountCredentials.new('user@example.com', 'TOKEN')
|
15
|
+
options = {
|
16
|
+
credentials: credentials,
|
17
|
+
interval: interval
|
18
|
+
}
|
19
|
+
report = PagSeguro::Subscription.search_by_days_interval(options)
|
20
|
+
|
21
|
+
if report.valid?
|
22
|
+
puts "====== Report ======"
|
23
|
+
|
24
|
+
while report.next_page?
|
25
|
+
report.next_page!
|
26
|
+
|
27
|
+
puts "=> Page #{report.page}/#{report.total_pages}"
|
28
|
+
report.subscriptions.each_with_index do |subscription, index|
|
29
|
+
puts "Subscription #{index+1}/#{report.results}:"
|
30
|
+
puts " code: #{subscription.code}"
|
31
|
+
puts " name: #{subscription.name}"
|
32
|
+
puts " date: #{subscription.date}"
|
33
|
+
puts " tracker: #{subscription.tracker}"
|
34
|
+
puts " status: #{subscription.status}"
|
35
|
+
puts " last event date: #{subscription.last_event_date}"
|
36
|
+
puts " charge: #{subscription.charge}"
|
37
|
+
puts " reference: #{subscription.reference}"
|
38
|
+
end
|
39
|
+
|
40
|
+
puts "- End page "
|
41
|
+
end
|
42
|
+
puts " - End report"
|
43
|
+
else
|
44
|
+
puts "Errors:"
|
45
|
+
puts report.errors.join("\n")
|
46
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require_relative '../../boot'
|
2
|
+
|
3
|
+
# Find a Subscription by notification code
|
4
|
+
#
|
5
|
+
# You need to give AccountCredentials (EMAIL, TOKEN) and the notification code
|
6
|
+
#
|
7
|
+
# P.S: See the boot file example for more details.
|
8
|
+
|
9
|
+
email = 'user@example.com'
|
10
|
+
token = 'TOKEN'
|
11
|
+
code = 'NOTIFICATION_CODE'
|
12
|
+
|
13
|
+
credentials = PagSeguro::AccountCredentials.new(email, token)
|
14
|
+
subscription = PagSeguro::Subscription.find_by_notification_code(code, credentials: credentials)
|
15
|
+
|
16
|
+
if subscription.errors.empty?
|
17
|
+
puts "Subscription:"
|
18
|
+
puts " code: #{subscription.code}"
|
19
|
+
puts " name: #{subscription.name}"
|
20
|
+
puts " date: #{subscription.date}"
|
21
|
+
puts " tracker: #{subscription.tracker}"
|
22
|
+
puts " status: #{subscription.status}"
|
23
|
+
puts " reference: #{subscription.reference}"
|
24
|
+
puts " last event date: #{subscription.last_event_date}"
|
25
|
+
puts " charge: #{subscription.charge}"
|
26
|
+
|
27
|
+
if subscription.sender
|
28
|
+
puts " sender.name: #{subscription.sender.name}"
|
29
|
+
puts " sender.email: #{subscription.sender.email}"
|
30
|
+
|
31
|
+
if subscription.sender.phone
|
32
|
+
puts " sender.phone.area_code: #{subscription.sender.phone.area_code}"
|
33
|
+
puts " sender.phone.number: #{subscription.sender.phone.number}"
|
34
|
+
end
|
35
|
+
|
36
|
+
if subscription.sender.address
|
37
|
+
puts " sender.address.street: #{subscription.sender.address.street}"
|
38
|
+
puts " sender.address.number: #{subscription.sender.address.number}"
|
39
|
+
puts " sender.address.complement: #{subscription.sender.address.complement}"
|
40
|
+
puts " sender.address.district: #{subscription.sender.address.district}"
|
41
|
+
puts " sender.address.city: #{subscription.sender.address.city}"
|
42
|
+
puts " sender.address.state: #{subscription.sender.address.state}"
|
43
|
+
puts " sender.address.postal_code: #{subscription.sender.address.postal_code}"
|
44
|
+
puts " sender.address.country: #{subscription.sender.address.country}"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
else
|
48
|
+
puts "Errors:"
|
49
|
+
puts subscription.errors.join("\n")
|
50
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require_relative '../../boot'
|
2
|
+
|
3
|
+
# Find a Subscription by code
|
4
|
+
#
|
5
|
+
# You need to give AccountCredentials (EMAIL, TOKEN) and the subscription code
|
6
|
+
#
|
7
|
+
# P.S: See the boot file example for more details.
|
8
|
+
|
9
|
+
email = 'user@example.com'
|
10
|
+
token = 'TOKEN'
|
11
|
+
code = 'CODE'
|
12
|
+
|
13
|
+
credentials = PagSeguro::AccountCredentials.new(email, token)
|
14
|
+
subscription = PagSeguro::Subscription.find_by_code(code, credentials: credentials)
|
15
|
+
|
16
|
+
if subscription.errors.empty?
|
17
|
+
puts "Subscription:"
|
18
|
+
puts " code: #{subscription.code}"
|
19
|
+
puts " name: #{subscription.name}"
|
20
|
+
puts " date: #{subscription.date}"
|
21
|
+
puts " tracker: #{subscription.tracker}"
|
22
|
+
puts " status: #{subscription.status}"
|
23
|
+
puts " reference: #{subscription.reference}"
|
24
|
+
puts " last event date: #{subscription.last_event_date}"
|
25
|
+
puts " charge: #{subscription.charge}"
|
26
|
+
|
27
|
+
if subscription.sender
|
28
|
+
puts " sender.name: #{subscription.sender.name}"
|
29
|
+
puts " sender.email: #{subscription.sender.email}"
|
30
|
+
|
31
|
+
if subscription.sender.phone
|
32
|
+
puts " sender.phone.area_code: #{subscription.sender.phone.area_code}"
|
33
|
+
puts " sender.phone.number: #{subscription.sender.phone.number}"
|
34
|
+
end
|
35
|
+
|
36
|
+
if subscription.sender.address
|
37
|
+
puts " sender.address.street: #{subscription.sender.address.street}"
|
38
|
+
puts " sender.address.number: #{subscription.sender.address.number}"
|
39
|
+
puts " sender.address.complement: #{subscription.sender.address.complement}"
|
40
|
+
puts " sender.address.district: #{subscription.sender.address.district}"
|
41
|
+
puts " sender.address.city: #{subscription.sender.address.city}"
|
42
|
+
puts " sender.address.state: #{subscription.sender.address.state}"
|
43
|
+
puts " sender.address.postal_code: #{subscription.sender.address.postal_code}"
|
44
|
+
puts " sender.address.country: #{subscription.sender.address.country}"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
else
|
48
|
+
puts "Errors:"
|
49
|
+
puts subscription.errors.join("\n")
|
50
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require_relative '../../boot'
|
2
|
+
|
3
|
+
code = 'CODE'
|
4
|
+
status = :processing # Availables: [ :scheduled, :processing, :not_processed, :suspended, :paid, :not_paid ]
|
5
|
+
email = 'EMAIL'
|
6
|
+
token = 'TOKEN'
|
7
|
+
|
8
|
+
credentials = PagSeguro::AccountCredentials.new(email, token)
|
9
|
+
|
10
|
+
options = { credentials: credentials }
|
11
|
+
|
12
|
+
report = PagSeguro::SubscriptionSearchPaymentOrders.new(code, status, options)
|
13
|
+
|
14
|
+
if report.valid?
|
15
|
+
puts "====== Report ======"
|
16
|
+
|
17
|
+
while report.next_page?
|
18
|
+
report.next_page!
|
19
|
+
|
20
|
+
puts "=> Page #{report.page}/#{report.total_pages}"
|
21
|
+
report.payment_orders.each_with_index do |order, index|
|
22
|
+
puts "Payment Order #{index}:"
|
23
|
+
puts " Code: #{order.code}"
|
24
|
+
puts " Status: #{order.status}"
|
25
|
+
puts " Amount: #{order.amount}"
|
26
|
+
puts " Gross amount: #{order.gross_amount}"
|
27
|
+
puts " Last event date: #{order.last_event_date}"
|
28
|
+
puts " Scheduling date: #{order.scheduling_date}"
|
29
|
+
|
30
|
+
if order.discount
|
31
|
+
puts "Discount:"
|
32
|
+
puts " Discount: #{order.discount.type}"
|
33
|
+
puts " Discount: #{order.discount.value}"
|
34
|
+
puts " Discount: #{order.discount.code}"
|
35
|
+
end
|
36
|
+
|
37
|
+
if order.transactions.any?
|
38
|
+
order.transactions.each_with_index do |transaction, index|
|
39
|
+
puts "Transaction #{index+1}/#{order.transactions.size}"
|
40
|
+
puts " Transaction code: #{transaction.code}"
|
41
|
+
puts " Transaction status: #{transaction.status}"
|
42
|
+
puts " Transaction date: #{transaction.date}"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
puts "- End page"
|
47
|
+
puts
|
48
|
+
end
|
49
|
+
|
50
|
+
else
|
51
|
+
puts "Errors:"
|
52
|
+
puts report.errors.join("\n")
|
53
|
+
end
|
@@ -0,0 +1,118 @@
|
|
1
|
+
require_relative "../boot"
|
2
|
+
|
3
|
+
# Create Transaction Using Boleto and Split Payment
|
4
|
+
#
|
5
|
+
# You need to set your AccountCredentials (EMAIL, TOKEN) in the application config
|
6
|
+
#
|
7
|
+
# P.S: See the boot file example for more details
|
8
|
+
|
9
|
+
payment = PagSeguro::BoletoTransactionRequest.new
|
10
|
+
payment.notification_url = "http://www.example.com/notification"
|
11
|
+
payment.payment_mode = "default"
|
12
|
+
payment.credentials = PagSeguro::ApplicationCredentials.new("APP_ID", "APP_KEY")
|
13
|
+
|
14
|
+
payment.items << {
|
15
|
+
id: 1234,
|
16
|
+
description: %[Televisão 19" Sony],
|
17
|
+
amount: 50.0,
|
18
|
+
weight: 0
|
19
|
+
}
|
20
|
+
|
21
|
+
payment.reference = "REF1234-boleto"
|
22
|
+
payment.sender = {
|
23
|
+
hash: "32fb09327a27b0a09a194a21d00be6d922fba5cfcdba03f15b3408029b56d41a",
|
24
|
+
name: "Joao Comprador",
|
25
|
+
email: "joao.comprador@sandbox.pagseguro.com.br",
|
26
|
+
document: { type: "CPF", value: "75073461100" },
|
27
|
+
phone: {
|
28
|
+
area_code: 11,
|
29
|
+
number: "12345678"
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
payment.shipping = {
|
34
|
+
type_name: "sedex",
|
35
|
+
address: {
|
36
|
+
street: "Av. Brig. Faria Lima",
|
37
|
+
number: "1384",
|
38
|
+
complement: "5º andar",
|
39
|
+
city: "São Paulo",
|
40
|
+
state: "SP",
|
41
|
+
district: "Jardim Paulistano",
|
42
|
+
postal_code: "01452002"
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
payment.receivers = [
|
47
|
+
{
|
48
|
+
public_key: 'PUBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
|
49
|
+
split: {
|
50
|
+
amount: 20.0,
|
51
|
+
rate_percent: 50.0,
|
52
|
+
fee_percent: 50.0
|
53
|
+
}
|
54
|
+
}
|
55
|
+
]
|
56
|
+
|
57
|
+
# Add extras params to request
|
58
|
+
# payment.extra_params << { paramName: 'paramValue' }
|
59
|
+
# payment.extra_params << { senderBirthDate: '07/05/1981' }
|
60
|
+
|
61
|
+
puts "=> REQUEST"
|
62
|
+
puts PagSeguro::TransactionRequest::RequestSerializer.new(payment).to_params
|
63
|
+
puts
|
64
|
+
|
65
|
+
payment.create
|
66
|
+
|
67
|
+
if payment.errors.any?
|
68
|
+
puts "=> ERRORS"
|
69
|
+
puts payment.errors.join("\n")
|
70
|
+
else
|
71
|
+
puts "=> Transaction"
|
72
|
+
puts " code: #{payment.code}"
|
73
|
+
puts " reference: #{payment.reference}"
|
74
|
+
puts " type: #{payment.type_id}"
|
75
|
+
puts " payment link: #{payment.payment_link}"
|
76
|
+
puts " status: #{payment.status}"
|
77
|
+
puts " payment method type: #{payment.payment_method}"
|
78
|
+
puts " created at: #{payment.created_at}"
|
79
|
+
puts " updated at: #{payment.updated_at}"
|
80
|
+
puts " gross amount: #{payment.gross_amount.to_f}"
|
81
|
+
puts " discount amount: #{payment.discount_amount.to_f}"
|
82
|
+
puts " net amount: #{payment.net_amount.to_f}"
|
83
|
+
puts " extra amount: #{payment.extra_amount.to_f}"
|
84
|
+
puts " installment count: #{payment.installment_count}"
|
85
|
+
|
86
|
+
puts " => Items"
|
87
|
+
puts " items count: #{payment.items.size}"
|
88
|
+
payment.items.each do |item|
|
89
|
+
puts " item id: #{item.id}"
|
90
|
+
puts " description: #{item.description}"
|
91
|
+
puts " quantity: #{item.quantity}"
|
92
|
+
puts " amount: #{item.amount.to_f}"
|
93
|
+
end
|
94
|
+
|
95
|
+
puts " => Receivers"
|
96
|
+
puts " receivers count: #{payment.receivers.size}"
|
97
|
+
payment.receivers.each do |receiver|
|
98
|
+
puts " email: #{receiver.email}"
|
99
|
+
puts " amount: #{receiver.split.amount}"
|
100
|
+
end
|
101
|
+
|
102
|
+
puts " => Sender"
|
103
|
+
puts " name: #{payment.sender.name}"
|
104
|
+
puts " email: #{payment.sender.email}"
|
105
|
+
puts " phone: (#{payment.sender.phone.area_code}) #{payment.sender.phone.number}"
|
106
|
+
puts " document: #{payment.sender.document}"
|
107
|
+
|
108
|
+
puts " => Shipping"
|
109
|
+
puts " street: #{payment.shipping.address.street}, #{payment.shipping.address.number}"
|
110
|
+
puts " complement: #{payment.shipping.address.complement}"
|
111
|
+
puts " postal code: #{payment.shipping.address.postal_code}"
|
112
|
+
puts " district: #{payment.shipping.address.district}"
|
113
|
+
puts " city: #{payment.shipping.address.city}"
|
114
|
+
puts " state: #{payment.shipping.address.state}"
|
115
|
+
puts " country: #{payment.shipping.address.country}"
|
116
|
+
puts " type: #{payment.shipping.type_name}"
|
117
|
+
puts " cost: #{payment.shipping.cost}"
|
118
|
+
end
|