paypal-sdk-invoice 1.100.0 → 1.101.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/Gemfile +1 -1
- data/README.md +11 -98
- data/lib/paypal-sdk/invoice/data_types.rb +30 -0
- data/lib/paypal-sdk/invoice/version.rb +1 -1
- data/spec/invoice_spec.rb +0 -9
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZmVlMGE2NDYxZmE5NTE3ZWQ3N2VmNWQ3MjllMWQ4MzVhYThkZmM2Mg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MjhlZjlkOWU0OTg5MzllMjIxOWEwNzVjYjg5ZTAyYzQ4NTYyZTVlMw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NGQ4YTM1YWIwZmEwOWQyMTM4OTQ1NjM2NGNkZTViNmU5ZWRlMDQwMGRmODBi
|
10
|
+
NjQ5NmRlOWIxMWRkOTJkMGJmYzg3MmMzNGIwNDI0NjkwMmM3ODI2NjgzZTlk
|
11
|
+
ZWNmYWZmZjU5NTA2OTVjNWE0NjQwMzUyNGFlZGRiM2QxNzM0YmQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NGJmZGZmMDI1OTM4OGJlNTg2OTA4OTcxZjRkYzNmYWMxOTNmNzVjOTU3NzI4
|
14
|
+
Zjk0MWZhOGRkOTAxZWQ0NDNiNDBlNzhiZmZmYzNkNTNkZGMwNzlhMTA2ZjJi
|
15
|
+
MDQ2ZGI1NTVjMjBiYTNiZTg4YTE4NGNmNDI2YjdjMDNmNmQwZmM=
|
data/Gemfile
CHANGED
@@ -8,7 +8,7 @@ if File.exist? File.expand_path('../samples/invoice_samples.gemspec', __FILE__)
|
|
8
8
|
gem 'invoice_samples', :path => 'samples', :require => false
|
9
9
|
group :test do
|
10
10
|
gem 'rspec-rails', :require => false
|
11
|
-
gem 'capybara', :require => false
|
11
|
+
gem 'capybara', '~> 2.0.3', :require => false
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
data/README.md
CHANGED
@@ -55,104 +55,13 @@ production:
|
|
55
55
|
<<: *default
|
56
56
|
mode: live
|
57
57
|
```
|
58
|
-
|
58
|
+
|
59
59
|
Load Configurations from specified file:
|
60
60
|
|
61
61
|
```ruby
|
62
62
|
PayPal::SDK::Core::Config.load('config/paypal.yml', ENV['RACK_ENV'] || 'development')
|
63
63
|
```
|
64
64
|
|
65
|
-
## Create API object
|
66
|
-
|
67
|
-
Create API object:
|
68
|
-
|
69
|
-
```ruby
|
70
|
-
api = PayPal::SDK::Invoice::API.new
|
71
|
-
```
|
72
|
-
|
73
|
-
Override configuration while creating a object:
|
74
|
-
|
75
|
-
```ruby
|
76
|
-
api = PayPal::SDK::Invoice::API.new(:development)
|
77
|
-
api = PayPal::SDK::Invoice::API.new(:development, :app_id => "XYZ")
|
78
|
-
api = PayPal::SDK::Invoice::API.new(:app_id => "XYZ") # Take default environment.
|
79
|
-
```
|
80
|
-
|
81
|
-
Change configuration:
|
82
|
-
|
83
|
-
```ruby
|
84
|
-
api.set_config :testing
|
85
|
-
api.set_config :testing, app_id => "XYZ"
|
86
|
-
```
|
87
|
-
|
88
|
-
|
89
|
-
## Build Request Object
|
90
|
-
|
91
|
-
To make api request, we need to build a request object.
|
92
|
-
|
93
|
-
```ruby
|
94
|
-
# To build a empty request object
|
95
|
-
create_invoice_request = api.build_create_invoice()
|
96
|
-
|
97
|
-
# To build a request object with default data
|
98
|
-
create_invoice_request = api.build_create_invoice( :invoice => { :merchantEmail => "jb-us-seller@paypal.com" })
|
99
|
-
```
|
100
|
-
|
101
|
-
|
102
|
-
The Build method can be access with camelcase or underscore:
|
103
|
-
|
104
|
-
```ruby
|
105
|
-
api = api.build_create_invoice()
|
106
|
-
# (or)
|
107
|
-
api = api.BuildCreateInvoice()
|
108
|
-
```
|
109
|
-
|
110
|
-
## Assign value to members
|
111
|
-
|
112
|
-
Members can be access with camelcase or underscore format.
|
113
|
-
|
114
|
-
```ruby
|
115
|
-
create_invoice_request.invoice.itemList.item[0].name = "item1"
|
116
|
-
# With underscore
|
117
|
-
create_invoice_request.invoice.item_list.item[0].name = "item1"
|
118
|
-
```
|
119
|
-
|
120
|
-
To Assign multiple values:
|
121
|
-
|
122
|
-
```ruby
|
123
|
-
create_invoice_request.invoice.itemList.item[0] = { :name => "item1", :quantity => 2.0, :unitPrice => 5.0 }
|
124
|
-
```
|
125
|
-
|
126
|
-
To Get members list for the given object( For Reference ):
|
127
|
-
|
128
|
-
```ruby
|
129
|
-
create_invoice_request.members
|
130
|
-
create_invoice_request.baseAmountList.members
|
131
|
-
```
|
132
|
-
|
133
|
-
## Make API Request
|
134
|
-
|
135
|
-
Make api call with request object:
|
136
|
-
|
137
|
-
```ruby
|
138
|
-
create_invoice_response = api.create_invoice(create_invoice_request)
|
139
|
-
```
|
140
|
-
|
141
|
-
Make api call with hash:
|
142
|
-
|
143
|
-
```ruby
|
144
|
-
create_invoice_response = api.create_invoice( :invoice => { :merchantEmail => "jb-us-seller@paypal.com", :payerEmail => "sender@yahoo.com" } )
|
145
|
-
```
|
146
|
-
|
147
|
-
## Access values from response object
|
148
|
-
|
149
|
-
To get response status:
|
150
|
-
|
151
|
-
```ruby
|
152
|
-
create_invoice_response.responseEnvelope.ack
|
153
|
-
```
|
154
|
-
|
155
|
-
|
156
65
|
## Example
|
157
66
|
|
158
67
|
```ruby
|
@@ -181,14 +90,18 @@ require 'paypal-sdk-invoice'
|
|
181
90
|
@create_invoice_response = @api.create_invoice(@create_invoice)
|
182
91
|
|
183
92
|
# Access Response
|
184
|
-
@create_invoice_response.
|
185
|
-
@create_invoice_response.invoiceID
|
186
|
-
@create_invoice_response.invoiceNumber
|
187
|
-
@create_invoice_response.invoiceURL
|
188
|
-
|
93
|
+
if @create_invoice_response.success?
|
94
|
+
@create_invoice_response.invoiceID
|
95
|
+
@create_invoice_response.invoiceNumber
|
96
|
+
@create_invoice_response.invoiceURL
|
97
|
+
else
|
98
|
+
@create_invoice_response.error
|
99
|
+
end
|
189
100
|
```
|
190
101
|
|
191
|
-
|
102
|
+
For more samples [paypal-sdk-samples.herokuapp.com/invoice/](https://paypal-sdk-samples.herokuapp.com/invoice/)
|
103
|
+
|
104
|
+
## Samples App
|
192
105
|
|
193
106
|
Add following line in rails `Gemfile`:
|
194
107
|
|
@@ -14,6 +14,22 @@ module PayPal::SDK
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
+
module ResponseStatus
|
18
|
+
Status = { :success => ["Success", "SuccessWithWarning"],
|
19
|
+
:warning => ["Warning", "SuccessWithWarning", "FailureWithWarning"],
|
20
|
+
:failure => ["Failure", "FailureWithWarning"] }
|
21
|
+
|
22
|
+
def response_status
|
23
|
+
self.responseEnvelope && self.responseEnvelope.ack
|
24
|
+
end
|
25
|
+
|
26
|
+
Status.keys.each do |status|
|
27
|
+
define_method("#{status}?") do
|
28
|
+
Status[status].include?(self.response_status)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
17
33
|
class EnumType < Core::API::DataTypes::Enum
|
18
34
|
end
|
19
35
|
|
@@ -59,6 +75,7 @@ module PayPal::SDK
|
|
59
75
|
# This specifies a fault, encapsulating error data, with specific error codes.
|
60
76
|
class FaultMessage < DataType
|
61
77
|
def self.load_members
|
78
|
+
include ResponseStatus
|
62
79
|
object_of :responseEnvelope, ResponseEnvelope, :required => true
|
63
80
|
array_of :error, ErrorData
|
64
81
|
end
|
@@ -220,6 +237,8 @@ module PayPal::SDK
|
|
220
237
|
object_of :merchantInfo, BusinessInfoType
|
221
238
|
# List of items included in this invoice.
|
222
239
|
object_of :itemList, InvoiceItemListType, :required => true
|
240
|
+
# If True, indicates tax calculated after discount. Default is False.
|
241
|
+
object_of :taxCalculatedAfterDiscount, Boolean
|
223
242
|
# Currency used for all invoice item amounts and totals.
|
224
243
|
object_of :currencyCode, String, :required => true
|
225
244
|
# Date on which the invoice will be enabled.
|
@@ -474,6 +493,7 @@ module PayPal::SDK
|
|
474
493
|
# The response object for CreateInvoice.
|
475
494
|
class CreateInvoiceResponse < DataType
|
476
495
|
def self.load_members
|
496
|
+
include ResponseStatus
|
477
497
|
object_of :responseEnvelope, ResponseEnvelope, :required => true
|
478
498
|
# The created invoice's ID.
|
479
499
|
object_of :invoiceID, String, :required => true
|
@@ -503,6 +523,7 @@ module PayPal::SDK
|
|
503
523
|
# The response object for SendInvoice.
|
504
524
|
class SendInvoiceResponse < DataType
|
505
525
|
def self.load_members
|
526
|
+
include ResponseStatus
|
506
527
|
object_of :responseEnvelope, ResponseEnvelope, :required => true
|
507
528
|
# The sent invoice's ID.
|
508
529
|
object_of :invoiceID, String, :required => true
|
@@ -528,6 +549,7 @@ module PayPal::SDK
|
|
528
549
|
# The response object for CreateAndSendInvoice.
|
529
550
|
class CreateAndSendInvoiceResponse < DataType
|
530
551
|
def self.load_members
|
552
|
+
include ResponseStatus
|
531
553
|
object_of :responseEnvelope, ResponseEnvelope, :required => true
|
532
554
|
# The created invoice's ID.
|
533
555
|
object_of :invoiceID, String, :required => true
|
@@ -559,6 +581,7 @@ module PayPal::SDK
|
|
559
581
|
# The response object for UpdateInvoice.
|
560
582
|
class UpdateInvoiceResponse < DataType
|
561
583
|
def self.load_members
|
584
|
+
include ResponseStatus
|
562
585
|
object_of :responseEnvelope, ResponseEnvelope, :required => true
|
563
586
|
# The invoice's ID.
|
564
587
|
object_of :invoiceID, String, :required => true
|
@@ -588,6 +611,7 @@ module PayPal::SDK
|
|
588
611
|
# The response object for CreateInvoice.
|
589
612
|
class GetInvoiceDetailsResponse < DataType
|
590
613
|
def self.load_members
|
614
|
+
include ResponseStatus
|
591
615
|
object_of :responseEnvelope, ResponseEnvelope, :required => true
|
592
616
|
# The requested invoice.
|
593
617
|
object_of :invoice, InvoiceType, :required => true
|
@@ -625,6 +649,7 @@ module PayPal::SDK
|
|
625
649
|
# The response object for CancelInvoice.
|
626
650
|
class CancelInvoiceResponse < DataType
|
627
651
|
def self.load_members
|
652
|
+
include ResponseStatus
|
628
653
|
object_of :responseEnvelope, ResponseEnvelope, :required => true
|
629
654
|
# The canceled invoice's ID.
|
630
655
|
object_of :invoiceID, String, :required => true
|
@@ -658,6 +683,7 @@ module PayPal::SDK
|
|
658
683
|
# The response object for SearchInvoices.
|
659
684
|
class SearchInvoicesResponse < DataType
|
660
685
|
def self.load_members
|
686
|
+
include ResponseStatus
|
661
687
|
object_of :responseEnvelope, ResponseEnvelope, :required => true
|
662
688
|
# Number of invoices that matched the search.
|
663
689
|
object_of :count, Integer, :required => true
|
@@ -691,6 +717,7 @@ module PayPal::SDK
|
|
691
717
|
# The response object for MarkInvoiceAsPaid.
|
692
718
|
class MarkInvoiceAsPaidResponse < DataType
|
693
719
|
def self.load_members
|
720
|
+
include ResponseStatus
|
694
721
|
object_of :responseEnvelope, ResponseEnvelope, :required => true
|
695
722
|
# The paid invoice ID.
|
696
723
|
object_of :invoiceID, String, :required => true
|
@@ -720,6 +747,7 @@ module PayPal::SDK
|
|
720
747
|
# The response object for MarkInvoiceAsRefunded.
|
721
748
|
class MarkInvoiceAsRefundedResponse < DataType
|
722
749
|
def self.load_members
|
750
|
+
include ResponseStatus
|
723
751
|
object_of :responseEnvelope, ResponseEnvelope, :required => true
|
724
752
|
# The invoice ID of the invoice that was marked as refunded.
|
725
753
|
object_of :invoiceID, String, :required => true
|
@@ -747,6 +775,7 @@ module PayPal::SDK
|
|
747
775
|
# The response object for MarkInvoiceAsUnpaid.
|
748
776
|
class MarkInvoiceAsUnpaidResponse < DataType
|
749
777
|
def self.load_members
|
778
|
+
include ResponseStatus
|
750
779
|
object_of :responseEnvelope, ResponseEnvelope, :required => true
|
751
780
|
# The invoice ID of the invoice that was marked as unpaid.
|
752
781
|
object_of :invoiceID, String, :required => true
|
@@ -788,6 +817,7 @@ module PayPal::SDK
|
|
788
817
|
# The response object for DeleteInvoice.
|
789
818
|
class DeleteInvoiceResponse < DataType
|
790
819
|
def self.load_members
|
820
|
+
include ResponseStatus
|
791
821
|
object_of :responseEnvelope, ResponseEnvelope, :required => true
|
792
822
|
array_of :error, ErrorData
|
793
823
|
end
|
data/spec/invoice_spec.rb
CHANGED
@@ -15,13 +15,4 @@ describe "Invoice" do
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
describe "DataTypes" do
|
19
|
-
PayPal::SDK::Invoice::DataTypes.constants.each do |const_name|
|
20
|
-
it "create object for #{const_name}" do
|
21
|
-
klass = PayPal::SDK::Invoice::DataTypes.const_get(const_name)
|
22
|
-
klass.new.should be_a klass
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
18
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paypal-sdk-invoice
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.101.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- PayPal
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: paypal-sdk-core
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.2.
|
19
|
+
version: 0.2.3
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.2.
|
26
|
+
version: 0.2.3
|
27
27
|
description: The PayPal Invoice SDK provides Ruby APIs to create and manage Invoices
|
28
28
|
using the PayPal's Invoicing Service API.
|
29
29
|
email:
|