paypal-sdk-rest 1.7.4 → 2.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -14
- data/README.md +45 -251
- data/lib/lib.rb +88 -0
- data/lib/paypal/core/access_token.rb +20 -0
- data/lib/paypal/core/paypal_environment.rb +38 -0
- data/lib/paypal/core/paypal_http_client.rb +51 -0
- data/lib/paypal/core/token_requests.rb +40 -0
- data/lib/paypal/core/version.rb +3 -0
- data/lib/v1/billing_agreements/agreement_bill_balance_request.rb +35 -0
- data/lib/v1/billing_agreements/agreement_cancel_request.rb +35 -0
- data/lib/v1/billing_agreements/agreement_create_request.rb +33 -0
- data/lib/v1/billing_agreements/agreement_execute_request.rb +31 -0
- data/lib/v1/billing_agreements/agreement_get_request.rb +31 -0
- data/lib/v1/billing_agreements/agreement_re_activate_request.rb +35 -0
- data/lib/v1/billing_agreements/agreement_set_balance_request.rb +35 -0
- data/lib/v1/billing_agreements/agreement_suspend_request.rb +35 -0
- data/lib/v1/billing_agreements/agreement_transactions_request.rb +41 -0
- data/lib/v1/billing_agreements/agreement_update_request.rb +35 -0
- data/lib/v1/billing_plans/plan_create_request.rb +33 -0
- data/lib/v1/billing_plans/plan_get_request.rb +31 -0
- data/lib/v1/billing_plans/plan_list_request.rb +49 -0
- data/lib/v1/billing_plans/plan_update_request.rb +35 -0
- data/lib/v1/identity/user_consent.rb +45 -0
- data/lib/v1/identity/userinfo_get_request.rb +33 -0
- data/lib/v1/invoices/invoice_cancel_request.rb +35 -0
- data/lib/v1/invoices/invoice_create_request.rb +33 -0
- data/lib/v1/invoices/invoice_delete_external_payment_request.rb +33 -0
- data/lib/v1/invoices/invoice_delete_external_refund_request.rb +33 -0
- data/lib/v1/invoices/invoice_delete_request.rb +31 -0
- data/lib/v1/invoices/invoice_get_request.rb +31 -0
- data/lib/v1/invoices/invoice_list_request.rb +44 -0
- data/lib/v1/invoices/invoice_next_invoice_number_request.rb +29 -0
- data/lib/v1/invoices/invoice_qr_code_request.rb +46 -0
- data/lib/v1/invoices/invoice_record_payment_request.rb +35 -0
- data/lib/v1/invoices/invoice_record_refund_request.rb +35 -0
- data/lib/v1/invoices/invoice_remind_request.rb +35 -0
- data/lib/v1/invoices/invoice_search_request.rb +33 -0
- data/lib/v1/invoices/invoice_send_request.rb +36 -0
- data/lib/v1/invoices/invoice_update_request.rb +40 -0
- data/lib/v1/invoices/template_create_request.rb +33 -0
- data/lib/v1/invoices/template_delete_request.rb +31 -0
- data/lib/v1/invoices/template_get_request.rb +31 -0
- data/lib/v1/invoices/template_list_request.rb +34 -0
- data/lib/v1/invoices/template_update_request.rb +35 -0
- data/lib/v1/orders/orders_cancel_request.rb +31 -0
- data/lib/v1/orders/orders_create_request.rb +33 -0
- data/lib/v1/orders/orders_get_request.rb +31 -0
- data/lib/v1/orders/orders_pay_request.rb +35 -0
- data/lib/v1/payment_experience/web_profile_create_request.rb +33 -0
- data/lib/v1/payment_experience/web_profile_delete_request.rb +31 -0
- data/lib/v1/payment_experience/web_profile_get_request.rb +31 -0
- data/lib/v1/payment_experience/web_profile_list_request.rb +29 -0
- data/lib/v1/payment_experience/web_profile_partial_update_request.rb +35 -0
- data/lib/v1/payment_experience/web_profile_update_request.rb +35 -0
- data/lib/v1/payments/authorization_capture_request.rb +35 -0
- data/lib/v1/payments/authorization_get_request.rb +31 -0
- data/lib/v1/payments/authorization_reauthorize_request.rb +35 -0
- data/lib/v1/payments/authorization_void_request.rb +31 -0
- data/lib/v1/payments/capture_get_request.rb +31 -0
- data/lib/v1/payments/capture_refund_request.rb +35 -0
- data/lib/v1/payments/order_authorize_request.rb +35 -0
- data/lib/v1/payments/order_capture_request.rb +35 -0
- data/lib/v1/payments/order_get_request.rb +31 -0
- data/lib/v1/payments/order_void_request.rb +31 -0
- data/lib/v1/payments/payment_create_request.rb +33 -0
- data/lib/v1/payments/payment_execute_request.rb +35 -0
- data/lib/v1/payments/payment_get_request.rb +31 -0
- data/lib/v1/payments/payment_list_request.rb +69 -0
- data/lib/v1/payments/payment_update_request.rb +35 -0
- data/lib/v1/payments/refund_get_request.rb +31 -0
- data/lib/v1/payments/sale_get_request.rb +31 -0
- data/lib/v1/payments/sale_refund_request.rb +35 -0
- data/lib/v1/sync/search_get_request.rb +99 -0
- data/lib/v1/vault/credit_card_create_request.rb +33 -0
- data/lib/v1/vault/credit_card_delete_request.rb +31 -0
- data/lib/v1/vault/credit_card_get_request.rb +31 -0
- data/lib/v1/vault/credit_card_list_request.rb +79 -0
- data/lib/v1/vault/credit_card_update_request.rb +35 -0
- data/lib/v1/webhooks/available_event_type_list_request.rb +29 -0
- data/lib/v1/webhooks/event_get_request.rb +31 -0
- data/lib/v1/webhooks/event_list_request.rb +54 -0
- data/lib/v1/webhooks/event_resend_request.rb +35 -0
- data/lib/v1/webhooks/simulate_event_request.rb +33 -0
- data/lib/v1/webhooks/webhook_create_request.rb +33 -0
- data/lib/v1/webhooks/webhook_delete_request.rb +31 -0
- data/lib/v1/webhooks/webhook_get_request.rb +31 -0
- data/lib/v1/webhooks/webhook_list_event_subscriptions_request.rb +31 -0
- data/lib/v1/webhooks/webhook_list_request.rb +34 -0
- data/lib/v1/webhooks/webhook_update_request.rb +35 -0
- data/lib/v1/webhooks/webhook_verify_signature_request.rb +33 -0
- data/spec/integration/test_harness.rb +25 -0
- data/spec/integration/v1/billing_agreements/agreement_create_spec.rb +63 -0
- data/spec/integration/v1/billing_plans/plan_create_spec.rb +12 -0
- data/spec/integration/v1/billing_plans/plan_get_spec.rb +16 -0
- data/spec/integration/v1/billing_plans/plan_helper.rb +71 -0
- data/spec/integration/v1/billing_plans/plan_list_spec.rb +16 -0
- data/spec/integration/v1/billing_plans/plan_update_spec.rb +19 -0
- data/spec/integration/v1/identity/userinfo_get_spec.rb +65 -0
- data/spec/integration/v1/invoices/invoice_cancel_spec.rb +23 -0
- data/spec/integration/v1/invoices/invoice_create_spec.rb +15 -0
- data/spec/integration/v1/invoices/invoice_delete_external_payment_spec.rb +23 -0
- data/spec/integration/v1/invoices/invoice_delete_external_refund_spec.rb +21 -0
- data/spec/integration/v1/invoices/invoice_delete_spec.rb +16 -0
- data/spec/integration/v1/invoices/invoice_get_spec.rb +18 -0
- data/spec/integration/v1/invoices/invoice_helper.rb +171 -0
- data/spec/integration/v1/invoices/invoice_list_spec.rb +20 -0
- data/spec/integration/v1/invoices/invoice_next_invoice_number_spec.rb +14 -0
- data/spec/integration/v1/invoices/invoice_qr_code_spec.rb +18 -0
- data/spec/integration/v1/invoices/invoice_record_payment_spec.rb +14 -0
- data/spec/integration/v1/invoices/invoice_record_refund_spec.rb +14 -0
- data/spec/integration/v1/invoices/invoice_remind_spec.rb +22 -0
- data/spec/integration/v1/invoices/invoice_search_spec.rb +20 -0
- data/spec/integration/v1/invoices/invoice_send_spec.rb +15 -0
- data/spec/integration/v1/invoices/invoice_update_spec.rb +26 -0
- data/spec/integration/v1/invoices/template_create_spec.rb +14 -0
- data/spec/integration/v1/invoices/template_delete_spec.rb +15 -0
- data/spec/integration/v1/invoices/template_get_spec.rb +18 -0
- data/spec/integration/v1/invoices/template_list_spec.rb +15 -0
- data/spec/integration/v1/invoices/template_update_spec.rb +62 -0
- data/spec/integration/v1/orders/orders_cancel_spec.rb +15 -0
- data/spec/integration/v1/orders/orders_create_spec.rb +17 -0
- data/spec/integration/v1/orders/orders_get_spec.rb +18 -0
- data/spec/integration/v1/orders/orders_helper.rb +36 -0
- data/spec/integration/v1/orders/orders_pay_spec.rb +19 -0
- data/spec/integration/v1/payment_experience/pe_helper.rb +35 -0
- data/spec/integration/v1/payment_experience/web_profile_create_spec.rb +20 -0
- data/spec/integration/v1/payment_experience/web_profile_delete_spec.rb +15 -0
- data/spec/integration/v1/payment_experience/web_profile_get_spec.rb +17 -0
- data/spec/integration/v1/payment_experience/web_profile_list_spec.rb +18 -0
- data/spec/integration/v1/payment_experience/web_profile_partial_update_spec.rb +32 -0
- data/spec/integration/v1/payment_experience/web_profile_update_spec.rb +44 -0
- data/spec/integration/v1/payments/authorization_capture_spec.rb +17 -0
- data/spec/integration/v1/payments/authorization_get_spec.rb +18 -0
- data/spec/integration/v1/payments/authorization_reauthorize_spec.rb +26 -0
- data/spec/integration/v1/payments/authorization_void_spec.rb +19 -0
- data/spec/integration/v1/payments/capture_get_spec.rb +20 -0
- data/spec/integration/v1/payments/capture_refund_spec.rb +27 -0
- data/spec/integration/v1/payments/order_authorize_spec.rb +20 -0
- data/spec/integration/v1/payments/order_capture_spec.rb +21 -0
- data/spec/integration/v1/payments/order_get_spec.rb +14 -0
- data/spec/integration/v1/payments/order_void_spec.rb +14 -0
- data/spec/integration/v1/payments/payment_create_spec.rb +13 -0
- data/spec/integration/v1/payments/payment_execute_spec.rb +19 -0
- data/spec/integration/v1/payments/payment_get_spec.rb +17 -0
- data/spec/integration/v1/payments/payment_list_spec.rb +16 -0
- data/spec/integration/v1/payments/payment_update_spec.rb +28 -0
- data/spec/integration/v1/payments/payments_helper.rb +72 -0
- data/spec/integration/v1/payments/refund_get_spec.rb +19 -0
- data/spec/integration/v1/payments/sale_get_spec.rb +18 -0
- data/spec/integration/v1/payments/sale_refund_spec.rb +18 -0
- data/spec/integration/v1/sync/search_get_spec.rb +34 -0
- data/spec/integration/v1/vault/credit_card_create_spec.rb +16 -0
- data/spec/integration/v1/vault/credit_card_delete_spec.rb +16 -0
- data/spec/integration/v1/vault/credit_card_get_spec.rb +17 -0
- data/spec/integration/v1/vault/credit_card_list_spec.rb +18 -0
- data/spec/integration/v1/vault/credit_card_update_spec.rb +26 -0
- data/spec/integration/v1/vault/vault_helper.rb +28 -0
- data/spec/integration/v1/webhooks/available_event_type_list_spec.rb +16 -0
- data/spec/integration/v1/webhooks/webhook_create_spec.rb +12 -0
- data/spec/integration/v1/webhooks/webhook_delete_spec.rb +13 -0
- data/spec/integration/v1/webhooks/webhook_get_spec.rb +16 -0
- data/spec/integration/v1/webhooks/webhook_helper.rb +43 -0
- data/spec/integration/v1/webhooks/webhook_list_event_subscriptions_spec.rb +16 -0
- data/spec/integration/v1/webhooks/webhook_list_spec.rb +15 -0
- data/spec/integration/v1/webhooks/webhook_update_spec.rb +29 -0
- data/spec/integration/v1/webhooks/webhook_verify_signature_spec.rb +20 -0
- data/spec/spec_helper.rb +97 -28
- data/spec/unit/paypal_http_client_spec.rb +264 -0
- metadata +250 -120
- data/Rakefile +0 -15
- data/data/DigiCertHighAssuranceEVRootCA.pem +0 -23
- data/data/DigiCertSHA2ExtendedValidationServerCA.pem +0 -28
- data/data/paypal.crt +0 -171
- data/lib/generators/paypal/sdk/USAGE +0 -3
- data/lib/generators/paypal/sdk/install_generator.rb +0 -17
- data/lib/generators/paypal/sdk/templates/paypal.rb +0 -2
- data/lib/generators/paypal/sdk/templates/paypal.yml +0 -29
- data/lib/paypal-sdk-core.rb +0 -38
- data/lib/paypal-sdk-rest.rb +0 -2
- data/lib/paypal-sdk/core/api.rb +0 -20
- data/lib/paypal-sdk/core/api/base.rb +0 -169
- data/lib/paypal-sdk/core/api/data_types/array_with_block.rb +0 -44
- data/lib/paypal-sdk/core/api/data_types/base.rb +0 -225
- data/lib/paypal-sdk/core/api/data_types/enum.rb +0 -26
- data/lib/paypal-sdk/core/api/data_types/simple_types.rb +0 -52
- data/lib/paypal-sdk/core/api/ipn.rb +0 -66
- data/lib/paypal-sdk/core/api/rest.rb +0 -177
- data/lib/paypal-sdk/core/authentication.rb +0 -66
- data/lib/paypal-sdk/core/config.rb +0 -253
- data/lib/paypal-sdk/core/credential.rb +0 -16
- data/lib/paypal-sdk/core/credential/base.rb +0 -27
- data/lib/paypal-sdk/core/credential/certificate.rb +0 -32
- data/lib/paypal-sdk/core/credential/signature.rb +0 -22
- data/lib/paypal-sdk/core/credential/third_party/subject.rb +0 -25
- data/lib/paypal-sdk/core/credential/third_party/token.rb +0 -39
- data/lib/paypal-sdk/core/exceptions.rb +0 -112
- data/lib/paypal-sdk/core/logging.rb +0 -50
- data/lib/paypal-sdk/core/openid_connect.rb +0 -140
- data/lib/paypal-sdk/core/openid_connect/api.rb +0 -50
- data/lib/paypal-sdk/core/openid_connect/data_types.rb +0 -73
- data/lib/paypal-sdk/core/openid_connect/get_api.rb +0 -28
- data/lib/paypal-sdk/core/openid_connect/request_data_type.rb +0 -52
- data/lib/paypal-sdk/core/openid_connect/set_api.rb +0 -36
- data/lib/paypal-sdk/core/util.rb +0 -11
- data/lib/paypal-sdk/core/util/http_helper.rb +0 -171
- data/lib/paypal-sdk/core/util/oauth_signature.rb +0 -64
- data/lib/paypal-sdk/core/util/ordered_hash.rb +0 -165
- data/lib/paypal-sdk/rest.rb +0 -39
- data/lib/paypal-sdk/rest/api.rb +0 -23
- data/lib/paypal-sdk/rest/data_types.rb +0 -2597
- data/lib/paypal-sdk/rest/error_hash.rb +0 -39
- data/lib/paypal-sdk/rest/get_api.rb +0 -20
- data/lib/paypal-sdk/rest/request_data_type.rb +0 -53
- data/lib/paypal-sdk/rest/set_api.rb +0 -42
- data/lib/paypal-sdk/rest/version.rb +0 -7
- data/spec/README.md +0 -22
- data/spec/config/cacert.pem +0 -171
- data/spec/config/cert_key.pem +0 -33
- data/spec/config/paypal.yml +0 -35
- data/spec/config/sample_data.yml +0 -3
- data/spec/core/api/data_type_spec.rb +0 -289
- data/spec/core/api/rest_spec.rb +0 -211
- data/spec/core/config_spec.rb +0 -192
- data/spec/core/logging_spec.rb +0 -28
- data/spec/core/openid_connect_spec.rb +0 -153
- data/spec/invoice_examples_spec.rb +0 -38
- data/spec/payments_examples_spec.rb +0 -437
- data/spec/payouts_examples_spec.rb +0 -74
- data/spec/rest/data_types_spec.rb +0 -62
- data/spec/rest/error_hash_spec.rb +0 -83
- data/spec/subscription_examples_spec.rb +0 -227
- data/spec/support/sample_data.rb +0 -5
- data/spec/web_profile_examples_spec.rb +0 -106
- data/spec/webhooks_examples_spec.rb +0 -93
@@ -0,0 +1,12 @@
|
|
1
|
+
require_relative '../../test_harness'
|
2
|
+
require_relative './plan_helper'
|
3
|
+
|
4
|
+
include PayPal::V1::BillingPlans
|
5
|
+
|
6
|
+
describe PlanCreateRequest do
|
7
|
+
it 'successfully makes a request' do
|
8
|
+
resp = PlanHelper::create_plan
|
9
|
+
expect(resp.status_code).to eq(201)
|
10
|
+
expect(resp.result).not_to be_nil
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require_relative '../../test_harness'
|
2
|
+
require_relative './plan_helper'
|
3
|
+
|
4
|
+
include PayPal::V1::BillingPlans
|
5
|
+
|
6
|
+
describe PlanGetRequest do
|
7
|
+
it 'successfully makes a request' do
|
8
|
+
create_response = PlanHelper::create_plan
|
9
|
+
|
10
|
+
get_response = PlanHelper::get_plan(create_response.result.id)
|
11
|
+
|
12
|
+
expect(get_response.status_code).to eq(200)
|
13
|
+
expect(get_response.result).not_to be_nil
|
14
|
+
expect(get_response.result.id).to eq(create_response.result.id)
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require_relative '../../test_harness'
|
2
|
+
|
3
|
+
include PayPal::V1::BillingPlans
|
4
|
+
|
5
|
+
module PlanHelper
|
6
|
+
class << self
|
7
|
+
def activate_plan(plan_id)
|
8
|
+
request_body = [
|
9
|
+
{
|
10
|
+
:op => 'replace',
|
11
|
+
:path => '/',
|
12
|
+
:value => {
|
13
|
+
:state => 'ACTIVE',
|
14
|
+
},
|
15
|
+
},
|
16
|
+
]
|
17
|
+
|
18
|
+
activate_request = PlanUpdateRequest.new(plan_id)
|
19
|
+
activate_request.request_body(request_body)
|
20
|
+
|
21
|
+
TestHarness::client.execute(activate_request)
|
22
|
+
end
|
23
|
+
|
24
|
+
def create_plan
|
25
|
+
request_body = {
|
26
|
+
"payment_definitions": [{
|
27
|
+
"amount": {
|
28
|
+
"value": "100",
|
29
|
+
"currency": "USD",
|
30
|
+
},
|
31
|
+
"frequency": "MONTH",
|
32
|
+
"cycles": "12",
|
33
|
+
"frequency_interval": "2",
|
34
|
+
"type": "REGULAR",
|
35
|
+
"name": "Regular Payments",
|
36
|
+
"charge_models": [{
|
37
|
+
"type": "SHIPPING",
|
38
|
+
"amount": {
|
39
|
+
"value": "10",
|
40
|
+
"currency": "USD",
|
41
|
+
},
|
42
|
+
}, {
|
43
|
+
"type": "TAX",
|
44
|
+
"amount": {
|
45
|
+
"value": "12",
|
46
|
+
"currency": "USD",
|
47
|
+
},
|
48
|
+
}],
|
49
|
+
}],
|
50
|
+
"merchant_preferences": {
|
51
|
+
"return_url": "http://localhost:3000/subscription/success",
|
52
|
+
"cancel_url": "http://localhost:3000/subscription/cancel",
|
53
|
+
},
|
54
|
+
"name": "T-Shirt of the Month Club Plan",
|
55
|
+
"description": "Template creation.",
|
56
|
+
"type": "fixed",
|
57
|
+
}
|
58
|
+
|
59
|
+
request = PlanCreateRequest.new()
|
60
|
+
request.request_body(request_body)
|
61
|
+
|
62
|
+
TestHarness::client.execute(request)
|
63
|
+
end
|
64
|
+
|
65
|
+
def get_plan(plan_id)
|
66
|
+
request = PlanGetRequest.new(plan_id)
|
67
|
+
|
68
|
+
TestHarness::client.execute(request)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require_relative '../../test_harness'
|
2
|
+
require_relative './plan_helper'
|
3
|
+
|
4
|
+
include PayPal::V1::BillingPlans
|
5
|
+
|
6
|
+
describe PlanListRequest do
|
7
|
+
it 'successfully makes a request' do
|
8
|
+
PlanHelper::create_plan
|
9
|
+
|
10
|
+
request = PlanListRequest.new()
|
11
|
+
|
12
|
+
resp = TestHarness::client.execute(request)
|
13
|
+
expect(resp.status_code).to eq(200)
|
14
|
+
expect(resp.result).not_to be_nil
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require_relative '../../test_harness'
|
2
|
+
require_relative './plan_helper'
|
3
|
+
|
4
|
+
include PayPal::V1::BillingPlans
|
5
|
+
|
6
|
+
describe PlanUpdateRequest do
|
7
|
+
it 'successfully makes a request' do
|
8
|
+
create_response = PlanHelper::create_plan
|
9
|
+
plan_id = create_response.result.id
|
10
|
+
|
11
|
+
activate_response = PlanHelper::activate_plan(plan_id)
|
12
|
+
|
13
|
+
expect(activate_response.status_code).to eq(200)
|
14
|
+
|
15
|
+
get_response = PlanHelper::get_plan(plan_id)
|
16
|
+
|
17
|
+
expect(get_response.result.state).to eq('ACTIVE')
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require_relative '../../test_harness'
|
2
|
+
require 'uri'
|
3
|
+
require 'cgi'
|
4
|
+
|
5
|
+
include PayPal::V1::Identity
|
6
|
+
|
7
|
+
describe UserinfoGetRequest do
|
8
|
+
|
9
|
+
it 'builds user consent url' do
|
10
|
+
builder = UserConsent.new(TestHarness::environment)
|
11
|
+
builder.response_type('code')
|
12
|
+
builder.scope('profile+email+openid+address')
|
13
|
+
builder.redirect_uri('http://example.com')
|
14
|
+
builder.state('some-state')
|
15
|
+
builder.nonce('some-nonce')
|
16
|
+
|
17
|
+
url = builder.build
|
18
|
+
|
19
|
+
parsed = URI(url)
|
20
|
+
|
21
|
+
expect(parsed.scheme).to eq('https')
|
22
|
+
expect(parsed.host).to eq('sandbox.paypal.com')
|
23
|
+
expect(parsed.path).to eq('/signin/authorize')
|
24
|
+
|
25
|
+
query = CGI::parse(parsed.query)
|
26
|
+
expect(query['response_type'][0]).to eq('code')
|
27
|
+
expect(query['scope'][0]).to eq('profile email openid address')
|
28
|
+
expect(query['redirect_uri'][0]).to eq('http://example.com')
|
29
|
+
expect(query['state'][0]).to eq('some-state')
|
30
|
+
expect(query['nonce'][0]).to eq('some-nonce')
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'gets refresh token from code', :skip => 'This test is an example of how to obtain user consent' do
|
34
|
+
builder = UserConsent.new(TestHarness::environment)
|
35
|
+
builder.redirect_uri(CGI::escape('http://requestbin.fullcontact.com/15a7bhu1'))
|
36
|
+
builder.response_type('code')
|
37
|
+
builder.scope('profile+email+openid+address')
|
38
|
+
|
39
|
+
url = builder.build
|
40
|
+
|
41
|
+
# Fetched from visiting the `url` and signing in w/ PayPal account
|
42
|
+
code = 'C21AAHkGGpGk-g8ZbMuKwTtisc6mkv18Tplrvu9RZR-_zmNQS0xthson09WpKA8vYi4G7ESo3fu694FXm3sxVRclBwg24b1MA'
|
43
|
+
|
44
|
+
environment = TestHarness::environment
|
45
|
+
refresh_token_request = PayPal::RefreshTokenRequest.new(environment, code)
|
46
|
+
token_response = TestHarness::exec(refresh_token_request)
|
47
|
+
|
48
|
+
expect(token_response.status_code).to eq(200)
|
49
|
+
expect(token_response.result).not_to be_nil
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'gets user info' do
|
53
|
+
# Fetched using the above example
|
54
|
+
refresh_token = 'R23AAEWf7GghkOpcrCXhiDkS2IpGPR-r_jMIez_gcTzrstXCsro0ZC2P8xEnv5lm4A8h2QXFhMhIcKI8Ak5lP8kIyZzCxqjg_JbX8QI7KJoXrbn57U19_tlfs-Z-seXHtK74OeGhJyGxfRTBLbOIw'
|
55
|
+
|
56
|
+
scoped_http_client = PayPal::PayPalHttpClient.new(TestHarness::environment, refresh_token)
|
57
|
+
|
58
|
+
request = UserinfoGetRequest.new()
|
59
|
+
request.schema('openid')
|
60
|
+
|
61
|
+
resp = scoped_http_client.execute(request)
|
62
|
+
expect(resp.status_code).to eq(200)
|
63
|
+
expect(resp.result).not_to be_nil
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require_relative '../../test_harness'
|
2
|
+
require_relative './invoice_helper'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
include PayPal::V1::Invoices
|
6
|
+
|
7
|
+
describe InvoiceCancelRequest do
|
8
|
+
it 'successfully makes a request' do
|
9
|
+
create_response = InvoiceHelper::create_invoice
|
10
|
+
InvoiceHelper::send_invoice(create_response.result.id)
|
11
|
+
|
12
|
+
request = InvoiceCancelRequest.new(create_response.result.id)
|
13
|
+
request.request_body({
|
14
|
+
:subject => 'Past Due',
|
15
|
+
:note => 'nevermind',
|
16
|
+
:send_to_merchant => true,
|
17
|
+
:send_to_payer => true,
|
18
|
+
})
|
19
|
+
|
20
|
+
resp = TestHarness::client.execute(request)
|
21
|
+
expect(resp.status_code).to eq(204)
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require_relative '../../test_harness'
|
2
|
+
require_relative './invoice_helper'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
include PayPal::V1::Invoices
|
6
|
+
|
7
|
+
describe InvoiceCreateRequest do
|
8
|
+
it 'successfully makes a request' do
|
9
|
+
invoice_create_response = InvoiceHelper::create_invoice
|
10
|
+
|
11
|
+
expect(invoice_create_response.status_code).to eq(201)
|
12
|
+
expect(invoice_create_response.result).not_to be_nil
|
13
|
+
expect(invoice_create_response.result.merchant_info.first_name).to eq('Dennis')
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require_relative '../../test_harness'
|
2
|
+
require_relative './invoice_helper'
|
3
|
+
|
4
|
+
include PayPal::V1::Invoices
|
5
|
+
|
6
|
+
describe InvoiceDeleteExternalPaymentRequest do
|
7
|
+
it 'successfully makes a request' do
|
8
|
+
create_response = InvoiceHelper::create_invoice
|
9
|
+
id = create_response.result.id
|
10
|
+
InvoiceHelper::record_payment(id)
|
11
|
+
|
12
|
+
get_response = InvoiceHelper::get_invoice(id)
|
13
|
+
|
14
|
+
txn_id = get_response.result.payments[0].transaction_id
|
15
|
+
request = InvoiceDeleteExternalPaymentRequest.new(id, txn_id)
|
16
|
+
|
17
|
+
resp = TestHarness::client.execute(request)
|
18
|
+
expect(resp.status_code).to eq(204)
|
19
|
+
|
20
|
+
get_response = InvoiceHelper::get_invoice(id)
|
21
|
+
expect(get_response.result.payments).to be_nil
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require_relative '../../test_harness'
|
2
|
+
require_relative './invoice_helper'
|
3
|
+
|
4
|
+
include PayPal::V1::Invoices
|
5
|
+
|
6
|
+
describe InvoiceDeleteExternalRefundRequest do
|
7
|
+
it 'successfully makes a request' do
|
8
|
+
create_response = InvoiceHelper::create_invoice
|
9
|
+
id = create_response.result.id
|
10
|
+
|
11
|
+
InvoiceHelper::record_refund(id)
|
12
|
+
|
13
|
+
get_response = InvoiceHelper::get_invoice(id)
|
14
|
+
refund_id = get_response.result.refunds[0].transaction_id
|
15
|
+
|
16
|
+
request = InvoiceDeleteExternalRefundRequest.new(id, refund_id)
|
17
|
+
|
18
|
+
resp = TestHarness::client.execute(request)
|
19
|
+
expect(resp.status_code).to eq(204)
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require_relative '../../test_harness'
|
2
|
+
require_relative './invoice_helper'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
include PayPal::V1::Invoices
|
6
|
+
|
7
|
+
describe InvoiceDeleteRequest do
|
8
|
+
it 'successfully makes a request' do
|
9
|
+
create_response = InvoiceHelper::create_invoice
|
10
|
+
|
11
|
+
request = InvoiceDeleteRequest.new(create_response.result.id)
|
12
|
+
|
13
|
+
resp = TestHarness::client.execute(request)
|
14
|
+
expect(resp.status_code).to eq(204)
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require_relative '../../test_harness'
|
2
|
+
require_relative './invoice_helper'
|
3
|
+
|
4
|
+
include PayPal::V1::Invoices
|
5
|
+
|
6
|
+
describe InvoiceGetRequest do
|
7
|
+
it 'successfully makes a request' do
|
8
|
+
create_response = InvoiceHelper::create_invoice
|
9
|
+
|
10
|
+
request = InvoiceGetRequest.new(create_response.result.id)
|
11
|
+
|
12
|
+
resp = TestHarness::client.execute(request)
|
13
|
+
expect(resp.status_code).to eq(200)
|
14
|
+
expect(resp.result).not_to be_nil
|
15
|
+
|
16
|
+
expect(resp.result.id).to eq(create_response.result.id)
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,171 @@
|
|
1
|
+
require_relative '../../test_harness'
|
2
|
+
|
3
|
+
include PayPal::V1::Invoices
|
4
|
+
|
5
|
+
module InvoiceHelper
|
6
|
+
class << self
|
7
|
+
def create_invoice
|
8
|
+
body = {
|
9
|
+
"merchant_info": {
|
10
|
+
"email": "team-dx-clients-facilitator@getbraintree.com",
|
11
|
+
"first_name": "Dennis",
|
12
|
+
"last_name": "Doctor",
|
13
|
+
"business_name": "Medical Professionals, LLC",
|
14
|
+
"phone": {
|
15
|
+
"country_code": "001",
|
16
|
+
"national_number": "5032141716",
|
17
|
+
},
|
18
|
+
"address": {
|
19
|
+
"line1": "1234 Main St.",
|
20
|
+
"city": "Portland",
|
21
|
+
"state": "OR",
|
22
|
+
"postal_code": "97217",
|
23
|
+
"country_code": "US",
|
24
|
+
},
|
25
|
+
},
|
26
|
+
"billing_info": [{
|
27
|
+
"email": "example@example.com",
|
28
|
+
}],
|
29
|
+
"items": [{
|
30
|
+
"name": "Sutures",
|
31
|
+
"quantity": 100.0,
|
32
|
+
"unit_price": {
|
33
|
+
"currency": "USD",
|
34
|
+
"value": 5,
|
35
|
+
},
|
36
|
+
}],
|
37
|
+
"note": "Medical Invoice 16 Jul, 2013 PST",
|
38
|
+
"payment_term": {
|
39
|
+
"term_type": "NET_45",
|
40
|
+
},
|
41
|
+
"shipping_info": {
|
42
|
+
"first_name": "Sally",
|
43
|
+
"last_name": "Patient",
|
44
|
+
"business_name": "Not applicable",
|
45
|
+
"phone": {
|
46
|
+
"country_code": "001",
|
47
|
+
"national_number": "5039871234",
|
48
|
+
},
|
49
|
+
"address": {
|
50
|
+
"line1": "1234 Broad St.",
|
51
|
+
"city": "Portland",
|
52
|
+
"state": "OR",
|
53
|
+
"postal_code": "97216",
|
54
|
+
"country_code": "US",
|
55
|
+
},
|
56
|
+
},
|
57
|
+
"tax_inclusive": false,
|
58
|
+
"total_amount": {
|
59
|
+
"currency": "USD",
|
60
|
+
"value": "500.00",
|
61
|
+
},
|
62
|
+
}
|
63
|
+
|
64
|
+
TestHarness::exec(InvoiceCreateRequest.new, body)
|
65
|
+
end
|
66
|
+
|
67
|
+
def get_invoice(id)
|
68
|
+
TestHarness::exec(InvoiceGetRequest.new(id))
|
69
|
+
end
|
70
|
+
|
71
|
+
def send_invoice(id)
|
72
|
+
req = InvoiceSendRequest.new(id)
|
73
|
+
req.notify_merchant(true)
|
74
|
+
|
75
|
+
TestHarness::exec(req)
|
76
|
+
end
|
77
|
+
|
78
|
+
def record_payment(id)
|
79
|
+
send_invoice(id)
|
80
|
+
|
81
|
+
request = InvoiceRecordPaymentRequest.new(id)
|
82
|
+
request.request_body({
|
83
|
+
:method => 'CASH',
|
84
|
+
:date => '2017-07-11 00:01:00 PST',
|
85
|
+
:amount => {
|
86
|
+
:value => '10',
|
87
|
+
:currency => 'USD',
|
88
|
+
},
|
89
|
+
})
|
90
|
+
|
91
|
+
TestHarness::exec(request)
|
92
|
+
end
|
93
|
+
|
94
|
+
def record_refund(id)
|
95
|
+
record_payment(id)
|
96
|
+
|
97
|
+
req = InvoiceRecordRefundRequest.new(id)
|
98
|
+
body = {
|
99
|
+
:amount => {
|
100
|
+
:value => '10',
|
101
|
+
:currency => 'USD',
|
102
|
+
},
|
103
|
+
}
|
104
|
+
|
105
|
+
TestHarness::exec(req, body)
|
106
|
+
end
|
107
|
+
|
108
|
+
def create_template
|
109
|
+
body = {
|
110
|
+
"name": "Hours Template_ruby#{Random.new.rand(1000000)}",
|
111
|
+
"default": true,
|
112
|
+
"unit_of_measure": "Hours",
|
113
|
+
"template_data": {
|
114
|
+
"items": [
|
115
|
+
{
|
116
|
+
"name": "Nutri Bullet",
|
117
|
+
"quantity": 1,
|
118
|
+
"unit_price": {
|
119
|
+
"currency": "USD",
|
120
|
+
"value": "50.00",
|
121
|
+
},
|
122
|
+
},
|
123
|
+
],
|
124
|
+
"merchant_info": {
|
125
|
+
"email": "team-dx-clients-facilitator@getbraintree.com",
|
126
|
+
},
|
127
|
+
"tax_calculated_after_discount": false,
|
128
|
+
"tax_inclusive": false,
|
129
|
+
"note": "Thank you for your business.",
|
130
|
+
"logo_url": "https://pics.paypal.com/v1/images/redDot.jpeg",
|
131
|
+
"allow_tip": true,
|
132
|
+
},
|
133
|
+
"settings": [
|
134
|
+
{
|
135
|
+
"field_name": "items.date",
|
136
|
+
"display_preference": {
|
137
|
+
"hidden": true,
|
138
|
+
},
|
139
|
+
},
|
140
|
+
{
|
141
|
+
"field_name": "custom",
|
142
|
+
"display_preference": {
|
143
|
+
"hidden": true,
|
144
|
+
},
|
145
|
+
},
|
146
|
+
],
|
147
|
+
}
|
148
|
+
|
149
|
+
TestHarness::exec(TemplateCreateRequest.new, body)
|
150
|
+
end
|
151
|
+
|
152
|
+
def get_template(id)
|
153
|
+
TestHarness::exec(TemplateGetRequest.new(id))
|
154
|
+
end
|
155
|
+
|
156
|
+
def delete_templates
|
157
|
+
list_resp = TestHarness::exec(TemplateListRequest.new)
|
158
|
+
|
159
|
+
puts "Deleting #{list_resp.result.templates.count} templates"
|
160
|
+
|
161
|
+
list_resp.result.templates.each do |template|
|
162
|
+
begin
|
163
|
+
TestHarness::exec(TemplateDeleteRequest.new(template.template_id))
|
164
|
+
puts "deleted #{template.template_id}"
|
165
|
+
rescue Exception => e
|
166
|
+
puts "Could not delete #{template.template_id}"
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|