pagseguro-sdk 2.6.2
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 +7 -0
- data/.github/.gitignore +204 -0
- data/.github/ISSUE_TEMPLATE/relatorio-de-bug.md +29 -0
- data/.github/workflows/codacy-analysis.yml +46 -0
- data/.gitignore +28 -0
- data/.rspec +1 -0
- data/.travis.yml +13 -0
- data/CHANGELOG.md +95 -0
- data/CONTRIBUTING.md +39 -0
- data/Dockerfile +20 -0
- data/Gemfile +2 -0
- data/LICENSE-2.0.txt +177 -0
- data/README.md +436 -0
- data/Rakefile +5 -0
- data/docker-compose.yml +5 -0
- data/docs/transparent_checkout.md +201 -0
- data/examples/authorization/create_authorization.rb +32 -0
- data/examples/authorization/create_authorization_with_account.rb +56 -0
- data/examples/authorization/search/search_authorization_by_code.rb +29 -0
- data/examples/authorization/search/search_authorization_by_date.rb +35 -0
- data/examples/authorization/search/search_authorization_by_notification_code.rb +29 -0
- data/examples/authorization/search/search_authorization_by_reference.rb +31 -0
- data/examples/boot.rb +26 -0
- data/examples/checkout/create_payment_request.rb +63 -0
- data/examples/checkout/search/search_abandoned_transactions.rb +41 -0
- data/examples/checkout/search/search_transaction_by_code.rb +76 -0
- data/examples/checkout/search/search_transaction_by_notification_code.rb +76 -0
- data/examples/checkout/search/search_transaction_by_reference.rb +36 -0
- data/examples/checkout/search/search_transactions_by_date.rb +45 -0
- data/examples/create_session.rb +19 -0
- data/examples/direct/create_transaction_using_boleto.rb +100 -0
- data/examples/direct/create_transaction_using_credit_card.rb +128 -0
- data/examples/direct/create_transaction_using_online_debit.rb +104 -0
- data/examples/get_installments.rb +40 -0
- 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/request_transaction_cancellation.rb +19 -0
- data/examples/split_payment/create_authorization.rb +32 -0
- data/examples/split_payment/create_payment_request.rb +71 -0
- 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-oficial.rb +1 -0
- data/lib/pagseguro.rb +221 -0
- data/lib/pagseguro/account.rb +29 -0
- data/lib/pagseguro/account_credentials.rb +14 -0
- data/lib/pagseguro/address.rb +40 -0
- data/lib/pagseguro/application_credentials.rb +18 -0
- data/lib/pagseguro/authorization.rb +61 -0
- data/lib/pagseguro/authorization/collection.rb +28 -0
- data/lib/pagseguro/authorization/request_serializer.rb +24 -0
- data/lib/pagseguro/authorization/response.rb +49 -0
- data/lib/pagseguro/authorization/response_serializer.rb +40 -0
- data/lib/pagseguro/authorization_request.rb +84 -0
- data/lib/pagseguro/authorization_request/request_serializer.rb +142 -0
- data/lib/pagseguro/authorization_request/response.rb +26 -0
- data/lib/pagseguro/authorization_request/response_serializer.rb +18 -0
- data/lib/pagseguro/bank.rb +8 -0
- data/lib/pagseguro/boleto_transaction_request.rb +8 -0
- data/lib/pagseguro/company.rb +41 -0
- data/lib/pagseguro/config.rb +34 -0
- data/lib/pagseguro/credit_card_transaction_request.rb +39 -0
- data/lib/pagseguro/creditor_fee.rb +23 -0
- data/lib/pagseguro/document.rb +23 -0
- data/lib/pagseguro/documents.rb +5 -0
- data/lib/pagseguro/errors.rb +57 -0
- data/lib/pagseguro/exceptions.rb +3 -0
- data/lib/pagseguro/extensions/collection_object.rb +34 -0
- data/lib/pagseguro/extensions/credentiable.rb +17 -0
- data/lib/pagseguro/extensions/ensure_type.rb +9 -0
- data/lib/pagseguro/extensions/mass_assignment.rb +11 -0
- data/lib/pagseguro/holder.rb +36 -0
- data/lib/pagseguro/installment.rb +57 -0
- data/lib/pagseguro/installment/collection.rb +25 -0
- data/lib/pagseguro/installment/request_serializer.rb +24 -0
- data/lib/pagseguro/installment/response.rb +37 -0
- data/lib/pagseguro/installment/response_serializer.rb +22 -0
- data/lib/pagseguro/item.rb +34 -0
- data/lib/pagseguro/items.rb +23 -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/notification.rb +11 -0
- data/lib/pagseguro/notification/authorization.rb +15 -0
- data/lib/pagseguro/notification/transaction.rb +15 -0
- data/lib/pagseguro/online_debit_transaction_request.rb +17 -0
- data/lib/pagseguro/partner.rb +20 -0
- data/lib/pagseguro/payment_method.rb +39 -0
- data/lib/pagseguro/payment_release.rb +21 -0
- data/lib/pagseguro/payment_releases.rb +28 -0
- data/lib/pagseguro/payment_request.rb +117 -0
- data/lib/pagseguro/payment_request/request_serializer.rb +203 -0
- data/lib/pagseguro/payment_request/response.rb +35 -0
- data/lib/pagseguro/payment_status.rb +39 -0
- data/lib/pagseguro/permission.rb +13 -0
- data/lib/pagseguro/person.rb +40 -0
- data/lib/pagseguro/phone.rb +20 -0
- data/lib/pagseguro/phones.rb +5 -0
- data/lib/pagseguro/receiver.rb +20 -0
- data/lib/pagseguro/receiver_split.rb +15 -0
- data/lib/pagseguro/request.rb +170 -0
- data/lib/pagseguro/sender.rb +53 -0
- data/lib/pagseguro/session.rb +34 -0
- data/lib/pagseguro/session/response.rb +32 -0
- data/lib/pagseguro/session/response_serializer.rb +18 -0
- data/lib/pagseguro/shipping.rb +57 -0
- 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 +215 -0
- data/lib/pagseguro/transaction/collection.rb +20 -0
- data/lib/pagseguro/transaction/response.rb +45 -0
- data/lib/pagseguro/transaction/search.rb +121 -0
- data/lib/pagseguro/transaction/search/search_abandoned.rb +20 -0
- data/lib/pagseguro/transaction/search/search_by_date.rb +16 -0
- data/lib/pagseguro/transaction/search/search_by_reference.rb +13 -0
- data/lib/pagseguro/transaction/serializer.rb +181 -0
- data/lib/pagseguro/transaction_cancellation.rb +37 -0
- data/lib/pagseguro/transaction_cancellation/request_serializer.rb +18 -0
- data/lib/pagseguro/transaction_cancellation/response.rb +33 -0
- data/lib/pagseguro/transaction_cancellation/response_serializer.rb +17 -0
- data/lib/pagseguro/transaction_installment.rb +11 -0
- data/lib/pagseguro/transaction_refund.rb +44 -0
- data/lib/pagseguro/transaction_refund/request_serializer.rb +24 -0
- data/lib/pagseguro/transaction_refund/response.rb +33 -0
- data/lib/pagseguro/transaction_refund/response_serializer.rb +17 -0
- data/lib/pagseguro/transaction_request.rb +165 -0
- data/lib/pagseguro/transaction_request/request_serializer.rb +311 -0
- data/lib/pagseguro/transaction_request/response.rb +33 -0
- data/lib/pagseguro/transaction_request/response_serializer.rb +117 -0
- data/lib/pagseguro/transaction_status.rb +14 -0
- data/lib/pagseguro/version.rb +3 -0
- data/locales/pt-BR.yml +130 -0
- data/pagseguro-oficial.gemspec +31 -0
- data/spec/fixtures/authorization/find_authorization.xml +17 -0
- data/spec/fixtures/authorization/search_authorization.xml +47 -0
- data/spec/fixtures/authorization_request/authorization_request.xml +11 -0
- data/spec/fixtures/authorization_request/authorization_request_with_account.xml +47 -0
- data/spec/fixtures/authorization_request/success.xml +4 -0
- data/spec/fixtures/by_date/success.xml +85 -0
- data/spec/fixtures/installment/success.xml +24 -0
- data/spec/fixtures/invalid_code.xml +7 -0
- data/spec/fixtures/manual_subscription_charger/fail.xml +6 -0
- data/spec/fixtures/manual_subscription_charger/success.xml +4 -0
- data/spec/fixtures/payment_request/failure.xml +7 -0
- data/spec/fixtures/payment_request/success.xml +5 -0
- data/spec/fixtures/refund/success.xml +2 -0
- data/spec/fixtures/session/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/transaction_cancellation/success.xml +2 -0
- data/spec/fixtures/transaction_request/success.xml +58 -0
- data/spec/fixtures/transactions/additional.xml +53 -0
- data/spec/fixtures/transactions/search.xml +40 -0
- data/spec/fixtures/transactions/success.xml +75 -0
- data/spec/fixtures/transactions/without_status_and_type.xml +71 -0
- data/spec/pagseguro/account_credentials_spec.rb +10 -0
- data/spec/pagseguro/account_spec.rb +27 -0
- data/spec/pagseguro/address_spec.rb +17 -0
- data/spec/pagseguro/application_credentials_spec.rb +11 -0
- data/spec/pagseguro/authorization/collection_spec.rb +49 -0
- data/spec/pagseguro/authorization/request_serializer_spec.rb +10 -0
- data/spec/pagseguro/authorization/response_serializer_spec.rb +19 -0
- data/spec/pagseguro/authorization/response_spec.rb +90 -0
- data/spec/pagseguro/authorization_request/request_serializer_spec.rb +323 -0
- data/spec/pagseguro/authorization_request/response_serializer_spec.rb +15 -0
- data/spec/pagseguro/authorization_request/response_spec.rb +36 -0
- data/spec/pagseguro/authorization_request_spec.rb +127 -0
- data/spec/pagseguro/authorization_spec.rb +111 -0
- data/spec/pagseguro/bank_spec.rb +5 -0
- data/spec/pagseguro/boleto_transaction_request_spec.rb +9 -0
- data/spec/pagseguro/company_spec.rb +12 -0
- data/spec/pagseguro/config_spec.rb +5 -0
- data/spec/pagseguro/credit_card_transaction_request_spec.rb +36 -0
- data/spec/pagseguro/creditor_fee_spec.rb +10 -0
- data/spec/pagseguro/document_spec.rb +21 -0
- data/spec/pagseguro/documents_spec.rb +37 -0
- data/spec/pagseguro/errors_spec.rb +145 -0
- data/spec/pagseguro/extensions/collection_object_spec.rb +77 -0
- data/spec/pagseguro/features/create_session_spec.rb +52 -0
- data/spec/pagseguro/features/create_transaction_request_spec.rb +58 -0
- data/spec/pagseguro/holder_spec.rb +10 -0
- data/spec/pagseguro/installment/collection_spec.rb +43 -0
- data/spec/pagseguro/installment/request_serializer_spec.rb +16 -0
- data/spec/pagseguro/installment/response_serializer_spec.rb +33 -0
- data/spec/pagseguro/installment/response_spec.rb +56 -0
- data/spec/pagseguro/installment_spec.rb +50 -0
- data/spec/pagseguro/item_spec.rb +20 -0
- data/spec/pagseguro/items_spec.rb +148 -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/notification_spec.rb +6 -0
- data/spec/pagseguro/online_debit_transaction_request_spec.rb +18 -0
- data/spec/pagseguro/pagseguro_spec.rb +82 -0
- data/spec/pagseguro/partner_spec.rb +8 -0
- data/spec/pagseguro/payment_method_spec.rb +42 -0
- data/spec/pagseguro/payment_release_spec.rb +9 -0
- data/spec/pagseguro/payment_releases_spec.rb +34 -0
- data/spec/pagseguro/payment_request/request_serializer_spec.rb +283 -0
- data/spec/pagseguro/payment_request/response_spec.rb +13 -0
- data/spec/pagseguro/payment_request_spec.rb +148 -0
- data/spec/pagseguro/payment_status_spec.rb +33 -0
- data/spec/pagseguro/permission_spec.rb +7 -0
- data/spec/pagseguro/person_spec.rb +10 -0
- data/spec/pagseguro/phone_spec.rb +6 -0
- data/spec/pagseguro/phones_spec.rb +38 -0
- data/spec/pagseguro/receiver_spec.rb +7 -0
- data/spec/pagseguro/receiver_split_spec.rb +7 -0
- data/spec/pagseguro/request_spec.rb +114 -0
- data/spec/pagseguro/sender_spec.rb +25 -0
- data/spec/pagseguro/session/response_serializer_spec.rb +12 -0
- data/spec/pagseguro/session/response_spec.rb +57 -0
- data/spec/pagseguro/session_spec.rb +45 -0
- data/spec/pagseguro/shipping_spec.rb +40 -0
- 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/collection_spec.rb +43 -0
- data/spec/pagseguro/transaction/response_spec.rb +60 -0
- data/spec/pagseguro/transaction/search/search_abandoned_spec.rb +55 -0
- data/spec/pagseguro/transaction/search/search_by_date_spec.rb +28 -0
- data/spec/pagseguro/transaction/search/search_by_reference_spec.rb +21 -0
- data/spec/pagseguro/transaction/search_spec.rb +133 -0
- data/spec/pagseguro/transaction/serializer_spec.rb +86 -0
- data/spec/pagseguro/transaction_cancellation/request_serializer_spec.rb +13 -0
- data/spec/pagseguro/transaction_cancellation/response_serializer_spec.rb +9 -0
- data/spec/pagseguro/transaction_cancellation/response_spec.rb +45 -0
- data/spec/pagseguro/transaction_cancellation_spec.rb +60 -0
- data/spec/pagseguro/transaction_installment_spec.rb +6 -0
- data/spec/pagseguro/transaction_refund/request_serializer_spec.rb +15 -0
- data/spec/pagseguro/transaction_refund/response_serializer_spec.rb +12 -0
- data/spec/pagseguro/transaction_refund/response_spec.rb +39 -0
- data/spec/pagseguro/transaction_refund_spec.rb +71 -0
- data/spec/pagseguro/transaction_request/request_serializer_spec.rb +677 -0
- data/spec/pagseguro/transaction_request/response_serializer_spec.rb +52 -0
- data/spec/pagseguro/transaction_request/response_spec.rb +63 -0
- data/spec/pagseguro/transaction_request_spec.rb +156 -0
- data/spec/pagseguro/transaction_spec.rb +265 -0
- data/spec/pagseguro/transaction_status_spec.rb +7 -0
- data/spec/spec_helper.rb +35 -0
- data/spec/support/ensure_type_macro.rb +35 -0
- data/spec/support/helpers.rb +14 -0
- data/spec/support/mass_assignment_macro.rb +11 -0
- data/spec/support/shared_examples_for_configuration.rb +10 -0
- data/transaction/transaction_refund.rb +25 -0
- metadata +641 -0
@@ -0,0 +1,128 @@
|
|
1
|
+
require_relative "../boot"
|
2
|
+
|
3
|
+
# Create Transaction Using Credit Card
|
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::CreditCardTransactionRequest.new
|
10
|
+
payment.notification_url = "http://www.meusite.com.br/notification"
|
11
|
+
payment.payment_mode = "default"
|
12
|
+
|
13
|
+
payment.items << {
|
14
|
+
id: 1234,
|
15
|
+
description: %[Televisão 19" Sony],
|
16
|
+
amount: 459.50,
|
17
|
+
weight: 0
|
18
|
+
}
|
19
|
+
|
20
|
+
payment.reference = "REF1234-credit-card"
|
21
|
+
payment.sender = {
|
22
|
+
hash: "f8d95a0747cdddf277a111ec1bab1d68628e095243b7a56382ec01f260216313",
|
23
|
+
name: "Joao Comprador",
|
24
|
+
email: "joao@sandbox.pagseguro.com.br",
|
25
|
+
document: { type: "CPF", value: "75073461100" },
|
26
|
+
phone: {
|
27
|
+
area_code: 11,
|
28
|
+
number: "12345678"
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
payment.shipping = {
|
33
|
+
type_name: "sedex",
|
34
|
+
address: {
|
35
|
+
street: "Av. Brig. Faria Lima",
|
36
|
+
number: "1384",
|
37
|
+
complement: "5º andar",
|
38
|
+
city: "São Paulo",
|
39
|
+
state: "SP",
|
40
|
+
district: "Jardim Paulistano",
|
41
|
+
postal_code: "01452002"
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
45
|
+
payment.billing_address = {
|
46
|
+
street: "Av. Brig. Faria Lima",
|
47
|
+
number: "1384",
|
48
|
+
complement: "5º andar",
|
49
|
+
city: "São Paulo",
|
50
|
+
state: "SP",
|
51
|
+
district: "Jardim Paulistano",
|
52
|
+
postal_code: "01452002"
|
53
|
+
}
|
54
|
+
|
55
|
+
payment.credit_card_token = "41c1f784216748ccae689fcd854aaca1"
|
56
|
+
payment.holder = {
|
57
|
+
name: "João Comprador",
|
58
|
+
birth_date: "07/05/1981",
|
59
|
+
document: {
|
60
|
+
type: "CPF",
|
61
|
+
value: "00000000191"
|
62
|
+
},
|
63
|
+
phone: {
|
64
|
+
area_code: 11,
|
65
|
+
number: "123456789"
|
66
|
+
}
|
67
|
+
}
|
68
|
+
|
69
|
+
payment.installment = {
|
70
|
+
value: 459.50,
|
71
|
+
quantity: 1
|
72
|
+
}
|
73
|
+
|
74
|
+
# Add extras params to request
|
75
|
+
# payment.extra_params << { paramName: 'paramValue' }
|
76
|
+
# payment.extra_params << { senderBirthDate: '07/05/1981' }
|
77
|
+
|
78
|
+
puts "=> REQUEST"
|
79
|
+
puts PagSeguro::TransactionRequest::RequestSerializer.new(payment).to_params
|
80
|
+
puts
|
81
|
+
|
82
|
+
payment.create
|
83
|
+
|
84
|
+
if payment.errors.any?
|
85
|
+
puts "=> ERRORS"
|
86
|
+
puts payment.errors.join("\n")
|
87
|
+
else
|
88
|
+
puts "=> Transaction"
|
89
|
+
puts " code: #{payment.code}"
|
90
|
+
puts " reference: #{payment.reference}"
|
91
|
+
puts " type: #{payment.type_id}"
|
92
|
+
puts " payment link: #{payment.payment_link}"
|
93
|
+
puts " status: #{payment.status}"
|
94
|
+
puts " payment method type: #{payment.payment_method}"
|
95
|
+
puts " created at: #{payment.created_at}"
|
96
|
+
puts " updated at: #{payment.updated_at}"
|
97
|
+
puts " gross amount: #{payment.gross_amount.to_f}"
|
98
|
+
puts " discount amount: #{payment.discount_amount.to_f}"
|
99
|
+
puts " net amount: #{payment.net_amount.to_f}"
|
100
|
+
puts " extra amount: #{payment.extra_amount.to_f}"
|
101
|
+
puts " installment count: #{payment.installment_count}"
|
102
|
+
|
103
|
+
puts " => Items"
|
104
|
+
puts " items count: #{payment.items.size}"
|
105
|
+
payment.items.each do |item|
|
106
|
+
puts " item id: #{item.id}"
|
107
|
+
puts " description: #{item.description}"
|
108
|
+
puts " quantity: #{item.quantity}"
|
109
|
+
puts " amount: #{item.amount.to_f}"
|
110
|
+
end
|
111
|
+
|
112
|
+
puts " => Sender"
|
113
|
+
puts " name: #{payment.sender.name}"
|
114
|
+
puts " email: #{payment.sender.email}"
|
115
|
+
puts " phone: (#{payment.sender.phone.area_code}) #{payment.sender.phone.number}"
|
116
|
+
puts " document: #{payment.sender.document}: #{payment.sender.document}"
|
117
|
+
|
118
|
+
puts " => Shipping"
|
119
|
+
puts " street: #{payment.shipping.address.street}, #{payment.shipping.address.number}"
|
120
|
+
puts " complement: #{payment.shipping.address.complement}"
|
121
|
+
puts " postal code: #{payment.shipping.address.postal_code}"
|
122
|
+
puts " district: #{payment.shipping.address.district}"
|
123
|
+
puts " city: #{payment.shipping.address.city}"
|
124
|
+
puts " state: #{payment.shipping.address.state}"
|
125
|
+
puts " country: #{payment.shipping.address.country}"
|
126
|
+
puts " type: #{payment.shipping.type_name}"
|
127
|
+
puts " cost: #{payment.shipping.cost}"
|
128
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
require_relative "../boot"
|
2
|
+
|
3
|
+
# Create Transaction Using Oline Debit
|
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::OnlineDebitTransactionRequest.new
|
10
|
+
payment.notification_url = "http://www.meusite.com.br/notification"
|
11
|
+
payment.payment_mode = "gateway"
|
12
|
+
|
13
|
+
payment.items << {
|
14
|
+
id: 1234,
|
15
|
+
description: %[Televisão 19" Sony],
|
16
|
+
amount: 459.50,
|
17
|
+
weight: 0
|
18
|
+
}
|
19
|
+
|
20
|
+
payment.reference = "REF1234-online-debit"
|
21
|
+
payment.sender = {
|
22
|
+
hash: "7e215170790948f45e26175c2192c77e88c0e4c361a5860b99d2e9a97af982e6",
|
23
|
+
name: "Joao Comprador",
|
24
|
+
email: "joao@sandbox.pagseguro.com.br",
|
25
|
+
document: { type: "CPF", value: "75073461100" },
|
26
|
+
phone: {
|
27
|
+
area_code: 11,
|
28
|
+
number: "12345678"
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
payment.shipping = {
|
33
|
+
type_name: "sedex",
|
34
|
+
address: {
|
35
|
+
street: "Av. Brig. Faria Lima",
|
36
|
+
number: "1384",
|
37
|
+
complement: "5º andar",
|
38
|
+
city: "São Paulo",
|
39
|
+
state: "SP",
|
40
|
+
district: "Jardim Paulistano",
|
41
|
+
postal_code: "01452002"
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
45
|
+
payment.bank = {
|
46
|
+
name: "itau"
|
47
|
+
}
|
48
|
+
|
49
|
+
|
50
|
+
# Add extras params to request
|
51
|
+
# payment.extra_params << { paramName: 'paramValue' }
|
52
|
+
# payment.extra_params << { senderBirthDate: '07/05/1981' }
|
53
|
+
|
54
|
+
puts "=> REQUEST"
|
55
|
+
puts PagSeguro::TransactionRequest::RequestSerializer.new(payment).to_params
|
56
|
+
puts
|
57
|
+
|
58
|
+
payment.create
|
59
|
+
|
60
|
+
if payment.errors.any?
|
61
|
+
puts "=> ERRORS"
|
62
|
+
puts payment.errors.join("\n")
|
63
|
+
else
|
64
|
+
puts "=> Transaction"
|
65
|
+
puts " code: #{payment.code}"
|
66
|
+
puts " reference: #{payment.reference}"
|
67
|
+
puts " type: #{payment.type_id}"
|
68
|
+
puts " payment link: #{payment.payment_link}"
|
69
|
+
puts " status: #{payment.status}"
|
70
|
+
puts " payment method type: #{payment.payment_method}"
|
71
|
+
puts " created at: #{payment.created_at}"
|
72
|
+
puts " updated at: #{payment.updated_at}"
|
73
|
+
puts " gross amount: #{payment.gross_amount.to_f}"
|
74
|
+
puts " discount amount: #{payment.discount_amount.to_f}"
|
75
|
+
puts " net amount: #{payment.net_amount.to_f}"
|
76
|
+
puts " extra amount: #{payment.extra_amount.to_f}"
|
77
|
+
puts " installment count: #{payment.installment_count}"
|
78
|
+
|
79
|
+
puts " => Items"
|
80
|
+
puts " items count: #{payment.items.size}"
|
81
|
+
payment.items.each do |item|
|
82
|
+
puts " item id: #{item.id}"
|
83
|
+
puts " description: #{item.description}"
|
84
|
+
puts " quantity: #{item.quantity}"
|
85
|
+
puts " amount: #{item.amount.to_f}"
|
86
|
+
end
|
87
|
+
|
88
|
+
puts " => Sender"
|
89
|
+
puts " name: #{payment.sender.name}"
|
90
|
+
puts " email: #{payment.sender.email}"
|
91
|
+
puts " phone: (#{payment.sender.phone.area_code}) #{payment.sender.phone.number}"
|
92
|
+
puts " document: #{payment.sender.document}"
|
93
|
+
|
94
|
+
puts " => Shipping"
|
95
|
+
puts " street: #{payment.shipping.address.street}, #{payment.shipping.address.number}"
|
96
|
+
puts " complement: #{payment.shipping.address.complement}"
|
97
|
+
puts " postal code: #{payment.shipping.address.postal_code}"
|
98
|
+
puts " district: #{payment.shipping.address.district}"
|
99
|
+
puts " city: #{payment.shipping.address.city}"
|
100
|
+
puts " state: #{payment.shipping.address.state}"
|
101
|
+
puts " country: #{payment.shipping.address.country}"
|
102
|
+
puts " type: #{payment.shipping.type_name}"
|
103
|
+
puts " cost: #{payment.shipping.cost}"
|
104
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require_relative "boot"
|
2
|
+
|
3
|
+
# Get Installments
|
4
|
+
#
|
5
|
+
# Required AccountCredentials
|
6
|
+
#
|
7
|
+
# You need to give:
|
8
|
+
# - amount
|
9
|
+
# - card_brand
|
10
|
+
# - account credentials (EMAIL, TOKEN)
|
11
|
+
#
|
12
|
+
# You can pass these parameters to PagSeguro::Installment#find
|
13
|
+
|
14
|
+
credentials = PagSeguro::AccountCredentials.new('EMAIL', 'TOKEN')
|
15
|
+
|
16
|
+
options = {
|
17
|
+
credentials: credentials # Unnecessary if you set in application config
|
18
|
+
}
|
19
|
+
|
20
|
+
installments = PagSeguro::Installment.find("100.00", nil, options)
|
21
|
+
|
22
|
+
if installments.errors.any?
|
23
|
+
puts installments.errors.join("\n")
|
24
|
+
else
|
25
|
+
puts "=> INSTALLMENTS"
|
26
|
+
puts
|
27
|
+
installments.each do |installment|
|
28
|
+
puts installment.inspect
|
29
|
+
end
|
30
|
+
|
31
|
+
visa_installments = PagSeguro::Installment.find("100.00", :visa, options)
|
32
|
+
|
33
|
+
puts
|
34
|
+
puts "=> VISA INSTALLMENTS"
|
35
|
+
puts
|
36
|
+
visa_installments.each do |installment|
|
37
|
+
puts installment.inspect
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative '../boot'
|
2
|
+
|
3
|
+
# Cancel a Subscription.
|
4
|
+
#
|
5
|
+
# You need to set your AccountCredentials (EMAIL, TOKEN) in the application
|
6
|
+
# config.
|
7
|
+
#
|
8
|
+
# P.S: See the boot file example for more details.
|
9
|
+
|
10
|
+
code = 'CODE'
|
11
|
+
email = 'EMAIL'
|
12
|
+
token = 'TOKEN'
|
13
|
+
|
14
|
+
# Edit the lines above.
|
15
|
+
|
16
|
+
cancel = PagSeguro::SubscriptionCanceller.new(subscription_code: code)
|
17
|
+
|
18
|
+
cancel.credentials = PagSeguro::AccountCredentials.new(email, token)
|
19
|
+
cancel.save
|
20
|
+
|
21
|
+
if cancel.errors.any?
|
22
|
+
puts '=> ERRORS'
|
23
|
+
puts cancel.errors.join('\n')
|
24
|
+
else
|
25
|
+
print '=> Subscription cancelled correctly.'
|
26
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require_relative '../boot'
|
2
|
+
|
3
|
+
# Change a Payment.
|
4
|
+
#
|
5
|
+
# You need to set your AccountCredentials (EMAIL, TOKEN) in the application
|
6
|
+
# config.
|
7
|
+
#
|
8
|
+
# P.S: See the boot file example for more details.
|
9
|
+
|
10
|
+
email = 'EMAIL'
|
11
|
+
token = 'TOKEN'
|
12
|
+
|
13
|
+
new_payment = PagSeguro::SubscriptionChangePayment.new(
|
14
|
+
subscription_code: 'SUBSCRIPTION_CODE',
|
15
|
+
sender: {
|
16
|
+
hash: 'HASH',
|
17
|
+
ip: '192.168.0.1',
|
18
|
+
},
|
19
|
+
subscription_payment_method: {
|
20
|
+
token: 'TOKEN',
|
21
|
+
holder: {
|
22
|
+
name: 'Nome',
|
23
|
+
birth_date: Date.new(1984, 12, 31),
|
24
|
+
phone: { area_code: '11', number: '988881234' },
|
25
|
+
document: { type: 'CPF', value: '00000000191' },
|
26
|
+
billing_address: {
|
27
|
+
street: 'Av Brigadeira Faria Lima',
|
28
|
+
number: '1384',
|
29
|
+
complement: '3 andar',
|
30
|
+
district: 'Jd Paulistano',
|
31
|
+
city: 'Sao Paulo',
|
32
|
+
state: 'SP',
|
33
|
+
country: 'BRA',
|
34
|
+
postal_code: '01452002'
|
35
|
+
}
|
36
|
+
}
|
37
|
+
}
|
38
|
+
)
|
39
|
+
|
40
|
+
# Edit the lines above.
|
41
|
+
|
42
|
+
new_payment.credentials = PagSeguro::AccountCredentials.new(email, token)
|
43
|
+
new_payment.update
|
44
|
+
|
45
|
+
if new_payment.errors.any?
|
46
|
+
puts '=> ERRORS'
|
47
|
+
puts new_payment.errors.join("\n")
|
48
|
+
else
|
49
|
+
print '=> Subscription correct changed.'
|
50
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require_relative "../boot"
|
2
|
+
|
3
|
+
# Change Subscription Status
|
4
|
+
#
|
5
|
+
# You need to set:
|
6
|
+
# - AccountCredentials (EMAIL, TOKEN)
|
7
|
+
# - Subscription's code
|
8
|
+
# - The new status
|
9
|
+
#
|
10
|
+
# P.S: Take a look at the boot file example for more details
|
11
|
+
|
12
|
+
user = 'user@example.com'
|
13
|
+
token = 'TOKEN'
|
14
|
+
code = 'CODE'
|
15
|
+
status = :suspended # Now just available the status :active and :suspended
|
16
|
+
|
17
|
+
credentials = PagSeguro::AccountCredentials.new('user@example.com', 'TOKEN')
|
18
|
+
|
19
|
+
change = PagSeguro::SubscriptionChangeStatus.new(code, status)
|
20
|
+
change.credentials = credentials
|
21
|
+
change.save
|
22
|
+
|
23
|
+
if change.errors.any?
|
24
|
+
puts "ERRORS: "
|
25
|
+
puts change.errors.inspect
|
26
|
+
else
|
27
|
+
puts "SUCCESS"
|
28
|
+
puts change.inspect
|
29
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require_relative '../boot'
|
2
|
+
|
3
|
+
# Charge a Manual Subscription.
|
4
|
+
#
|
5
|
+
# You also can set your AccountCredentials (EMAIL, TOKEN) in the application
|
6
|
+
# config.
|
7
|
+
#
|
8
|
+
# See the boot file example for more details.
|
9
|
+
|
10
|
+
email = 'EMAIL'
|
11
|
+
token = 'TOKEN'
|
12
|
+
|
13
|
+
charger = PagSeguro::ManualSubscriptionCharger.new(
|
14
|
+
reference: 'REFERENCE',
|
15
|
+
subscription_code: 'SUBSCRIPTION_CODE',
|
16
|
+
)
|
17
|
+
|
18
|
+
charger.items << {
|
19
|
+
id: '0001',
|
20
|
+
description: 'Seguro contra roubo',
|
21
|
+
amount: 100.0,
|
22
|
+
quantity: 1
|
23
|
+
}
|
24
|
+
|
25
|
+
# Edit the lines above.
|
26
|
+
|
27
|
+
charger.credentials = PagSeguro::AccountCredentials.new(email, token)
|
28
|
+
charger.create
|
29
|
+
|
30
|
+
if charger.errors.any?
|
31
|
+
puts '=> ERRORS'
|
32
|
+
puts charger.errors.join("\n")
|
33
|
+
else
|
34
|
+
print '=> Subscription was corrected charged, the transaction code is '
|
35
|
+
puts charger.transaction_code
|
36
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require_relative '../boot'
|
2
|
+
|
3
|
+
# Subscribe your client in a SubscriptionPlan (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
|
+
subscription = PagSeguro::Subscription.new(
|
13
|
+
plan: 'SUBSCRIPTION_CODE',
|
14
|
+
reference: 'SUB-1234',
|
15
|
+
sender: {
|
16
|
+
name: 'Comprador',
|
17
|
+
email: 'user@sandbox.pagseguro.com.br',
|
18
|
+
ip: '192.168.0.1',
|
19
|
+
hash: 'hash',
|
20
|
+
phone: {
|
21
|
+
area_code: 12,
|
22
|
+
number: '23456789'
|
23
|
+
},
|
24
|
+
document: { type: 'CPF', value: '23606838450' },
|
25
|
+
address: {
|
26
|
+
street: 'Av Brigadeira Faria Lima',
|
27
|
+
number: '1384',
|
28
|
+
complement: '3 andar',
|
29
|
+
district: 'Jd Paulistano',
|
30
|
+
city: 'Sao Paulo',
|
31
|
+
state: 'SP',
|
32
|
+
country: 'BRA',
|
33
|
+
postal_code: '01452002'
|
34
|
+
}
|
35
|
+
},
|
36
|
+
payment_method: {
|
37
|
+
token: 'TOKEN',
|
38
|
+
holder: {
|
39
|
+
name: 'Nome',
|
40
|
+
birth_date: '11/01/1984',
|
41
|
+
document: { type: 'CPF', value: '00000000191' },
|
42
|
+
billing_address: {
|
43
|
+
street: 'Av Brigadeira Faria Lima',
|
44
|
+
number: '1384',
|
45
|
+
complement: '3 andar',
|
46
|
+
district: 'Jd Paulistano',
|
47
|
+
city: 'Sao Paulo',
|
48
|
+
state: 'SP',
|
49
|
+
country: 'BRA',
|
50
|
+
postal_code: '01452002'
|
51
|
+
},
|
52
|
+
phone: { area_code: '11', number: '988881234' }
|
53
|
+
}
|
54
|
+
}
|
55
|
+
)
|
56
|
+
|
57
|
+
# Edit the lines above.
|
58
|
+
|
59
|
+
subscription.credentials = PagSeguro::AccountCredentials.new(email, token)
|
60
|
+
subscription.create
|
61
|
+
|
62
|
+
if subscription.errors.any?
|
63
|
+
puts '=> ERRORS'
|
64
|
+
puts subscription.errors.join('\n')
|
65
|
+
else
|
66
|
+
print '=> Subscription correct created, its code is '
|
67
|
+
puts subscription.code
|
68
|
+
end
|