paypal-rest-api 0.5.1 → 0.6.0
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 +4 -4
- data/README.md +214 -182
- data/VERSION +1 -1
- data/lib/paypal-api/api_collections/orders_v1.rb +74 -0
- data/lib/paypal-api/client/api_methods.rb +5 -0
- data/lib/paypal-api/network_error_builder.rb +1 -2
- data/lib/paypal-api/request_executor.rb +8 -8
- data/lib/paypal-api.rb +6 -0
- metadata +4 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 154aa3a4e9e77bf6a4d3a88a1f6061d995f7a4f0c6e97eda2c58df3892c64f60
|
4
|
+
data.tar.gz: bd4788d47f3173f2349888205873bb7e796296ee961b8edb17b59f3f07ecfa8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87b51280566237af1cbb7c569acc723b0f64051adccc3bbf68a18792dbbcd8442abbe6e6e984bdaea8d549d4fdc38d9525d5ea58db4c30fb7867e3726a888f4f
|
7
|
+
data.tar.gz: e6518c22a79a1a8afb31339c607b24732f9f4ef1fe9bdd3421c37ec22c1723cc81b49d1e9f6fbca661acdd4db2476c5f3228b278e1e68e6bddabdd725f0626b8
|
data/README.md
CHANGED
@@ -25,65 +25,82 @@ bundle add paypal-rest-api
|
|
25
25
|
|
26
26
|
## Usage
|
27
27
|
|
28
|
-
There are two options:
|
29
|
-
|
30
|
-
- Setting global client
|
31
|
-
- Setting local client (for possibility to use multiple PayPal environments)
|
32
|
-
|
33
|
-
### Setting global client
|
34
|
-
|
35
28
|
```ruby
|
36
29
|
# in config/initializers/paypal_rest_api.rb
|
37
30
|
PaypalAPI.client = PaypalAPI::Client.new(
|
38
31
|
client_id: ENV['PAYPAL_CLIENT_ID'],
|
39
32
|
client_secret: ENV['PAYPAL_CLIENT_SECRET'],
|
40
|
-
live:
|
33
|
+
live: ENV['PAYPAL_LIVE'] == 'true'
|
41
34
|
)
|
42
35
|
|
43
|
-
#
|
44
|
-
PaypalAPI.
|
45
|
-
|
46
|
-
|
36
|
+
# Use this API to create order
|
37
|
+
PaypalAPI::Orders.create(body: body, headers: {prefer: 'return=representation'})
|
38
|
+
|
39
|
+
# After customer approves order, we can tell PayPal to authorize it
|
40
|
+
PaypalAPI::Orders.authorize(order_id)
|
41
|
+
|
42
|
+
# After PayPal authorizes order, we can capture it
|
43
|
+
PaypalAPI::AuthorizedPayments.capture(authorization_id)
|
47
44
|
|
48
|
-
|
49
|
-
|
45
|
+
# After payment was captured, we can refund it
|
46
|
+
PaypalAPI::CapturedPayments.refund(capture_id, body: payload, headers: headers)
|
47
|
+
|
48
|
+
# Use this APIs to register/actualize PayPal Webhooks
|
49
|
+
PaypalAPI::Webhooks.list
|
50
|
+
PaypalAPI::Webhooks.create(body: body)
|
51
|
+
PaypalAPI::Webhooks.update(webhook_id, body: body)
|
52
|
+
PaypalAPI::Webhooks.delete(webhook_id)
|
50
53
|
```
|
51
54
|
|
52
|
-
###
|
55
|
+
### Per-request Configuration
|
53
56
|
|
54
57
|
```ruby
|
55
|
-
# in your business logic
|
58
|
+
# Anywhere in your business logic
|
56
59
|
client = PaypalAPI::Client.new(
|
57
60
|
client_id: ENV['PAYPAL_CLIENT_ID'],
|
58
61
|
client_secret: ENV['PAYPAL_CLIENT_SECRET'],
|
59
|
-
live:
|
62
|
+
live: ENV['PAYPAL_LIVE'] == 'true'
|
60
63
|
)
|
61
64
|
|
62
|
-
|
63
|
-
client.
|
64
|
-
client.web_url # => "https://sandbox.paypal.com"
|
65
|
+
# Show order
|
66
|
+
client.orders.show(order_id)
|
65
67
|
|
66
|
-
|
67
|
-
|
68
|
+
# Create order
|
69
|
+
client.orders.create(body: body)
|
68
70
|
```
|
69
71
|
|
70
|
-
###
|
72
|
+
### Custom requests
|
71
73
|
|
72
|
-
|
74
|
+
If you want to request some undocumented APIs (or some forgotten API):
|
73
75
|
|
74
76
|
```ruby
|
77
|
+
response = PaypalAPI.post(path, query: query, body: body, headers: headers)
|
78
|
+
response = PaypalAPI.get(path, query: query, body: body, headers: headers)
|
79
|
+
response = PaypalAPI.patch(path, query: query, body: body, headers: headers)
|
80
|
+
response = PaypalAPI.put(path, query: query, body: body, headers: headers)
|
81
|
+
response = PaypalAPI.delete(path, query: query, body: body, headers: headers)
|
82
|
+
|
83
|
+
# Or, using per-request client:
|
75
84
|
response = client.post(path, query: query, body: body, headers: headers)
|
76
85
|
response = client.get(path, query: query, body: body, headers: headers)
|
77
86
|
response = client.patch(path, query: query, body: body, headers: headers)
|
78
87
|
response = client.put(path, query: query, body: body, headers: headers)
|
79
88
|
response = client.delete(path, query: query, body: body, headers: headers)
|
89
|
+
```
|
80
90
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
91
|
+
### Environment helpers
|
92
|
+
|
93
|
+
```ruby
|
94
|
+
PaypalAPI.client = PaypalAPI::Client.new(
|
95
|
+
live: ENV['PAYPAL_LIVE'] == 'true',
|
96
|
+
client_id: ENV['PAYPAL_CLIENT_ID'],
|
97
|
+
client_secret: ENV['PAYPAL_CLIENT_SECRET']
|
98
|
+
)
|
99
|
+
|
100
|
+
PaypalAPI.live? # => false
|
101
|
+
PaypalAPI.sandbox? # => true
|
102
|
+
PaypalAPI.api_url # => "https://api-m.sandbox.paypal.com"
|
103
|
+
PaypalAPI.web_url # => "https://sandbox.paypal.com"
|
87
104
|
```
|
88
105
|
|
89
106
|
### Response
|
@@ -128,7 +145,7 @@ response = PaypalAPI.delete(path, query: query, body: body, headers: headers)
|
|
128
145
|
PaypalAPI client accepts this additional options:
|
129
146
|
|
130
147
|
- `:live`
|
131
|
-
- `:retries
|
148
|
+
- `:retries`
|
132
149
|
- `:http_opts`
|
133
150
|
- `:cache`
|
134
151
|
|
@@ -139,7 +156,7 @@ When `live` is `false` all requests will be send to the sandbox endpoints.
|
|
139
156
|
|
140
157
|
```ruby
|
141
158
|
client = PaypalAPI::Client.new(
|
142
|
-
live: true
|
159
|
+
live: ENV['PAYPAL_LIVE'] == 'true'
|
143
160
|
# ...
|
144
161
|
)
|
145
162
|
```
|
@@ -180,9 +197,9 @@ client = PaypalAPI::Client.new(
|
|
180
197
|
|
181
198
|
### Option `:cache`
|
182
199
|
|
183
|
-
This option can be added to save certificates
|
184
|
-
webhooks offline. By default this gem has only in-memory
|
185
|
-
|
200
|
+
This option can be added to save webhook-validating certificates between
|
201
|
+
redeploys to validate webhooks offline. By default this gem has only in-memory
|
202
|
+
caching. The `cache` object must respond to standard for caching `#fetch` method.
|
186
203
|
|
187
204
|
By default it is `nil`, so downloaded certificates will be downloaded again after
|
188
205
|
redeploys.
|
@@ -228,7 +245,7 @@ valid webhook.
|
|
228
245
|
When some required header is missing the
|
229
246
|
`PaypalAPI::WebhooksVerifier::MissingHeader` error will be raised.
|
230
247
|
|
231
|
-
Example of Rails controller with webhook verification:
|
248
|
+
Example of a Rails controller with a webhook verification:
|
232
249
|
|
233
250
|
```ruby
|
234
251
|
class Webhooks::PaypalController < ApplicationController
|
@@ -257,15 +274,13 @@ end
|
|
257
274
|
|
258
275
|
## Callbacks
|
259
276
|
|
260
|
-
|
277
|
+
Paypal::API client allows to subscribe to this callbacks:
|
261
278
|
|
262
279
|
- `:before` - Runs before request
|
263
280
|
- `:after_success` - Runs after getting successful response
|
264
281
|
- `:after_fail` - Runs after getting failed response (non-2xx) status code
|
265
282
|
- `:after_network_error` - Runs after getting network error
|
266
283
|
|
267
|
-
Callbacks are registered on `client` object.
|
268
|
-
|
269
284
|
Each callback receive `request` and `context` variables.
|
270
285
|
`context` can be modified manually to save state between callbacks.
|
271
286
|
|
@@ -276,8 +291,10 @@ Arguments:
|
|
276
291
|
- `:after_fail` - (request, context, response)
|
277
292
|
- `:after_network_error` - (request, context, error)
|
278
293
|
|
279
|
-
`Context` argument contains `retries_enabled
|
280
|
-
`retry_number`
|
294
|
+
`Context` argument contains `retries_enabled`, `retries_count` and
|
295
|
+
`retry_number` options by default.
|
296
|
+
On `:after_fail` and `:after_network_error` there are also the
|
297
|
+
`:will_retry` boolean option.
|
281
298
|
|
282
299
|
Examples:
|
283
300
|
|
@@ -381,201 +398,216 @@ end
|
|
381
398
|
|
382
399
|
## APIs
|
383
400
|
|
384
|
-
All API endpoints accept
|
401
|
+
All API endpoints accept `query:`, `body:` and `headers:` **optional** **keyword**
|
402
|
+
**Hash** parameters. So this parameters can be omitted in next docs.
|
385
403
|
|
386
|
-
- `resource_id` - Resource ID (Unless `create`/`list` endpoint)
|
387
404
|
- `query` - Hash with request query params
|
388
405
|
- `body` - Hash with request body params
|
389
406
|
- `headers` - Hash with request headers
|
390
407
|
|
391
|
-
###
|
408
|
+
### Add tracking / Shipment Tracking [docs](https://developer.paypal.com/docs/api/tracking/v1/)
|
392
409
|
|
393
|
-
- `PaypalAPI::
|
394
|
-
- `PaypalAPI::
|
395
|
-
- `PaypalAPI::
|
396
|
-
- `PaypalAPI::Orders.confirm`
|
397
|
-
- `PaypalAPI::Orders.authorize`
|
398
|
-
- `PaypalAPI::Orders.capture`
|
399
|
-
- `PaypalAPI::Orders.track`
|
400
|
-
- `PaypalAPI::Orders.update_tracker`
|
401
|
-
|
402
|
-
### Payment Tokens
|
410
|
+
- `PaypalAPI::ShipmentTracking.add(body: body)`
|
411
|
+
- `PaypalAPI::ShipmentTracking.update(id, body: body)`
|
412
|
+
- `PaypalAPI::ShipmentTracking.show(id)`
|
403
413
|
|
404
|
-
|
405
|
-
- `PaypalAPI::PaymentTokens.list`
|
406
|
-
- `PaypalAPI::PaymentTokens.show`
|
407
|
-
- `PaypalAPI::PaymentTokens.delete`
|
414
|
+
### Catalog Products [docs](https://developer.paypal.com/docs/api/catalog-products/v1/)
|
408
415
|
|
409
|
-
|
416
|
+
- `PaypalAPI::CatalogProducts.create(body: body)`
|
417
|
+
- `PaypalAPI::CatalogProducts.list`
|
418
|
+
- `PaypalAPI::CatalogProducts.show(product_id)`
|
419
|
+
- `PaypalAPI::CatalogProducts.update(product_id, body: body)`
|
410
420
|
|
411
|
-
|
412
|
-
- `PaypalAPI::SetupTokens.show`
|
421
|
+
### Disputes [docs](https://developer.paypal.com/docs/api/customer-disputes/v1/)
|
413
422
|
|
414
|
-
|
423
|
+
- `PaypalAPI::Disputes.settle(id)`
|
424
|
+
- `PaypalAPI::Disputes.update_status(id)`
|
425
|
+
- `PaypalAPI::Disputes.escalate(id)`
|
426
|
+
- `PaypalAPI::Disputes.accept_offer(id)`
|
427
|
+
- `PaypalAPI::Disputes.list`
|
428
|
+
- `PaypalAPI::Disputes.provide_supporting_info(id)`
|
429
|
+
- `PaypalAPI::Disputes.show(id)`
|
430
|
+
- `PaypalAPI::Disputes.update(id)`
|
431
|
+
- `PaypalAPI::Disputes.deny_offer(id)`
|
432
|
+
- `PaypalAPI::Disputes.make_offer(id)`
|
433
|
+
- `PaypalAPI::Disputes.appeal(id)`
|
434
|
+
- `PaypalAPI::Disputes.provide_evidence(id)`
|
435
|
+
- `PaypalAPI::Disputes.acknowledge_return_item`
|
436
|
+
- `PaypalAPI::Disputes.send_message(id)`
|
437
|
+
- `PaypalAPI::Disputes.accept_claim`(id)
|
415
438
|
|
416
|
-
|
417
|
-
- `PaypalAPI::AuthorizedPayments.capture`
|
418
|
-
- `PaypalAPI::AuthorizedPayments.reauthorize`
|
419
|
-
- `PaypalAPI::AuthorizedPayments.void`
|
439
|
+
### Identity [docs](https://developer.paypal.com/docs/api/identity/v1/)
|
420
440
|
|
421
|
-
|
441
|
+
#### User Info
|
422
442
|
|
423
|
-
- `PaypalAPI::
|
424
|
-
- `PaypalAPI::CapturedPayments.refund`
|
443
|
+
- `PaypalAPI::UserInfo.show`
|
425
444
|
|
426
|
-
|
445
|
+
#### User Management
|
427
446
|
|
428
|
-
- `PaypalAPI::
|
447
|
+
- `PaypalAPI::Users.create`
|
448
|
+
- `PaypalAPI::Users.list`
|
449
|
+
- `PaypalAPI::Users.update(id)`
|
450
|
+
- `PaypalAPI::Users.show(id)`
|
451
|
+
- `PaypalAPI::Users.delete(id)`
|
429
452
|
|
430
|
-
###
|
453
|
+
### Invoicing (Invoices & Invoice Templates) [docs](https://developer.paypal.com/docs/api/invoicing/v2/)
|
431
454
|
|
432
|
-
- `PaypalAPI::
|
433
|
-
- `PaypalAPI::
|
434
|
-
- `PaypalAPI::
|
435
|
-
- `PaypalAPI::
|
436
|
-
- `PaypalAPI::
|
437
|
-
- `PaypalAPI::
|
438
|
-
- `PaypalAPI::
|
455
|
+
- `PaypalAPI::Invoices.create`
|
456
|
+
- `PaypalAPI::Invoices.list`
|
457
|
+
- `PaypalAPI::Invoices.send_invoice(invoice_id)`
|
458
|
+
- `PaypalAPI::Invoices.remind(invoice_id)`
|
459
|
+
- `PaypalAPI::Invoices.cancel(invoice_id)`
|
460
|
+
- `PaypalAPI::Invoices.record_payment(invoice_id)`
|
461
|
+
- `PaypalAPI::Invoices.delete_payment(invoice_id)`
|
462
|
+
- `PaypalAPI::Invoices.record_refund(invoice_id)`
|
463
|
+
- `PaypalAPI::Invoices.delete_refund(invoice_id)`
|
464
|
+
- `PaypalAPI::Invoices.generate_qr_code(invoice_id)`
|
465
|
+
- `PaypalAPI::Invoices.generate_invoice_number`
|
466
|
+
- `PaypalAPI::Invoices.show(invoice_id)`
|
467
|
+
- `PaypalAPI::Invoices.update(invoice_id)`
|
468
|
+
- `PaypalAPI::Invoices.delete(invoice_id)`
|
469
|
+
- `PaypalAPI::Invoices.search`
|
439
470
|
|
440
471
|
<!-- -->
|
441
472
|
|
442
|
-
- `PaypalAPI::
|
443
|
-
- `PaypalAPI::
|
444
|
-
- `PaypalAPI::
|
445
|
-
- `PaypalAPI::
|
446
|
-
- `PaypalAPI::
|
473
|
+
- `PaypalAPI::InvoiceTemplates.create`
|
474
|
+
- `PaypalAPI::InvoiceTemplates.list`
|
475
|
+
- `PaypalAPI::InvoiceTemplates.show(template_id)`
|
476
|
+
- `PaypalAPI::InvoiceTemplates.update(template_id)`
|
477
|
+
- `PaypalAPI::InvoiceTemplates.delete(template_id)`
|
447
478
|
|
448
|
-
|
479
|
+
### Orders [docs](https://developer.paypal.com/docs/api/orders/v2/)
|
449
480
|
|
450
|
-
- `PaypalAPI::
|
451
|
-
- `PaypalAPI::
|
452
|
-
- `PaypalAPI::
|
453
|
-
- `PaypalAPI::
|
481
|
+
- `PaypalAPI::Orders.create`
|
482
|
+
- `PaypalAPI::Orders.show(order_id)`
|
483
|
+
- `PaypalAPI::Orders.update(order_id)`
|
484
|
+
- `PaypalAPI::Orders.confirm(order_id)`
|
485
|
+
- `PaypalAPI::Orders.authorize(order_id)`
|
486
|
+
- `PaypalAPI::Orders.capture(order_id)`
|
487
|
+
- `PaypalAPI::Orders.track(order_id)`
|
488
|
+
- `PaypalAPI::Orders.update_tracker(order_id, tracker_id)`
|
454
489
|
|
455
|
-
###
|
490
|
+
### Orders V1 (Deprecated on PayPal) [docs](https://developer.paypal.com/docs/api/orders/v1/)
|
456
491
|
|
457
|
-
- `PaypalAPI::
|
458
|
-
- `PaypalAPI::
|
459
|
-
- `PaypalAPI::
|
460
|
-
- `PaypalAPI::
|
461
|
-
- `PaypalAPI::Subscriptions.suspend`
|
462
|
-
- `PaypalAPI::Subscriptions.cancel`
|
463
|
-
- `PaypalAPI::Subscriptions.activate`
|
464
|
-
- `PaypalAPI::Subscriptions.capture`
|
465
|
-
- `PaypalAPI::Subscriptions.transactions`
|
492
|
+
- `PaypalAPI::OrdersV1.create`
|
493
|
+
- `PaypalAPI::OrdersV1.show(order_id)`
|
494
|
+
- `PaypalAPI::OrdersV1.cancel(order_id)`
|
495
|
+
- `PaypalAPI::OrdersV1.pay(order_id)`
|
466
496
|
|
467
|
-
|
497
|
+
### PartnerReferrals [docs](https://developer.paypal.com/docs/api/partner-referrals/v2/)
|
468
498
|
|
469
|
-
- `PaypalAPI::
|
470
|
-
- `PaypalAPI::
|
471
|
-
- `PaypalAPI::SubscriptionPlans.show`
|
472
|
-
- `PaypalAPI::SubscriptionPlans.update`
|
473
|
-
- `PaypalAPI::SubscriptionPlans.activate`
|
474
|
-
- `PaypalAPI::SubscriptionPlans.deactivate`
|
475
|
-
- `PaypalAPI::SubscriptionPlans.update_pricing`
|
499
|
+
- `PaypalAPI::PartnerReferrals.create`
|
500
|
+
- `PaypalAPI::PartnerReferrals.show(partner_referral_id)`
|
476
501
|
|
477
|
-
###
|
502
|
+
### Payment Experience Web Profiles [docs](https://developer.paypal.com/docs/api/payment-experience/v1/)
|
478
503
|
|
479
|
-
- `PaypalAPI::
|
480
|
-
- `PaypalAPI::
|
481
|
-
- `PaypalAPI::
|
504
|
+
- `PaypalAPI::PaymentExperienceWebProfiles.create`
|
505
|
+
- `PaypalAPI::PaymentExperienceWebProfiles.list`
|
506
|
+
- `PaypalAPI::PaymentExperienceWebProfiles.show`
|
507
|
+
- `PaypalAPI::PaymentExperienceWebProfiles.replace`
|
508
|
+
- `PaypalAPI::PaymentExperienceWebProfiles.update`
|
509
|
+
- `PaypalAPI::PaymentExperienceWebProfiles.delete`
|
482
510
|
|
483
|
-
###
|
511
|
+
### Payment Method Tokens / Setup Tokens [docs](https://developer.paypal.com/docs/api/payment-tokens/v3/)
|
484
512
|
|
485
|
-
- `PaypalAPI::
|
486
|
-
- `PaypalAPI::
|
487
|
-
- `PaypalAPI::
|
488
|
-
- `PaypalAPI::
|
489
|
-
|
490
|
-
### Disputes
|
491
|
-
|
492
|
-
- `PaypalAPI::Disputes.appeal`
|
493
|
-
- `PaypalAPI::Disputes.make_offer`
|
494
|
-
- `PaypalAPI::Disputes.show`
|
495
|
-
- `PaypalAPI::Disputes.update`
|
496
|
-
- `PaypalAPI::Disputes.send_message`
|
497
|
-
- `PaypalAPI::Disputes.provide_supporting_info`
|
498
|
-
- `PaypalAPI::Disputes.update_status`
|
499
|
-
- `PaypalAPI::Disputes.deny_offer`
|
500
|
-
- `PaypalAPI::Disputes.provide_evidence`
|
501
|
-
- `PaypalAPI::Disputes.settle`
|
502
|
-
- `PaypalAPI::Disputes.acknowledge_return_item`
|
503
|
-
- `PaypalAPI::Disputes.accept_claim`
|
504
|
-
- `PaypalAPI::Disputes.list`
|
505
|
-
- `PaypalAPI::Disputes.escalate`
|
506
|
-
- `PaypalAPI::Disputes.accept_offer`
|
513
|
+
- `PaypalAPI::PaymentTokens.create`
|
514
|
+
- `PaypalAPI::PaymentTokens.list`
|
515
|
+
- `PaypalAPI::PaymentTokens.show(id)`
|
516
|
+
- `PaypalAPI::PaymentTokens.delete(id)`
|
507
517
|
|
508
|
-
|
518
|
+
<!-- -->
|
509
519
|
|
510
|
-
- `PaypalAPI::
|
520
|
+
- `PaypalAPI::SetupTokens.create`
|
521
|
+
- `PaypalAPI::SetupTokens.show(setup_token_id)`
|
511
522
|
|
512
|
-
###
|
523
|
+
### Payments (Authorized Payments, Captured Payments, Refunds) [docs](https://developer.paypal.com/docs/api/payments/v2/)
|
513
524
|
|
514
|
-
- `PaypalAPI::
|
515
|
-
- `PaypalAPI::
|
516
|
-
- `PaypalAPI::
|
517
|
-
- `PaypalAPI::
|
518
|
-
- `PaypalAPI::Users.delete`
|
525
|
+
- `PaypalAPI::AuthorizedPayments.show(authorization_id)`
|
526
|
+
- `PaypalAPI::AuthorizedPayments.capture(authorization_id)`
|
527
|
+
- `PaypalAPI::AuthorizedPayments.reauthorize(authorization_id)`
|
528
|
+
- `PaypalAPI::AuthorizedPayments.void(authorization_id)`
|
519
529
|
|
520
|
-
|
530
|
+
<!-- -->
|
521
531
|
|
522
|
-
- `PaypalAPI::
|
523
|
-
- `PaypalAPI::
|
524
|
-
- `PaypalAPI::Invoices.show`
|
525
|
-
- `PaypalAPI::Invoices.update`
|
526
|
-
- `PaypalAPI::Invoices.delete`
|
527
|
-
- `PaypalAPI::Invoices.search`
|
528
|
-
- `PaypalAPI::Invoices.remind`
|
529
|
-
- `PaypalAPI::Invoices.delete_refund`
|
530
|
-
- `PaypalAPI::Invoices.delete_payment`
|
531
|
-
- `PaypalAPI::Invoices.record_refund`
|
532
|
-
- `PaypalAPI::Invoices.record_payment`
|
533
|
-
- `PaypalAPI::Invoices.send_invoice`
|
534
|
-
- `PaypalAPI::Invoices.cancel`
|
535
|
-
- `PaypalAPI::Invoices.generate_qr_code`
|
536
|
-
- `PaypalAPI::Invoices.generate_invoice_number`
|
532
|
+
- `PaypalAPI::CapturedPayments.show(capture_id)`
|
533
|
+
- `PaypalAPI::CapturedPayments.refund(capture_id)`
|
537
534
|
|
538
|
-
|
535
|
+
<!-- -->
|
539
536
|
|
540
|
-
- `PaypalAPI::
|
541
|
-
- `PaypalAPI::InvoiceTemplates.list`
|
542
|
-
- `PaypalAPI::InvoiceTemplates.show`
|
543
|
-
- `PaypalAPI::InvoiceTemplates.update`
|
544
|
-
- `PaypalAPI::InvoiceTemplates.delete`
|
537
|
+
- `PaypalAPI::Refunds.show(refund_id)`
|
545
538
|
|
546
|
-
### Payouts
|
539
|
+
### Payouts / Payout Items [docs](https://developer.paypal.com/docs/api/payments.payouts-batch/v1/)
|
547
540
|
|
548
541
|
- `PaypalAPI::Payouts.create`
|
549
|
-
- `PaypalAPI::Payouts.show`
|
550
|
-
|
551
|
-
|
542
|
+
- `PaypalAPI::Payouts.show(payout_id)`
|
543
|
+
|
544
|
+
<!-- -->
|
545
|
+
|
546
|
+
- `PaypalAPI::PayoutItems.show(payout_item_id)`
|
547
|
+
- `PaypalAPI::PayoutItems.cancel(payout_item_id)`
|
552
548
|
|
553
|
-
###
|
549
|
+
### Referenced Payouts / Referenced Payout Items [docs](https://developer.paypal.com/docs/api/referenced-payouts/v1/)
|
554
550
|
|
555
551
|
- `PaypalAPI::ReferencedPayouts.create`
|
556
|
-
- `PaypalAPI::ReferencedPayouts.show`
|
552
|
+
- `PaypalAPI::ReferencedPayouts.show(payouts_batch_id)`
|
553
|
+
|
554
|
+
<!-- -->
|
555
|
+
|
557
556
|
- `PaypalAPI::ReferencedPayoutItems.create`
|
558
|
-
- `PaypalAPI::ReferencedPayoutItems.show`
|
557
|
+
- `PaypalAPI::ReferencedPayoutItems.show(payouts_item_id)`
|
559
558
|
|
560
|
-
###
|
559
|
+
### Subscriptions / Subscription Plans [docs](https://developer.paypal.com/docs/api/subscriptions/v1/)
|
561
560
|
|
562
|
-
- `PaypalAPI::
|
563
|
-
- `PaypalAPI::
|
561
|
+
- `PaypalAPI::Subscriptions.create`
|
562
|
+
- `PaypalAPI::Subscriptions.show(id)`
|
563
|
+
- `PaypalAPI::Subscriptions.update(id)`
|
564
|
+
- `PaypalAPI::Subscriptions.revise(id)`
|
565
|
+
- `PaypalAPI::Subscriptions.suspend(id)`
|
566
|
+
- `PaypalAPI::Subscriptions.cancel(id)`
|
567
|
+
- `PaypalAPI::Subscriptions.activate(id)`
|
568
|
+
- `PaypalAPI::Subscriptions.capture(id)`
|
569
|
+
- `PaypalAPI::Subscriptions.transactions(id)`
|
564
570
|
|
565
|
-
|
571
|
+
<!-- -->
|
566
572
|
|
567
|
-
- `PaypalAPI::
|
568
|
-
- `PaypalAPI::
|
569
|
-
- `PaypalAPI::
|
570
|
-
- `PaypalAPI::
|
571
|
-
- `PaypalAPI::
|
572
|
-
- `PaypalAPI::
|
573
|
+
- `PaypalAPI::SubscriptionPlans.create`
|
574
|
+
- `PaypalAPI::SubscriptionPlans.list`
|
575
|
+
- `PaypalAPI::SubscriptionPlans.show(plan_id)`
|
576
|
+
- `PaypalAPI::SubscriptionPlans.update(plan_id)`
|
577
|
+
- `PaypalAPI::SubscriptionPlans.activate(plan_id)`
|
578
|
+
- `PaypalAPI::SubscriptionPlans.deactivate(plan_id)`
|
579
|
+
- `PaypalAPI::SubscriptionPlans.update_pricing(plan_id)`
|
573
580
|
|
574
|
-
###
|
581
|
+
### Transaction Search [docs](https://developer.paypal.com/docs/api/transaction-search/v1/)
|
575
582
|
|
576
583
|
- `PaypalAPI::TransactionSearch.list_transactions`
|
577
584
|
- `PaypalAPI::TransactionSearch.list_all_balances`
|
578
585
|
|
586
|
+
### Webhooks Management [docs](https://developer.paypal.com/docs/api/webhooks/v1/)
|
587
|
+
|
588
|
+
- `PaypalAPI::Webhooks.create`
|
589
|
+
- `PaypalAPI::Webhooks.list`
|
590
|
+
- `PaypalAPI::Webhooks.show(webhook_id)`
|
591
|
+
- `PaypalAPI::Webhooks.update(webhook_id)`
|
592
|
+
- `PaypalAPI::Webhooks.delete(webhook_id)`
|
593
|
+
- `PaypalAPI::Webhooks.event_types(webhook_id)`
|
594
|
+
- `PaypalAPI::Webhooks.verify`
|
595
|
+
|
596
|
+
<!-- -->
|
597
|
+
|
598
|
+
- `PaypalAPI::WebhookEvents.available`
|
599
|
+
- `PaypalAPI::WebhookEvents.list`
|
600
|
+
- `PaypalAPI::WebhookEvents.show(event_id)`
|
601
|
+
- `PaypalAPI::WebhookEvents.resend(event_id)`
|
602
|
+
- `PaypalAPI::WebhookEvents.simulate`
|
603
|
+
|
604
|
+
<!-- -->
|
605
|
+
|
606
|
+
- `PaypalAPI::WebhookLookups.create`
|
607
|
+
- `PaypalAPI::WebhookLookups.list`
|
608
|
+
- `PaypalAPI::WebhookLookups.show(webhook_lookup_id)`
|
609
|
+
- `PaypalAPI::WebhookLookups.delete(webhook_lookup_id)`
|
610
|
+
|
579
611
|
## Development
|
580
612
|
|
581
613
|
```bash
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.6.0
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module PaypalAPI
|
4
|
+
#
|
5
|
+
# DEPRECATED: Orders V1
|
6
|
+
#
|
7
|
+
# @see https://developer.paypal.com/docs/api/orders/v1/
|
8
|
+
#
|
9
|
+
class OrdersV1 < APICollection
|
10
|
+
#
|
11
|
+
# Common methods for PaypalAPI::OrdersV1 class and client.orders_v1 instance
|
12
|
+
#
|
13
|
+
module APIs
|
14
|
+
# @!macro [new] request
|
15
|
+
# @param query [Hash, nil] Request query parameters
|
16
|
+
# @param body [Hash, nil] Request body parameters
|
17
|
+
# @param headers [Hash, nil] Request headers
|
18
|
+
# @return [Response] Response object
|
19
|
+
|
20
|
+
#
|
21
|
+
# Create Order
|
22
|
+
# @note This method is DEPRECATED on PayPal
|
23
|
+
#
|
24
|
+
# @see https://developer.paypal.com/docs/api/orders/v1/#orders_create
|
25
|
+
#
|
26
|
+
# @macro request
|
27
|
+
#
|
28
|
+
def create(query: nil, body: nil, headers: nil)
|
29
|
+
client.post("/v1/checkout/orders", query: query, body: body, headers: headers)
|
30
|
+
end
|
31
|
+
|
32
|
+
#
|
33
|
+
# Show order details
|
34
|
+
# @note This method is DEPRECATED on PayPal
|
35
|
+
#
|
36
|
+
# @see https://developer.paypal.com/docs/api/orders/v1/#orders_get
|
37
|
+
#
|
38
|
+
# @param id [String] Order ID
|
39
|
+
# @macro request
|
40
|
+
#
|
41
|
+
def show(id, query: nil, body: nil, headers: nil)
|
42
|
+
client.get("/v1/checkout/orders/#{encode(id)}", query: query, body: body, headers: headers)
|
43
|
+
end
|
44
|
+
|
45
|
+
#
|
46
|
+
# Cancel order
|
47
|
+
# @note This method is DEPRECATED on PayPal
|
48
|
+
#
|
49
|
+
# @see https://developer.paypal.com/docs/api/orders/v1/#orders_cancel
|
50
|
+
#
|
51
|
+
# @param id [String] Order ID
|
52
|
+
# @macro request
|
53
|
+
#
|
54
|
+
def cancel(id, query: nil, body: nil, headers: nil)
|
55
|
+
client.delete("/v1/checkout/orders/#{encode(id)}", query: query, body: body, headers: headers)
|
56
|
+
end
|
57
|
+
|
58
|
+
#
|
59
|
+
# Pay for order
|
60
|
+
#
|
61
|
+
# @see https://developer.paypal.com/docs/api/orders/v1/#orders_pay
|
62
|
+
#
|
63
|
+
# @param id [String] Order ID
|
64
|
+
# @macro request
|
65
|
+
#
|
66
|
+
def pay(id, query: nil, body: nil, headers: nil)
|
67
|
+
client.post("/v1/checkout/orders/#{encode(id)}/pay", query: query, body: body, headers: headers)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
include APIs
|
72
|
+
extend APIs
|
73
|
+
end
|
74
|
+
end
|
@@ -46,6 +46,11 @@ module PaypalAPI
|
|
46
46
|
Orders.new(self)
|
47
47
|
end
|
48
48
|
|
49
|
+
# @return [OrdersV1] DEPRECATED: Orders V1 APIs collection
|
50
|
+
def orders_v1
|
51
|
+
OrdersV1.new(self)
|
52
|
+
end
|
53
|
+
|
49
54
|
# @return [PartnerReferrals] PartnerReferrals APIs collection
|
50
55
|
def partner_referrals
|
51
56
|
PartnerReferrals.new(self)
|
@@ -7,14 +7,13 @@ module PaypalAPI
|
|
7
7
|
class NetworkErrorBuilder
|
8
8
|
# List of possible Network errors
|
9
9
|
ERRORS = [
|
10
|
-
|
10
|
+
IOError,
|
11
11
|
Errno::ECONNABORTED,
|
12
12
|
Errno::ECONNREFUSED,
|
13
13
|
Errno::ECONNRESET,
|
14
14
|
Errno::EHOSTUNREACH,
|
15
15
|
Errno::EPIPE,
|
16
16
|
Errno::ETIMEDOUT,
|
17
|
-
IOError,
|
18
17
|
OpenSSL::SSL::SSLError,
|
19
18
|
SocketError,
|
20
19
|
Timeout::Error # Net::OpenTimeout, Net::ReadTimeout
|
@@ -30,6 +30,14 @@ module PaypalAPI
|
|
30
30
|
|
31
31
|
private
|
32
32
|
|
33
|
+
def execute_request(retry_number: 0)
|
34
|
+
response = start_execution(retry_number)
|
35
|
+
rescue => error
|
36
|
+
unknown_network_error?(error) ? handle_unknown_error(error) : handle_network_error(error, retry_number)
|
37
|
+
else
|
38
|
+
response.success? ? handle_success_response(response) : handle_failed_response(response, retry_number)
|
39
|
+
end
|
40
|
+
|
33
41
|
def start_execution(retry_number)
|
34
42
|
callbacks_context[:retry_number] = retry_number
|
35
43
|
run_callbacks(:before)
|
@@ -58,14 +66,6 @@ module PaypalAPI
|
|
58
66
|
will_retry ? retry_request(retry_number) : response
|
59
67
|
end
|
60
68
|
|
61
|
-
def execute_request(retry_number: 0)
|
62
|
-
response = start_execution(retry_number)
|
63
|
-
rescue => error
|
64
|
-
unknown_network_error?(error) ? handle_unknown_error(error) : handle_network_error(error, retry_number)
|
65
|
-
else
|
66
|
-
response.success? ? handle_success_response(response) : handle_failed_response(response, retry_number)
|
67
|
-
end
|
68
|
-
|
69
69
|
def execute_net_http_request
|
70
70
|
uri = request.uri
|
71
71
|
|
data/lib/paypal-api.rb
CHANGED
@@ -137,6 +137,10 @@ module PaypalAPI
|
|
137
137
|
# @macro api_collection
|
138
138
|
# @return [Orders]
|
139
139
|
#
|
140
|
+
# @!method orders_v1
|
141
|
+
# @macro api_collection
|
142
|
+
# @return [OrdersV1]
|
143
|
+
#
|
140
144
|
# @!method partner_referrals
|
141
145
|
# @macro api_collection
|
142
146
|
# @return [PartnerReferrals]
|
@@ -210,6 +214,7 @@ module PaypalAPI
|
|
210
214
|
invoice_templates
|
211
215
|
invoices
|
212
216
|
orders
|
217
|
+
orders_v1
|
213
218
|
partner_referrals
|
214
219
|
payment_experience_web_profiles
|
215
220
|
payment_tokens
|
@@ -272,6 +277,7 @@ require_relative "paypal-api/api_collections/disputes"
|
|
272
277
|
require_relative "paypal-api/api_collections/invoice_templates"
|
273
278
|
require_relative "paypal-api/api_collections/invoices"
|
274
279
|
require_relative "paypal-api/api_collections/orders"
|
280
|
+
require_relative "paypal-api/api_collections/orders_v1"
|
275
281
|
require_relative "paypal-api/api_collections/partner_referrals"
|
276
282
|
require_relative "paypal-api/api_collections/payment_experience_web_profiles"
|
277
283
|
require_relative "paypal-api/api_collections/payment_tokens"
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paypal-rest-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrey Glushkov
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-02-03 00:00:00.000000000 Z
|
12
11
|
dependencies: []
|
13
12
|
description: PayPal REST API with no dependencies.
|
14
13
|
email:
|
@@ -30,6 +29,7 @@ files:
|
|
30
29
|
- lib/paypal-api/api_collections/invoice_templates.rb
|
31
30
|
- lib/paypal-api/api_collections/invoices.rb
|
32
31
|
- lib/paypal-api/api_collections/orders.rb
|
32
|
+
- lib/paypal-api/api_collections/orders_v1.rb
|
33
33
|
- lib/paypal-api/api_collections/partner_referrals.rb
|
34
34
|
- lib/paypal-api/api_collections/payment_experience_web_profiles.rb
|
35
35
|
- lib/paypal-api/api_collections/payment_tokens.rb
|
@@ -72,7 +72,6 @@ metadata:
|
|
72
72
|
source_code_uri: https://github.com/aglushkov/paypal-rest-api
|
73
73
|
documentation_uri: https://www.rubydoc.info/gems/paypal-rest-api
|
74
74
|
changelog_uri: https://github.com/aglushkov/paypal-rest-api/blob/master/CHANGELOG.md
|
75
|
-
post_install_message:
|
76
75
|
rdoc_options: []
|
77
76
|
require_paths:
|
78
77
|
- lib
|
@@ -87,8 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
86
|
- !ruby/object:Gem::Version
|
88
87
|
version: '0'
|
89
88
|
requirements: []
|
90
|
-
rubygems_version: 3.
|
91
|
-
signing_key:
|
89
|
+
rubygems_version: 3.6.3
|
92
90
|
specification_version: 4
|
93
91
|
summary: PayPal REST API
|
94
92
|
test_files: []
|