paypal-sdk-rest 0.7.3 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/paypal-sdk/rest/api.rb +1 -1
- data/lib/paypal-sdk/rest/data_types.rb +1659 -1138
- data/lib/paypal-sdk/rest/version.rb +1 -1
- data/spec/README.md +34 -0
- data/spec/invoice_examples_spec.rb +4 -4
- data/spec/log/http.log +755 -0
- data/spec/payments_examples_spec.rb +54 -12
- data/spec/spec_helper.rb +2 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50c4b6c303398d0616d50cca9ea5425372504ad6
|
4
|
+
data.tar.gz: 64101a28702aeb06650d5b4043e432b270df0706
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6ed80f9ad8cd1456ea216c3a4c88843a66bbcccd394c81dc77f9a4aba62bdaff2b53cfcb6bd788fe638c6644f6eba7dd6a046a7566e1d476d2958505145bd1d
|
7
|
+
data.tar.gz: 5547cde29565746be4709da67471ab14e7e683bf5b10d3716aadfee44c9ffce9139e3acbcb2e0ca16176b9fcd4e9be9990f4dc2131b4a9dad0e98b49faf92c4a
|
data/lib/paypal-sdk/rest/api.rb
CHANGED
@@ -1,1138 +1,1659 @@
|
|
1
|
-
require 'paypal-sdk-core'
|
2
|
-
require 'uuidtools'
|
3
|
-
|
4
|
-
module PayPal::SDK
|
5
|
-
module REST
|
6
|
-
module DataTypes
|
7
|
-
class Base < Core::API::DataTypes::Base
|
8
|
-
attr_accessor :error
|
9
|
-
attr_writer :header, :request_id
|
10
|
-
|
11
|
-
def header
|
12
|
-
@header ||= {}
|
13
|
-
end
|
14
|
-
|
15
|
-
def request_id
|
16
|
-
@request_id ||= UUIDTools::UUID.random_create.to_s
|
17
|
-
end
|
18
|
-
|
19
|
-
def http_header
|
20
|
-
{ "PayPal-Request-Id" => request_id.to_s }.merge(header)
|
21
|
-
end
|
22
|
-
|
23
|
-
def success?
|
24
|
-
@error.nil?
|
25
|
-
end
|
26
|
-
|
27
|
-
def merge!(values)
|
28
|
-
@error = nil
|
29
|
-
super
|
30
|
-
end
|
31
|
-
|
32
|
-
def self.load_members
|
33
|
-
end
|
34
|
-
|
35
|
-
class Number < Float
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
class
|
40
|
-
|
41
|
-
def self.load_members
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
self.
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
end
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
def
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
end
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
end
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
def
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
end
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
self.
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
path = "v1/
|
967
|
-
|
968
|
-
end
|
969
|
-
end
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1092
|
-
def
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1112
|
-
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1121
|
-
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1129
|
-
|
1130
|
-
|
1131
|
-
|
1132
|
-
|
1133
|
-
|
1134
|
-
|
1135
|
-
|
1136
|
-
|
1137
|
-
|
1138
|
-
|
1
|
+
require 'paypal-sdk-core'
|
2
|
+
require 'uuidtools'
|
3
|
+
|
4
|
+
module PayPal::SDK
|
5
|
+
module REST
|
6
|
+
module DataTypes
|
7
|
+
class Base < Core::API::DataTypes::Base
|
8
|
+
attr_accessor :error
|
9
|
+
attr_writer :header, :request_id
|
10
|
+
|
11
|
+
def header
|
12
|
+
@header ||= {}
|
13
|
+
end
|
14
|
+
|
15
|
+
def request_id
|
16
|
+
@request_id ||= UUIDTools::UUID.random_create.to_s
|
17
|
+
end
|
18
|
+
|
19
|
+
def http_header
|
20
|
+
{ "PayPal-Request-Id" => request_id.to_s }.merge(header)
|
21
|
+
end
|
22
|
+
|
23
|
+
def success?
|
24
|
+
@error.nil?
|
25
|
+
end
|
26
|
+
|
27
|
+
def merge!(values)
|
28
|
+
@error = nil
|
29
|
+
super
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.load_members
|
33
|
+
end
|
34
|
+
|
35
|
+
class Number < Float
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
class Payment < Base
|
40
|
+
|
41
|
+
def self.load_members
|
42
|
+
object_of :id, String
|
43
|
+
object_of :intent, String
|
44
|
+
object_of :payer, Payer
|
45
|
+
object_of :cart, String
|
46
|
+
array_of :transactions, Transaction
|
47
|
+
array_of :failed_transactions, Error
|
48
|
+
object_of :payment_instruction, PaymentInstruction
|
49
|
+
object_of :state, String
|
50
|
+
object_of :experience_profile_id, String
|
51
|
+
object_of :redirect_urls, RedirectUrls
|
52
|
+
object_of :create_time, String
|
53
|
+
object_of :update_time, String
|
54
|
+
array_of :links, Links
|
55
|
+
end
|
56
|
+
|
57
|
+
include RequestDataType
|
58
|
+
|
59
|
+
def create()
|
60
|
+
path = "v1/payments/payment"
|
61
|
+
response = api.post(path, self.to_hash, http_header)
|
62
|
+
self.merge!(response)
|
63
|
+
success?
|
64
|
+
end
|
65
|
+
|
66
|
+
class << self
|
67
|
+
def find(resource_id)
|
68
|
+
raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
|
69
|
+
path = "v1/payments/payment/#{resource_id}"
|
70
|
+
self.new(api.get(path))
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def update(patch_request)
|
75
|
+
patch_request = PatchRequest.new(patch_request) unless patch_request.is_a? PatchRequest
|
76
|
+
path = "v1/payments/payment/#{self.id}"
|
77
|
+
response = api.patch(path, patch_request.to_hash, http_header)
|
78
|
+
object.new(response)
|
79
|
+
end
|
80
|
+
|
81
|
+
def execute(payment_execution)
|
82
|
+
payment_execution = PaymentExecution.new(payment_execution) unless payment_execution.is_a? PaymentExecution
|
83
|
+
path = "v1/payments/payment/#{self.id}/execute"
|
84
|
+
response = api.post(path, payment_execution.to_hash, http_header)
|
85
|
+
self.merge!(response)
|
86
|
+
success?
|
87
|
+
end
|
88
|
+
|
89
|
+
class << self
|
90
|
+
def all(options = {})
|
91
|
+
path = "v1/payments/payment"
|
92
|
+
PaymentHistory.new(api.get(path, options))
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
class Payer < Base
|
98
|
+
|
99
|
+
def self.load_members
|
100
|
+
object_of :payment_method, String
|
101
|
+
object_of :status, String
|
102
|
+
array_of :funding_instruments, FundingInstrument
|
103
|
+
object_of :funding_option_id, String
|
104
|
+
object_of :funding_option, FundingOption
|
105
|
+
object_of :related_funding_option, FundingOption
|
106
|
+
object_of :payer_info, PayerInfo
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
110
|
+
class FundingInstrument < Base
|
111
|
+
|
112
|
+
def self.load_members
|
113
|
+
object_of :credit_card, CreditCard
|
114
|
+
object_of :credit_card_token, CreditCardToken
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
118
|
+
class CreditCard < Base
|
119
|
+
|
120
|
+
def self.load_members
|
121
|
+
object_of :id, String
|
122
|
+
object_of :number, String
|
123
|
+
object_of :type, String
|
124
|
+
object_of :expire_month, Integer
|
125
|
+
object_of :expire_year, Integer
|
126
|
+
object_of :cvv2, String
|
127
|
+
object_of :first_name, String
|
128
|
+
object_of :last_name, String
|
129
|
+
object_of :billing_address, Address
|
130
|
+
object_of :external_customer_id, String
|
131
|
+
object_of :state, String
|
132
|
+
object_of :valid_until, String
|
133
|
+
object_of :create_time, String
|
134
|
+
object_of :update_time, String
|
135
|
+
array_of :links, Links
|
136
|
+
end
|
137
|
+
|
138
|
+
include RequestDataType
|
139
|
+
|
140
|
+
def create()
|
141
|
+
path = "v1/vault/credit-card"
|
142
|
+
response = api.post(path, self.to_hash, http_header)
|
143
|
+
self.merge!(response)
|
144
|
+
success?
|
145
|
+
end
|
146
|
+
|
147
|
+
class << self
|
148
|
+
def find(resource_id)
|
149
|
+
raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
|
150
|
+
path = "v1/vault/credit-card/#{resource_id}"
|
151
|
+
self.new(api.get(path))
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
def delete()
|
156
|
+
path = "v1/vault/credit-card/#{self.id}"
|
157
|
+
response = api.delete(path, {})
|
158
|
+
self.merge!(response)
|
159
|
+
success?
|
160
|
+
end
|
161
|
+
|
162
|
+
def update()
|
163
|
+
path = "v1/vault/credit-card/#{self.id}"
|
164
|
+
response = api.patch(path, self.to_hash, http_header)
|
165
|
+
self.merge!(response)
|
166
|
+
success?
|
167
|
+
end
|
168
|
+
|
169
|
+
end
|
170
|
+
class Address < Base
|
171
|
+
|
172
|
+
def self.load_members
|
173
|
+
object_of :line1, String
|
174
|
+
object_of :line2, String
|
175
|
+
object_of :city, String
|
176
|
+
object_of :country_code, String
|
177
|
+
object_of :postal_code, String
|
178
|
+
object_of :state, String
|
179
|
+
object_of :phone, String
|
180
|
+
object_of :normalization_status, String
|
181
|
+
end
|
182
|
+
|
183
|
+
end
|
184
|
+
class OneOf < Base
|
185
|
+
|
186
|
+
def self.load_members
|
187
|
+
object_of :phone, Phone
|
188
|
+
end
|
189
|
+
|
190
|
+
end
|
191
|
+
class CreditCardToken < Base
|
192
|
+
|
193
|
+
def self.load_members
|
194
|
+
object_of :credit_card_id, String
|
195
|
+
object_of :payer_id, String
|
196
|
+
object_of :last4, String
|
197
|
+
object_of :type, String
|
198
|
+
object_of :expire_month, Integer
|
199
|
+
object_of :expire_year, Integer
|
200
|
+
end
|
201
|
+
|
202
|
+
end
|
203
|
+
class PaymentCard < Base
|
204
|
+
|
205
|
+
def self.load_members
|
206
|
+
object_of :id, String
|
207
|
+
object_of :number, String
|
208
|
+
object_of :type, String
|
209
|
+
object_of :expire_month, Integer
|
210
|
+
object_of :expire_year, Integer
|
211
|
+
object_of :start_month, String
|
212
|
+
object_of :start_year, String
|
213
|
+
object_of :cvv2, String
|
214
|
+
object_of :first_name, String
|
215
|
+
object_of :last_name, String
|
216
|
+
object_of :billing_country, String
|
217
|
+
object_of :billing_address, Address
|
218
|
+
object_of :external_customer_id, String
|
219
|
+
object_of :status, String
|
220
|
+
object_of :valid_until, String
|
221
|
+
end
|
222
|
+
|
223
|
+
end
|
224
|
+
class BankAccount < Base
|
225
|
+
|
226
|
+
def self.load_members
|
227
|
+
object_of :id, String
|
228
|
+
object_of :account_number, String
|
229
|
+
object_of :account_number_type, String
|
230
|
+
object_of :routing_number, String
|
231
|
+
object_of :account_type, String
|
232
|
+
object_of :account_name, String
|
233
|
+
object_of :check_type, String
|
234
|
+
object_of :auth_type, String
|
235
|
+
object_of :auth_capture_timestamp, String
|
236
|
+
object_of :bank_name, String
|
237
|
+
object_of :country_code, String
|
238
|
+
object_of :first_name, String
|
239
|
+
object_of :last_name, String
|
240
|
+
object_of :birth_date, String
|
241
|
+
object_of :billing_address, Address
|
242
|
+
object_of :state, String
|
243
|
+
object_of :confirmation_status, String
|
244
|
+
object_of :payer_id, String
|
245
|
+
object_of :external_customer_id, String
|
246
|
+
object_of :merchant_id, String
|
247
|
+
object_of :create_time, String
|
248
|
+
object_of :update_time, String
|
249
|
+
object_of :valid_until, String
|
250
|
+
end
|
251
|
+
|
252
|
+
include RequestDataType
|
253
|
+
|
254
|
+
def create()
|
255
|
+
path = "v1/vault/bank-accounts"
|
256
|
+
response = api.post(path, self.to_hash, http_header)
|
257
|
+
self.merge!(response)
|
258
|
+
success?
|
259
|
+
end
|
260
|
+
|
261
|
+
class << self
|
262
|
+
def find(resource_id)
|
263
|
+
raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
|
264
|
+
path = "v1/vault/bank-accounts/#{resource_id}"
|
265
|
+
self.new(api.get(path))
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
def delete()
|
270
|
+
path = "v1/vault/bank-accounts/#{self.id}"
|
271
|
+
response = api.delete(path, {})
|
272
|
+
self.merge!(response)
|
273
|
+
success?
|
274
|
+
end
|
275
|
+
|
276
|
+
def update(patch_request)
|
277
|
+
patch_request = PatchRequest.new(patch_request) unless patch_request.is_a? PatchRequest
|
278
|
+
path = "v1/vault/bank-accounts/#{self.id}"
|
279
|
+
response = api.patch(path, patch_request.to_hash, http_header)
|
280
|
+
self.merge!(response)
|
281
|
+
success?
|
282
|
+
end
|
283
|
+
|
284
|
+
end
|
285
|
+
class ExtendedBankAccount < BankAccount
|
286
|
+
|
287
|
+
def self.load_members
|
288
|
+
object_of :mandate_reference_number, String
|
289
|
+
end
|
290
|
+
|
291
|
+
end
|
292
|
+
class BankToken < Base
|
293
|
+
|
294
|
+
def self.load_members
|
295
|
+
object_of :bank_id, String
|
296
|
+
object_of :external_customer_id, String
|
297
|
+
object_of :mandate_reference_number, String
|
298
|
+
end
|
299
|
+
|
300
|
+
end
|
301
|
+
class Credit < Base
|
302
|
+
|
303
|
+
def self.load_members
|
304
|
+
object_of :id, String
|
305
|
+
object_of :type, String
|
306
|
+
end
|
307
|
+
|
308
|
+
end
|
309
|
+
class Incentive < Base
|
310
|
+
|
311
|
+
def self.load_members
|
312
|
+
object_of :id, String
|
313
|
+
object_of :code, String
|
314
|
+
object_of :name, String
|
315
|
+
object_of :description, String
|
316
|
+
object_of :minimum_purchase_amount, Currency
|
317
|
+
object_of :logo_image_url, String
|
318
|
+
object_of :expiry_date, String
|
319
|
+
object_of :type, String
|
320
|
+
object_of :terms, String
|
321
|
+
end
|
322
|
+
|
323
|
+
end
|
324
|
+
class Currency < Base
|
325
|
+
|
326
|
+
def self.load_members
|
327
|
+
object_of :currency, String
|
328
|
+
object_of :value, String
|
329
|
+
end
|
330
|
+
|
331
|
+
end
|
332
|
+
class CarrierAccountToken < Base
|
333
|
+
|
334
|
+
def self.load_members
|
335
|
+
object_of :carrier_account_id, String
|
336
|
+
object_of :external_customer_id, String
|
337
|
+
end
|
338
|
+
|
339
|
+
end
|
340
|
+
class FundingOption < Base
|
341
|
+
|
342
|
+
def self.load_members
|
343
|
+
object_of :id, String
|
344
|
+
array_of :funding_sources, FundingSource
|
345
|
+
object_of :backup_funding_instrument, FundingInstrument
|
346
|
+
object_of :currency_conversion, CurrencyConversion
|
347
|
+
object_of :installment_info, InstallmentInfo
|
348
|
+
end
|
349
|
+
|
350
|
+
end
|
351
|
+
class FundingSource < Base
|
352
|
+
|
353
|
+
def self.load_members
|
354
|
+
object_of :funding_mode, String
|
355
|
+
object_of :funding_instrument_type, String
|
356
|
+
object_of :soft_descriptor, String
|
357
|
+
object_of :amount, Currency
|
358
|
+
object_of :legal_text, String
|
359
|
+
object_of :funding_detail, FundingDetail
|
360
|
+
object_of :additional_text, String
|
361
|
+
object_of :extends, FundingInstrument
|
362
|
+
end
|
363
|
+
|
364
|
+
end
|
365
|
+
class FundingDetail < Base
|
366
|
+
|
367
|
+
def self.load_members
|
368
|
+
object_of :clearing_time, String
|
369
|
+
object_of :payment_hold_date, String
|
370
|
+
end
|
371
|
+
|
372
|
+
end
|
373
|
+
class CurrencyConversion < Base
|
374
|
+
|
375
|
+
def self.load_members
|
376
|
+
object_of :conversion_date, String
|
377
|
+
object_of :from_currency, String
|
378
|
+
object_of :from_amount, Number
|
379
|
+
object_of :to_currency, String
|
380
|
+
object_of :to_amount, Number
|
381
|
+
object_of :conversion_type, String
|
382
|
+
object_of :conversion_type_changeable, Boolean
|
383
|
+
object_of :web_url, String
|
384
|
+
end
|
385
|
+
|
386
|
+
end
|
387
|
+
class InstallmentInfo < Base
|
388
|
+
|
389
|
+
def self.load_members
|
390
|
+
object_of :installment_id, String
|
391
|
+
object_of :network, String
|
392
|
+
object_of :issuer, String
|
393
|
+
array_of :installment_options, InstallmentOption
|
394
|
+
end
|
395
|
+
|
396
|
+
end
|
397
|
+
class InstallmentOption < Base
|
398
|
+
|
399
|
+
def self.load_members
|
400
|
+
object_of :term, Integer
|
401
|
+
object_of :monthly_payment, Currency
|
402
|
+
object_of :discount_amount, Currency
|
403
|
+
object_of :discount_percentage, Percentage
|
404
|
+
end
|
405
|
+
|
406
|
+
end
|
407
|
+
class Percentage < Base
|
408
|
+
|
409
|
+
def self.load_members
|
410
|
+
end
|
411
|
+
|
412
|
+
end
|
413
|
+
class PayerInfo < Base
|
414
|
+
|
415
|
+
def self.load_members
|
416
|
+
object_of :email, String
|
417
|
+
object_of :external_remember_me_id, String
|
418
|
+
object_of :buyer_account_number, String
|
419
|
+
object_of :first_name, String
|
420
|
+
object_of :last_name, String
|
421
|
+
object_of :payer_id, String
|
422
|
+
object_of :phone, String
|
423
|
+
object_of :phone_type, String
|
424
|
+
object_of :birth_date, String
|
425
|
+
object_of :tax_id, String
|
426
|
+
object_of :tax_id_type, String
|
427
|
+
object_of :billing_address, Address
|
428
|
+
object_of :shipping_address, ShippingAddress
|
429
|
+
end
|
430
|
+
|
431
|
+
end
|
432
|
+
class ShippingAddress < Base
|
433
|
+
|
434
|
+
def self.load_members
|
435
|
+
object_of :line1, String
|
436
|
+
object_of :city, String
|
437
|
+
object_of :state, String
|
438
|
+
object_of :postal_code, String
|
439
|
+
object_of :country_code, String
|
440
|
+
object_of :recipient_name, String
|
441
|
+
end
|
442
|
+
|
443
|
+
end
|
444
|
+
class AllOf < Base
|
445
|
+
|
446
|
+
def self.load_members
|
447
|
+
array_of :related_resources, RelatedResources
|
448
|
+
end
|
449
|
+
|
450
|
+
end
|
451
|
+
class Transaction < Base
|
452
|
+
|
453
|
+
def self.load_members
|
454
|
+
object_of :amount, Amount
|
455
|
+
object_of :payee, Payee
|
456
|
+
object_of :description, String
|
457
|
+
object_of :invoice_number, String
|
458
|
+
object_of :custom, String
|
459
|
+
object_of :soft_descriptor, String
|
460
|
+
object_of :item_list, ItemList
|
461
|
+
array_of :related_resources, RelatedResources
|
462
|
+
array_of :transactions, Transaction
|
463
|
+
end
|
464
|
+
|
465
|
+
end
|
466
|
+
class CartBase < Base
|
467
|
+
|
468
|
+
def self.load_members
|
469
|
+
object_of :amount, Amount
|
470
|
+
object_of :payee, Payee
|
471
|
+
object_of :description, String
|
472
|
+
object_of :note_to_payee, String
|
473
|
+
object_of :custom, String
|
474
|
+
object_of :invoice_number, String
|
475
|
+
object_of :soft_descriptor, String
|
476
|
+
object_of :payment_options, PaymentOptions
|
477
|
+
object_of :item_list, ItemList
|
478
|
+
end
|
479
|
+
|
480
|
+
end
|
481
|
+
class Amount < Base
|
482
|
+
|
483
|
+
def self.load_members
|
484
|
+
object_of :currency, String
|
485
|
+
object_of :total, String
|
486
|
+
object_of :details, Details
|
487
|
+
end
|
488
|
+
|
489
|
+
end
|
490
|
+
class Details < Base
|
491
|
+
|
492
|
+
def self.load_members
|
493
|
+
object_of :subtotal, String
|
494
|
+
object_of :shipping, String
|
495
|
+
object_of :tax, String
|
496
|
+
object_of :handling_fee, String
|
497
|
+
object_of :shipping_discount, String
|
498
|
+
object_of :insurance, String
|
499
|
+
object_of :gift_wrap, String
|
500
|
+
end
|
501
|
+
|
502
|
+
end
|
503
|
+
class Payee < Base
|
504
|
+
|
505
|
+
def self.load_members
|
506
|
+
end
|
507
|
+
|
508
|
+
end
|
509
|
+
class Phone < Base
|
510
|
+
|
511
|
+
def self.load_members
|
512
|
+
object_of :country_code, String
|
513
|
+
object_of :national_number, String
|
514
|
+
object_of :extension, String
|
515
|
+
end
|
516
|
+
|
517
|
+
end
|
518
|
+
class PaymentOptions < Base
|
519
|
+
|
520
|
+
def self.load_members
|
521
|
+
object_of :allowed_payment_method, String
|
522
|
+
end
|
523
|
+
|
524
|
+
end
|
525
|
+
class Item < Base
|
526
|
+
|
527
|
+
def self.load_members
|
528
|
+
object_of :quantity, String
|
529
|
+
object_of :name, String
|
530
|
+
object_of :description, String
|
531
|
+
object_of :price, String
|
532
|
+
object_of :tax, String
|
533
|
+
object_of :currency, String
|
534
|
+
object_of :sku, String
|
535
|
+
object_of :url, String
|
536
|
+
object_of :category, String
|
537
|
+
array_of :supplementary_data, NameValuePair
|
538
|
+
array_of :postback_data, NameValuePair
|
539
|
+
end
|
540
|
+
|
541
|
+
end
|
542
|
+
class NameValuePair < Base
|
543
|
+
|
544
|
+
def self.load_members
|
545
|
+
object_of :name, String
|
546
|
+
object_of :value, String
|
547
|
+
end
|
548
|
+
|
549
|
+
end
|
550
|
+
class ItemList < Base
|
551
|
+
|
552
|
+
def self.load_members
|
553
|
+
array_of :items, Item
|
554
|
+
object_of :shipping_address, ShippingAddress
|
555
|
+
end
|
556
|
+
|
557
|
+
end
|
558
|
+
class RelatedResources < Base
|
559
|
+
|
560
|
+
def self.load_members
|
561
|
+
object_of :order, Order
|
562
|
+
object_of :sale, Sale
|
563
|
+
object_of :authorization, Authorization
|
564
|
+
object_of :capture, Capture
|
565
|
+
object_of :refund, Refund
|
566
|
+
end
|
567
|
+
|
568
|
+
end
|
569
|
+
class Sale < Base
|
570
|
+
|
571
|
+
def self.load_members
|
572
|
+
object_of :id, String
|
573
|
+
object_of :purchase_unit_reference_id, String
|
574
|
+
object_of :amount, Amount
|
575
|
+
object_of :payment_mode, String
|
576
|
+
object_of :state, String
|
577
|
+
object_of :reason_code, String
|
578
|
+
object_of :protection_eligibility, String
|
579
|
+
object_of :protection_eligibility_type, String
|
580
|
+
object_of :clearing_time, String
|
581
|
+
object_of :parent_payment, String
|
582
|
+
object_of :create_time, String
|
583
|
+
object_of :update_time, String
|
584
|
+
array_of :links, Links
|
585
|
+
end
|
586
|
+
|
587
|
+
include RequestDataType
|
588
|
+
|
589
|
+
class << self
|
590
|
+
def find(resource_id)
|
591
|
+
raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
|
592
|
+
path = "v1/payments/sale/#{resource_id}"
|
593
|
+
self.new(api.get(path))
|
594
|
+
end
|
595
|
+
end
|
596
|
+
|
597
|
+
def refund(refund)
|
598
|
+
refund = Refund.new(refund) unless refund.is_a? Refund
|
599
|
+
path = "v1/payments/sale/#{self.id}/refund"
|
600
|
+
response = api.post(path, refund.to_hash, http_header)
|
601
|
+
Refund.new(response)
|
602
|
+
end
|
603
|
+
|
604
|
+
end
|
605
|
+
class AnyOf < Base
|
606
|
+
|
607
|
+
def self.load_members
|
608
|
+
object_of :refund, Refund
|
609
|
+
end
|
610
|
+
|
611
|
+
end
|
612
|
+
class Authorization < Base
|
613
|
+
|
614
|
+
def self.load_members
|
615
|
+
object_of :id, String
|
616
|
+
object_of :amount, Amount
|
617
|
+
object_of :payment_mode, String
|
618
|
+
object_of :state, String
|
619
|
+
object_of :protection_eligibility, String
|
620
|
+
object_of :protection_eligibility_type, String
|
621
|
+
object_of :parent_payment, String
|
622
|
+
object_of :valid_until, String
|
623
|
+
object_of :create_time, String
|
624
|
+
object_of :update_time, String
|
625
|
+
array_of :links, Links
|
626
|
+
end
|
627
|
+
|
628
|
+
include RequestDataType
|
629
|
+
|
630
|
+
class << self
|
631
|
+
def find(resource_id)
|
632
|
+
raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
|
633
|
+
path = "v1/payments/authorization/#{resource_id}"
|
634
|
+
self.new(api.get(path))
|
635
|
+
end
|
636
|
+
end
|
637
|
+
|
638
|
+
def capture(capture)
|
639
|
+
capture = Capture.new(capture) unless capture.is_a? Capture
|
640
|
+
path = "v1/payments/authorization/#{self.id}/capture"
|
641
|
+
response = api.post(path, capture.to_hash, http_header)
|
642
|
+
Capture.new(response)
|
643
|
+
end
|
644
|
+
|
645
|
+
def void()
|
646
|
+
path = "v1/payments/authorization/#{self.id}/void"
|
647
|
+
response = api.post(path, {}, http_header)
|
648
|
+
self.merge!(response)
|
649
|
+
success?
|
650
|
+
end
|
651
|
+
|
652
|
+
def reauthorize()
|
653
|
+
path = "v1/payments/authorization/#{self.id}/reauthorize"
|
654
|
+
response = api.post(path, self.to_hash, http_header)
|
655
|
+
self.merge!(response)
|
656
|
+
success?
|
657
|
+
end
|
658
|
+
|
659
|
+
end
|
660
|
+
class Order < Base
|
661
|
+
|
662
|
+
def self.load_members
|
663
|
+
object_of :id, String
|
664
|
+
object_of :purchase_unit_reference_id, String
|
665
|
+
object_of :amount, Amount
|
666
|
+
object_of :payment_mode, String
|
667
|
+
object_of :state, String
|
668
|
+
object_of :pending_reason, String
|
669
|
+
object_of :"protection-eligibility", String
|
670
|
+
object_of :"protection-eligibility_type", String
|
671
|
+
object_of :parent_payment, String
|
672
|
+
object_of :create_time, String
|
673
|
+
object_of :update_time, String
|
674
|
+
array_of :links, Links
|
675
|
+
end
|
676
|
+
|
677
|
+
include RequestDataType
|
678
|
+
|
679
|
+
class << self
|
680
|
+
def find(resource_id)
|
681
|
+
raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
|
682
|
+
path = "v1/payments/orders/#{resource_id}"
|
683
|
+
self.new(api.get(path))
|
684
|
+
end
|
685
|
+
end
|
686
|
+
|
687
|
+
def capture(capture)
|
688
|
+
capture = Capture.new(capture) unless capture.is_a? Capture
|
689
|
+
path = "v1/payments/orders/#{self.id}/capture"
|
690
|
+
response = api.post(path, capture.to_hash, http_header)
|
691
|
+
Capture.new(response)
|
692
|
+
end
|
693
|
+
|
694
|
+
def void()
|
695
|
+
path = "v1/payments/orders/#{self.id}/do-void"
|
696
|
+
response = api.post(path, {}, http_header)
|
697
|
+
self.merge!(response)
|
698
|
+
success?
|
699
|
+
end
|
700
|
+
|
701
|
+
def authorize()
|
702
|
+
path = "v1/payments/orders/#{self.id}/authorize"
|
703
|
+
response = api.post(path, self.to_hash, http_header)
|
704
|
+
Authorization.new(response)
|
705
|
+
end
|
706
|
+
|
707
|
+
end
|
708
|
+
class Capture < Base
|
709
|
+
|
710
|
+
def self.load_members
|
711
|
+
object_of :id, String
|
712
|
+
object_of :amount, Amount
|
713
|
+
object_of :is_final_capture, Boolean
|
714
|
+
object_of :state, String
|
715
|
+
object_of :parent_payment, String
|
716
|
+
object_of :create_time, String
|
717
|
+
object_of :update_time, String
|
718
|
+
array_of :links, Links
|
719
|
+
end
|
720
|
+
|
721
|
+
include RequestDataType
|
722
|
+
|
723
|
+
class << self
|
724
|
+
def find(resource_id)
|
725
|
+
raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
|
726
|
+
path = "v1/payments/capture/#{resource_id}"
|
727
|
+
self.new(api.get(path))
|
728
|
+
end
|
729
|
+
end
|
730
|
+
|
731
|
+
def refund(refund)
|
732
|
+
refund = Refund.new(refund) unless refund.is_a? Refund
|
733
|
+
path = "v1/payments/capture/#{self.id}/refund"
|
734
|
+
response = api.post(path, refund.to_hash, http_header)
|
735
|
+
Refund.new(response)
|
736
|
+
end
|
737
|
+
|
738
|
+
end
|
739
|
+
class Refund < Base
|
740
|
+
|
741
|
+
def self.load_members
|
742
|
+
object_of :id, String
|
743
|
+
object_of :amount, Amount
|
744
|
+
object_of :state, String
|
745
|
+
object_of :reason, String
|
746
|
+
object_of :sale_id, String
|
747
|
+
object_of :capture_id, String
|
748
|
+
object_of :parent_payment, String
|
749
|
+
object_of :description, String
|
750
|
+
object_of :create_time, String
|
751
|
+
object_of :update_time, String
|
752
|
+
array_of :links, Links
|
753
|
+
end
|
754
|
+
|
755
|
+
include RequestDataType
|
756
|
+
|
757
|
+
class << self
|
758
|
+
def find(resource_id)
|
759
|
+
raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
|
760
|
+
path = "v1/payments/refund/#{resource_id}"
|
761
|
+
self.new(api.get(path))
|
762
|
+
end
|
763
|
+
end
|
764
|
+
|
765
|
+
end
|
766
|
+
class Error < Base
|
767
|
+
|
768
|
+
def self.load_members
|
769
|
+
object_of :name, String
|
770
|
+
object_of :debug_id, String
|
771
|
+
object_of :message, String
|
772
|
+
object_of :information_link, String
|
773
|
+
array_of :details, ErrorDetails
|
774
|
+
end
|
775
|
+
|
776
|
+
end
|
777
|
+
class ErrorDetails < Base
|
778
|
+
|
779
|
+
def self.load_members
|
780
|
+
object_of :field, String
|
781
|
+
object_of :issue, String
|
782
|
+
end
|
783
|
+
|
784
|
+
end
|
785
|
+
class PaymentInstruction < Base
|
786
|
+
|
787
|
+
def self.load_members
|
788
|
+
object_of :reference_number, String
|
789
|
+
object_of :instruction_type, String
|
790
|
+
object_of :recipient_banking_instruction, RecipientBankingInstruction
|
791
|
+
object_of :amount, Currency
|
792
|
+
object_of :payment_due_date, String
|
793
|
+
object_of :note, String
|
794
|
+
array_of :links, Links
|
795
|
+
end
|
796
|
+
|
797
|
+
include RequestDataType
|
798
|
+
|
799
|
+
class << self
|
800
|
+
def find(resource_id)
|
801
|
+
raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
|
802
|
+
path = "v1/payments/payments/payment/#{resource_id}/payment-instruction"
|
803
|
+
self.new(api.get(path))
|
804
|
+
end
|
805
|
+
end
|
806
|
+
|
807
|
+
end
|
808
|
+
class RecipientBankingInstruction < Base
|
809
|
+
|
810
|
+
def self.load_members
|
811
|
+
object_of :bank_name, String
|
812
|
+
object_of :account_holder_name, String
|
813
|
+
object_of :account_number, String
|
814
|
+
object_of :routing_number, String
|
815
|
+
object_of :international_bank_account_number, String
|
816
|
+
object_of :bank_identifier_code, String
|
817
|
+
end
|
818
|
+
|
819
|
+
end
|
820
|
+
class RedirectUrls < Base
|
821
|
+
|
822
|
+
def self.load_members
|
823
|
+
object_of :return_url, String
|
824
|
+
object_of :cancel_url, String
|
825
|
+
end
|
826
|
+
|
827
|
+
end
|
828
|
+
class PatchRequest < Base
|
829
|
+
|
830
|
+
def self.load_members
|
831
|
+
object_of :op, String
|
832
|
+
object_of :path, String
|
833
|
+
end
|
834
|
+
|
835
|
+
end
|
836
|
+
class Patch < Base
|
837
|
+
|
838
|
+
def self.load_members
|
839
|
+
object_of :op, String
|
840
|
+
object_of :path, String
|
841
|
+
end
|
842
|
+
|
843
|
+
end
|
844
|
+
class PaymentExecution < Base
|
845
|
+
|
846
|
+
def self.load_members
|
847
|
+
object_of :payer_id, String
|
848
|
+
array_of :transactions, CartBase
|
849
|
+
end
|
850
|
+
|
851
|
+
end
|
852
|
+
class PaymentHistory < Base
|
853
|
+
|
854
|
+
def self.load_members
|
855
|
+
array_of :payments, Payment
|
856
|
+
object_of :count, Integer
|
857
|
+
object_of :next_id, String
|
858
|
+
end
|
859
|
+
|
860
|
+
end
|
861
|
+
class CreditCardList < Base
|
862
|
+
|
863
|
+
def self.load_members
|
864
|
+
array_of :"credit-cards", CreditCard
|
865
|
+
object_of :count, Integer
|
866
|
+
object_of :next_id, String
|
867
|
+
end
|
868
|
+
|
869
|
+
end
|
870
|
+
class BankAccountsList < Base
|
871
|
+
|
872
|
+
def self.load_members
|
873
|
+
array_of :"bank-accounts", BankAccount
|
874
|
+
object_of :count, Integer
|
875
|
+
object_of :next_id, String
|
876
|
+
end
|
877
|
+
|
878
|
+
end
|
879
|
+
class Invoice < Base
|
880
|
+
|
881
|
+
def self.load_members
|
882
|
+
object_of :id, String
|
883
|
+
object_of :number, String
|
884
|
+
object_of :uri, String
|
885
|
+
object_of :status, String
|
886
|
+
object_of :merchant_info, MerchantInfo
|
887
|
+
array_of :billing_info, BillingInfo
|
888
|
+
object_of :shipping_info, ShippingInfo
|
889
|
+
array_of :items, InvoiceItem
|
890
|
+
object_of :invoice_date, String
|
891
|
+
object_of :payment_term, PaymentTerm
|
892
|
+
object_of :discount, Cost
|
893
|
+
object_of :shipping_cost, ShippingCost
|
894
|
+
object_of :custom, CustomAmount
|
895
|
+
object_of :tax_calculated_after_discount, Boolean
|
896
|
+
object_of :tax_inclusive, Boolean
|
897
|
+
object_of :terms, String
|
898
|
+
object_of :note, String
|
899
|
+
object_of :merchant_memo, String
|
900
|
+
object_of :logo_url, String
|
901
|
+
object_of :total_amount, Currency
|
902
|
+
array_of :payment_details, PaymentDetail
|
903
|
+
array_of :refund_details, RefundDetail
|
904
|
+
object_of :metadata, Metadata
|
905
|
+
end
|
906
|
+
|
907
|
+
include RequestDataType
|
908
|
+
|
909
|
+
def create()
|
910
|
+
path = "v1/invoicing/invoices"
|
911
|
+
response = api.post(path, self.to_hash, http_header)
|
912
|
+
self.merge!(response)
|
913
|
+
success?
|
914
|
+
end
|
915
|
+
|
916
|
+
class << self
|
917
|
+
def self.search(options)
|
918
|
+
path = "v1/invoicing/search"
|
919
|
+
response = api.post(path, options)
|
920
|
+
Invoices.new(response)
|
921
|
+
end
|
922
|
+
end
|
923
|
+
|
924
|
+
def send_invoice()
|
925
|
+
path = "v1/invoicing/invoices/#{self.id}/send"
|
926
|
+
response = api.post(path, {}, http_header)
|
927
|
+
self.merge!(response)
|
928
|
+
success?
|
929
|
+
end
|
930
|
+
|
931
|
+
def remind(notification)
|
932
|
+
notification = Notification.new(notification) unless notification.is_a? Notification
|
933
|
+
path = "v1/invoicing/invoices/#{self.id}/remind"
|
934
|
+
response = api.post(path, notification.to_hash, http_header)
|
935
|
+
self.merge!(response)
|
936
|
+
success?
|
937
|
+
end
|
938
|
+
|
939
|
+
def cancel(cancel_notification)
|
940
|
+
cancel_notification = CancelNotification.new(cancel_notification) unless cancel_notification.is_a? CancelNotification
|
941
|
+
path = "v1/invoicing/invoices/#{self.id}/cancel"
|
942
|
+
response = api.post(path, cancel_notification.to_hash, http_header)
|
943
|
+
self.merge!(response)
|
944
|
+
success?
|
945
|
+
end
|
946
|
+
|
947
|
+
def record_payment(payment_detail)
|
948
|
+
payment_detail = PaymentDetail.new(payment_detail) unless payment_detail.is_a? PaymentDetail
|
949
|
+
path = "v1/invoicing/invoices/#{self.id}/record-payment"
|
950
|
+
response = api.post(path, payment_detail.to_hash, http_header)
|
951
|
+
self.merge!(response)
|
952
|
+
success?
|
953
|
+
end
|
954
|
+
|
955
|
+
def record_refund(refund_detail)
|
956
|
+
refund_detail = RefundDetail.new(refund_detail) unless refund_detail.is_a? RefundDetail
|
957
|
+
path = "v1/invoicing/invoices/#{self.id}/record-refund"
|
958
|
+
response = api.post(path, refund_detail.to_hash, http_header)
|
959
|
+
self.merge!(response)
|
960
|
+
success?
|
961
|
+
end
|
962
|
+
|
963
|
+
class << self
|
964
|
+
def find(resource_id)
|
965
|
+
raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
|
966
|
+
path = "v1/invoicing/invoices/#{resource_id}"
|
967
|
+
self.new(api.get(path))
|
968
|
+
end
|
969
|
+
end
|
970
|
+
|
971
|
+
class << self
|
972
|
+
def get_all(options = {})
|
973
|
+
path = "v1/invoicing/invoices/"
|
974
|
+
Invoices.new(api.get(path, options))
|
975
|
+
end
|
976
|
+
end
|
977
|
+
|
978
|
+
def update()
|
979
|
+
path = "v1/invoicing/invoices/#{self.id}"
|
980
|
+
response = api.put(path, self.to_hash, http_header)
|
981
|
+
self.merge!(response)
|
982
|
+
success?
|
983
|
+
end
|
984
|
+
|
985
|
+
def delete()
|
986
|
+
path = "v1/invoicing/invoices/#{self.id}"
|
987
|
+
response = api.delete(path, {})
|
988
|
+
self.merge!(response)
|
989
|
+
success?
|
990
|
+
end
|
991
|
+
|
992
|
+
end
|
993
|
+
class Invoices < Base
|
994
|
+
|
995
|
+
def self.load_members
|
996
|
+
object_of :total_count, Integer
|
997
|
+
array_of :invoices, Invoice
|
998
|
+
end
|
999
|
+
|
1000
|
+
end
|
1001
|
+
class InvoiceItem < Base
|
1002
|
+
|
1003
|
+
def self.load_members
|
1004
|
+
object_of :name, String
|
1005
|
+
object_of :description, String
|
1006
|
+
object_of :quantity, Number
|
1007
|
+
object_of :unit_price, Currency
|
1008
|
+
object_of :tax, Tax
|
1009
|
+
object_of :date, String
|
1010
|
+
object_of :discount, Cost
|
1011
|
+
end
|
1012
|
+
|
1013
|
+
end
|
1014
|
+
class MerchantInfo < Base
|
1015
|
+
|
1016
|
+
def self.load_members
|
1017
|
+
object_of :email, String
|
1018
|
+
object_of :first_name, String
|
1019
|
+
object_of :last_name, String
|
1020
|
+
object_of :address, Address
|
1021
|
+
object_of :business_name, String
|
1022
|
+
object_of :phone, Phone
|
1023
|
+
object_of :fax, Phone
|
1024
|
+
object_of :website, String
|
1025
|
+
object_of :tax_id, String
|
1026
|
+
object_of :additional_info, String
|
1027
|
+
end
|
1028
|
+
|
1029
|
+
end
|
1030
|
+
class BillingInfo < Base
|
1031
|
+
|
1032
|
+
def self.load_members
|
1033
|
+
object_of :email, String
|
1034
|
+
object_of :first_name, String
|
1035
|
+
object_of :last_name, String
|
1036
|
+
object_of :business_name, String
|
1037
|
+
object_of :address, Address
|
1038
|
+
object_of :language, String
|
1039
|
+
object_of :additional_info, String
|
1040
|
+
end
|
1041
|
+
|
1042
|
+
end
|
1043
|
+
class ShippingInfo < Base
|
1044
|
+
|
1045
|
+
def self.load_members
|
1046
|
+
object_of :first_name, String
|
1047
|
+
object_of :last_name, String
|
1048
|
+
object_of :business_name, String
|
1049
|
+
object_of :address, Address
|
1050
|
+
object_of :email, String
|
1051
|
+
end
|
1052
|
+
|
1053
|
+
end
|
1054
|
+
class InvoicingNotification < Base
|
1055
|
+
|
1056
|
+
def self.load_members
|
1057
|
+
object_of :subject, String
|
1058
|
+
object_of :note, String
|
1059
|
+
object_of :send_to_merchant, Boolean
|
1060
|
+
end
|
1061
|
+
|
1062
|
+
end
|
1063
|
+
class InvoicingMetaData < Base
|
1064
|
+
|
1065
|
+
def self.load_members
|
1066
|
+
object_of :created_date, String
|
1067
|
+
object_of :created_by, String
|
1068
|
+
object_of :cancelled_date, String
|
1069
|
+
object_of :cancelled_by, String
|
1070
|
+
object_of :last_updated_date, String
|
1071
|
+
object_of :last_updated_by, String
|
1072
|
+
object_of :first_sent_date, String
|
1073
|
+
object_of :last_sent_date, String
|
1074
|
+
object_of :last_sent_by, String
|
1075
|
+
end
|
1076
|
+
|
1077
|
+
end
|
1078
|
+
class InvoicingPaymentDetail < Base
|
1079
|
+
|
1080
|
+
def self.load_members
|
1081
|
+
object_of :type, String
|
1082
|
+
object_of :transaction_id, String
|
1083
|
+
object_of :transaction_type, String
|
1084
|
+
object_of :date, String
|
1085
|
+
object_of :method, String
|
1086
|
+
object_of :note, String
|
1087
|
+
end
|
1088
|
+
|
1089
|
+
end
|
1090
|
+
class InvoicingRefundDetail < Base
|
1091
|
+
|
1092
|
+
def self.load_members
|
1093
|
+
object_of :type, String
|
1094
|
+
object_of :date, String
|
1095
|
+
object_of :note, String
|
1096
|
+
end
|
1097
|
+
|
1098
|
+
end
|
1099
|
+
class InvoicingSearch < Base
|
1100
|
+
|
1101
|
+
def self.load_members
|
1102
|
+
object_of :email, String
|
1103
|
+
object_of :recipient_first_name, String
|
1104
|
+
object_of :recipient_last_name, String
|
1105
|
+
object_of :recipient_business_name, String
|
1106
|
+
object_of :number, String
|
1107
|
+
object_of :status, String
|
1108
|
+
object_of :lower_total_amount, Currency
|
1109
|
+
object_of :upper_total_amount, Currency
|
1110
|
+
object_of :start_invoice_date, String
|
1111
|
+
object_of :end_invoice_date, String
|
1112
|
+
object_of :start_due_date, String
|
1113
|
+
object_of :end_due_date, String
|
1114
|
+
object_of :start_payment_date, String
|
1115
|
+
object_of :end_payment_date, String
|
1116
|
+
object_of :start_creation_date, String
|
1117
|
+
object_of :end_creation_date, String
|
1118
|
+
object_of :page, Number
|
1119
|
+
object_of :page_size, Number
|
1120
|
+
object_of :total_count_required, Boolean
|
1121
|
+
end
|
1122
|
+
|
1123
|
+
end
|
1124
|
+
class PaymentTerm < Base
|
1125
|
+
|
1126
|
+
def self.load_members
|
1127
|
+
object_of :term_type, String
|
1128
|
+
object_of :due_date, String
|
1129
|
+
end
|
1130
|
+
|
1131
|
+
end
|
1132
|
+
class Cost < Base
|
1133
|
+
|
1134
|
+
def self.load_members
|
1135
|
+
object_of :percent, Number
|
1136
|
+
object_of :amount, Currency
|
1137
|
+
end
|
1138
|
+
|
1139
|
+
end
|
1140
|
+
class ShippingCost < Base
|
1141
|
+
|
1142
|
+
def self.load_members
|
1143
|
+
object_of :amount, Currency
|
1144
|
+
object_of :tax, Tax
|
1145
|
+
end
|
1146
|
+
|
1147
|
+
end
|
1148
|
+
class Tax < Base
|
1149
|
+
|
1150
|
+
def self.load_members
|
1151
|
+
object_of :id, String
|
1152
|
+
object_of :name, String
|
1153
|
+
object_of :percent, Number
|
1154
|
+
object_of :amount, Currency
|
1155
|
+
end
|
1156
|
+
|
1157
|
+
end
|
1158
|
+
class CustomAmount < Base
|
1159
|
+
|
1160
|
+
def self.load_members
|
1161
|
+
object_of :label, String
|
1162
|
+
object_of :amount, Currency
|
1163
|
+
end
|
1164
|
+
|
1165
|
+
end
|
1166
|
+
class PaymentDetail < Base
|
1167
|
+
|
1168
|
+
def self.load_members
|
1169
|
+
object_of :type, String
|
1170
|
+
object_of :transaction_id, String
|
1171
|
+
object_of :transaction_type, String
|
1172
|
+
object_of :date, String
|
1173
|
+
object_of :method, String
|
1174
|
+
object_of :note, String
|
1175
|
+
end
|
1176
|
+
|
1177
|
+
end
|
1178
|
+
class RefundDetail < Base
|
1179
|
+
|
1180
|
+
def self.load_members
|
1181
|
+
object_of :type, String
|
1182
|
+
object_of :date, String
|
1183
|
+
object_of :note, String
|
1184
|
+
end
|
1185
|
+
|
1186
|
+
end
|
1187
|
+
class Metadata < Base
|
1188
|
+
|
1189
|
+
def self.load_members
|
1190
|
+
object_of :created_date, String
|
1191
|
+
object_of :created_by, String
|
1192
|
+
object_of :cancelled_date, String
|
1193
|
+
object_of :cancelled_by, String
|
1194
|
+
object_of :last_updated_date, String
|
1195
|
+
object_of :last_updated_by, String
|
1196
|
+
object_of :first_sent_date, String
|
1197
|
+
object_of :last_sent_date, String
|
1198
|
+
object_of :last_sent_by, String
|
1199
|
+
object_of :payer_view_url, String
|
1200
|
+
end
|
1201
|
+
|
1202
|
+
end
|
1203
|
+
class Notification < Base
|
1204
|
+
|
1205
|
+
def self.load_members
|
1206
|
+
object_of :subject, String
|
1207
|
+
object_of :note, String
|
1208
|
+
object_of :send_to_merchant, Boolean
|
1209
|
+
end
|
1210
|
+
|
1211
|
+
end
|
1212
|
+
class Search < Base
|
1213
|
+
|
1214
|
+
def self.load_members
|
1215
|
+
object_of :email, String
|
1216
|
+
object_of :recipient_first_name, String
|
1217
|
+
object_of :recipient_last_name, String
|
1218
|
+
object_of :recipient_business_name, String
|
1219
|
+
object_of :number, String
|
1220
|
+
object_of :status, String
|
1221
|
+
object_of :lower_total_amount, Currency
|
1222
|
+
object_of :upper_total_amount, Currency
|
1223
|
+
object_of :start_invoice_date, String
|
1224
|
+
object_of :end_invoice_date, String
|
1225
|
+
object_of :start_due_date, String
|
1226
|
+
object_of :end_due_date, String
|
1227
|
+
object_of :start_payment_date, String
|
1228
|
+
object_of :end_payment_date, String
|
1229
|
+
object_of :start_creation_date, String
|
1230
|
+
object_of :end_creation_date, String
|
1231
|
+
object_of :page, Number
|
1232
|
+
object_of :page_size, Number
|
1233
|
+
object_of :total_count_required, Boolean
|
1234
|
+
end
|
1235
|
+
|
1236
|
+
end
|
1237
|
+
class CancelNotification < Base
|
1238
|
+
|
1239
|
+
def self.load_members
|
1240
|
+
object_of :subject, String
|
1241
|
+
object_of :note, String
|
1242
|
+
object_of :send_to_merchant, Boolean
|
1243
|
+
object_of :send_to_payer, Boolean
|
1244
|
+
end
|
1245
|
+
|
1246
|
+
end
|
1247
|
+
class Plan < Base
|
1248
|
+
|
1249
|
+
def self.load_members
|
1250
|
+
object_of :id, String
|
1251
|
+
object_of :name, String
|
1252
|
+
object_of :description, String
|
1253
|
+
object_of :type, String
|
1254
|
+
object_of :state, String
|
1255
|
+
object_of :create_time, String
|
1256
|
+
object_of :update_time, String
|
1257
|
+
array_of :payment_definitions, PaymentDefinition
|
1258
|
+
array_of :terms, Terms
|
1259
|
+
object_of :merchant_preferences, MerchantPreferences
|
1260
|
+
array_of :links, Links
|
1261
|
+
end
|
1262
|
+
|
1263
|
+
include RequestDataType
|
1264
|
+
|
1265
|
+
class << self
|
1266
|
+
def find(resource_id)
|
1267
|
+
raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
|
1268
|
+
path = "v1/payments/billing-plans/#{resource_id}"
|
1269
|
+
self.new(api.get(path))
|
1270
|
+
end
|
1271
|
+
end
|
1272
|
+
|
1273
|
+
def create()
|
1274
|
+
path = "v1/payments/billing-plans/"
|
1275
|
+
response = api.post(path, self.to_hash, http_header)
|
1276
|
+
self.merge!(response)
|
1277
|
+
success?
|
1278
|
+
end
|
1279
|
+
|
1280
|
+
def update(patch_request)
|
1281
|
+
patch_request = PatchRequest.new(patch_request) unless patch_request.is_a? PatchRequest
|
1282
|
+
path = "v1/payments/billing-plans/#{self.id}"
|
1283
|
+
response = api.patch(path, patch_request.to_hash, http_header)
|
1284
|
+
self.merge!(response)
|
1285
|
+
success?
|
1286
|
+
end
|
1287
|
+
|
1288
|
+
class << self
|
1289
|
+
def all(options = {})
|
1290
|
+
path = "v1/payments/billing-plans/"
|
1291
|
+
PlanList.new(api.get(path, options))
|
1292
|
+
end
|
1293
|
+
end
|
1294
|
+
|
1295
|
+
end
|
1296
|
+
class PaymentDefinition < Base
|
1297
|
+
|
1298
|
+
def self.load_members
|
1299
|
+
object_of :id, String
|
1300
|
+
object_of :name, String
|
1301
|
+
object_of :type, String
|
1302
|
+
object_of :frequency_interval, String
|
1303
|
+
object_of :frequency, String
|
1304
|
+
object_of :cycles, String
|
1305
|
+
object_of :amount, Currency
|
1306
|
+
array_of :charge_models, ChargeModels
|
1307
|
+
end
|
1308
|
+
|
1309
|
+
end
|
1310
|
+
class ChargeModels < Base
|
1311
|
+
|
1312
|
+
def self.load_members
|
1313
|
+
object_of :id, String
|
1314
|
+
object_of :type, String
|
1315
|
+
object_of :amount, Currency
|
1316
|
+
end
|
1317
|
+
|
1318
|
+
end
|
1319
|
+
class Terms < Base
|
1320
|
+
|
1321
|
+
def self.load_members
|
1322
|
+
object_of :id, String
|
1323
|
+
object_of :type, String
|
1324
|
+
object_of :max_billing_amount, Currency
|
1325
|
+
object_of :occurrences, String
|
1326
|
+
object_of :amount_range, Currency
|
1327
|
+
object_of :buyer_editable, String
|
1328
|
+
end
|
1329
|
+
|
1330
|
+
end
|
1331
|
+
class MerchantPreferences < Base
|
1332
|
+
|
1333
|
+
def self.load_members
|
1334
|
+
object_of :id, String
|
1335
|
+
object_of :setup_fee, Currency
|
1336
|
+
object_of :cancel_url, String
|
1337
|
+
object_of :return_url, String
|
1338
|
+
object_of :notify_url, String
|
1339
|
+
object_of :max_fail_attempts, String
|
1340
|
+
object_of :auto_bill_amount, String
|
1341
|
+
object_of :initial_fail_amount_action, String
|
1342
|
+
object_of :accepted_payment_type, String
|
1343
|
+
object_of :char_set, String
|
1344
|
+
end
|
1345
|
+
|
1346
|
+
end
|
1347
|
+
class Links < Base
|
1348
|
+
|
1349
|
+
def self.load_members
|
1350
|
+
object_of :href, String
|
1351
|
+
object_of :rel, String
|
1352
|
+
object_of :targetSchema, HyperSchema
|
1353
|
+
object_of :method, String
|
1354
|
+
object_of :enctype, String
|
1355
|
+
object_of :schema, HyperSchema
|
1356
|
+
end
|
1357
|
+
|
1358
|
+
end
|
1359
|
+
class Schema < Base
|
1360
|
+
|
1361
|
+
def self.load_members
|
1362
|
+
object_of :type, Object
|
1363
|
+
object_of :properties, Schema
|
1364
|
+
object_of :patternProperties, Schema
|
1365
|
+
object_of :additionalProperties, Object
|
1366
|
+
object_of :items, Object
|
1367
|
+
object_of :additionalItems, Object
|
1368
|
+
object_of :required, Boolean
|
1369
|
+
object_of :dependencies, Object
|
1370
|
+
object_of :minimum, Number
|
1371
|
+
object_of :maximum, Number
|
1372
|
+
object_of :exclusiveMinimum, Boolean
|
1373
|
+
object_of :exclusiveMaximum, Boolean
|
1374
|
+
object_of :minItems, Integer
|
1375
|
+
object_of :maxItems, Integer
|
1376
|
+
object_of :uniqueItems, Boolean
|
1377
|
+
object_of :pattern, String
|
1378
|
+
object_of :minLength, Integer
|
1379
|
+
object_of :maxLength, Integer
|
1380
|
+
array_of :enum, Array
|
1381
|
+
object_of :title, String
|
1382
|
+
object_of :description, String
|
1383
|
+
object_of :format, String
|
1384
|
+
object_of :divisibleBy, Number
|
1385
|
+
object_of :disallow, Object
|
1386
|
+
object_of :extends, Object
|
1387
|
+
object_of :id, String
|
1388
|
+
object_of :$ref, String
|
1389
|
+
object_of :$schema, String
|
1390
|
+
end
|
1391
|
+
|
1392
|
+
end
|
1393
|
+
class HyperSchema < Schema
|
1394
|
+
|
1395
|
+
def self.load_members
|
1396
|
+
array_of :links, Links
|
1397
|
+
object_of :fragmentResolution, String
|
1398
|
+
object_of :readonly, Boolean
|
1399
|
+
object_of :contentEncoding, String
|
1400
|
+
object_of :pathStart, String
|
1401
|
+
object_of :mediaType, String
|
1402
|
+
end
|
1403
|
+
|
1404
|
+
end
|
1405
|
+
class PlanList < Base
|
1406
|
+
|
1407
|
+
def self.load_members
|
1408
|
+
array_of :plans, Plan
|
1409
|
+
object_of :total_items, String
|
1410
|
+
object_of :total_pages, String
|
1411
|
+
array_of :links, Links
|
1412
|
+
end
|
1413
|
+
|
1414
|
+
end
|
1415
|
+
class Agreement < Base
|
1416
|
+
|
1417
|
+
def self.load_members
|
1418
|
+
object_of :id, String
|
1419
|
+
object_of :name, String
|
1420
|
+
object_of :description, String
|
1421
|
+
object_of :start_date, String
|
1422
|
+
object_of :payer, Payer
|
1423
|
+
object_of :shipping_address, Address
|
1424
|
+
object_of :override_merchant_preferences, MerchantPreferences
|
1425
|
+
array_of :override_charge_models, OverrideChargeModel
|
1426
|
+
object_of :plan, Plan
|
1427
|
+
object_of :create_time, String
|
1428
|
+
object_of :update_time, String
|
1429
|
+
array_of :links, Links
|
1430
|
+
end
|
1431
|
+
|
1432
|
+
include RequestDataType
|
1433
|
+
|
1434
|
+
def create()
|
1435
|
+
path = "v1/payments/billing-agreements/"
|
1436
|
+
response = api.post(path, self.to_hash, http_header)
|
1437
|
+
self.merge!(response)
|
1438
|
+
success?
|
1439
|
+
end
|
1440
|
+
|
1441
|
+
def execute()
|
1442
|
+
path = "v1/payments/billing-agreements/#{self.id}/agreement-execute"
|
1443
|
+
response = api.post(path, {}, http_header)
|
1444
|
+
self.merge!(response)
|
1445
|
+
success?
|
1446
|
+
end
|
1447
|
+
|
1448
|
+
class << self
|
1449
|
+
def find(resource_id)
|
1450
|
+
raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
|
1451
|
+
path = "v1/payments/billing-agreements/#{resource_id}"
|
1452
|
+
self.new(api.get(path))
|
1453
|
+
end
|
1454
|
+
end
|
1455
|
+
|
1456
|
+
def update(patch_request)
|
1457
|
+
patch_request = PatchRequest.new(patch_request) unless patch_request.is_a? PatchRequest
|
1458
|
+
path = "v1/payments/billing-agreements/#{self.id}"
|
1459
|
+
response = api.patch(path, patch_request.to_hash, http_header)
|
1460
|
+
self.merge!(response)
|
1461
|
+
success?
|
1462
|
+
end
|
1463
|
+
|
1464
|
+
def suspend(agreement_state_descriptor)
|
1465
|
+
agreement_state_descriptor = AgreementStateDescriptor.new(agreement_state_descriptor) unless agreement_state_descriptor.is_a? AgreementStateDescriptor
|
1466
|
+
path = "v1/payments/billing-agreements/#{self.id}/suspend"
|
1467
|
+
response = api.post(path, agreement_state_descriptor.to_hash, http_header)
|
1468
|
+
self.merge!(response)
|
1469
|
+
success?
|
1470
|
+
end
|
1471
|
+
|
1472
|
+
def re_activate(agreement_state_descriptor)
|
1473
|
+
agreement_state_descriptor = AgreementStateDescriptor.new(agreement_state_descriptor) unless agreement_state_descriptor.is_a? AgreementStateDescriptor
|
1474
|
+
path = "v1/payments/billing-agreements/#{self.id}/re-activate"
|
1475
|
+
response = api.post(path, agreement_state_descriptor.to_hash, http_header)
|
1476
|
+
self.merge!(response)
|
1477
|
+
success?
|
1478
|
+
end
|
1479
|
+
|
1480
|
+
def cancel(agreement_state_descriptor)
|
1481
|
+
agreement_state_descriptor = AgreementStateDescriptor.new(agreement_state_descriptor) unless agreement_state_descriptor.is_a? AgreementStateDescriptor
|
1482
|
+
path = "v1/payments/billing-agreements/#{self.id}/cancel"
|
1483
|
+
response = api.post(path, agreement_state_descriptor.to_hash, http_header)
|
1484
|
+
self.merge!(response)
|
1485
|
+
success?
|
1486
|
+
end
|
1487
|
+
|
1488
|
+
def bill_balance(agreement_state_descriptor)
|
1489
|
+
agreement_state_descriptor = AgreementStateDescriptor.new(agreement_state_descriptor) unless agreement_state_descriptor.is_a? AgreementStateDescriptor
|
1490
|
+
path = "v1/payments/billing-agreements/#{self.id}/bill-balance"
|
1491
|
+
response = api.post(path, agreement_state_descriptor.to_hash, http_header)
|
1492
|
+
self.merge!(response)
|
1493
|
+
success?
|
1494
|
+
end
|
1495
|
+
|
1496
|
+
def set_balance(currency)
|
1497
|
+
currency = Currency.new(currency) unless currency.is_a? Currency
|
1498
|
+
path = "v1/payments/billing-agreements/#{self.id}/set-balance"
|
1499
|
+
response = api.post(path, currency.to_hash, http_header)
|
1500
|
+
self.merge!(response)
|
1501
|
+
success?
|
1502
|
+
end
|
1503
|
+
|
1504
|
+
class << self
|
1505
|
+
def transactions(options = {})
|
1506
|
+
path = "v1/payments/billing-agreements/{agreement-id}/transactions"
|
1507
|
+
AgreementTransactions.new(api.get(path, options))
|
1508
|
+
end
|
1509
|
+
end
|
1510
|
+
|
1511
|
+
end
|
1512
|
+
class OverrideChargeModel < Base
|
1513
|
+
|
1514
|
+
def self.load_members
|
1515
|
+
object_of :charge_id, String
|
1516
|
+
object_of :amount, Currency
|
1517
|
+
end
|
1518
|
+
|
1519
|
+
end
|
1520
|
+
class AgreementStateDescriptor < Base
|
1521
|
+
|
1522
|
+
def self.load_members
|
1523
|
+
object_of :note, String
|
1524
|
+
object_of :amount, Currency
|
1525
|
+
end
|
1526
|
+
|
1527
|
+
end
|
1528
|
+
class AgreementTransactions < Base
|
1529
|
+
|
1530
|
+
def self.load_members
|
1531
|
+
array_of :agreement_transaction_list, AgreementTransaction
|
1532
|
+
end
|
1533
|
+
|
1534
|
+
end
|
1535
|
+
class AgreementTransaction < Base
|
1536
|
+
|
1537
|
+
def self.load_members
|
1538
|
+
object_of :transaction_id, String
|
1539
|
+
object_of :status, String
|
1540
|
+
object_of :transaction_type, String
|
1541
|
+
object_of :amount, Currency
|
1542
|
+
object_of :fee_amount, Currency
|
1543
|
+
object_of :net_amount, Currency
|
1544
|
+
object_of :payer_email, String
|
1545
|
+
object_of :payer_name, String
|
1546
|
+
object_of :time_updated, String
|
1547
|
+
object_of :time_zone, String
|
1548
|
+
end
|
1549
|
+
|
1550
|
+
end
|
1551
|
+
class WebProfile < Base
|
1552
|
+
|
1553
|
+
def self.load_members
|
1554
|
+
object_of :id, String
|
1555
|
+
object_of :name, String
|
1556
|
+
object_of :flow_config, FlowConfig
|
1557
|
+
object_of :input_fields, InputFields
|
1558
|
+
object_of :presentation, Presentation
|
1559
|
+
end
|
1560
|
+
|
1561
|
+
include RequestDataType
|
1562
|
+
|
1563
|
+
def create()
|
1564
|
+
path = "v1/payment-experience/web-profiles/"
|
1565
|
+
response = api.post(path, self.to_hash, http_header)
|
1566
|
+
CreateProfileResponse.new(response)
|
1567
|
+
end
|
1568
|
+
|
1569
|
+
def update()
|
1570
|
+
path = "v1/payment-experience/web-profiles/#{self.id}"
|
1571
|
+
response = api.put(path, self.to_hash, http_header)
|
1572
|
+
self.merge!(response)
|
1573
|
+
success?
|
1574
|
+
end
|
1575
|
+
|
1576
|
+
def partial_update(patch_request)
|
1577
|
+
patch_request = PatchRequest.new(patch_request) unless patch_request.is_a? PatchRequest
|
1578
|
+
path = "v1/payment-experience/web-profiles/#{self.id}"
|
1579
|
+
response = api.patch(path, patch_request.to_hash, http_header)
|
1580
|
+
self.merge!(response)
|
1581
|
+
success?
|
1582
|
+
end
|
1583
|
+
|
1584
|
+
class << self
|
1585
|
+
def find(resource_id)
|
1586
|
+
raise ArgumentError.new("id required") if resource_id.to_s.strip.empty?
|
1587
|
+
path = "v1/payment-experience/web-profiles/#{resource_id}"
|
1588
|
+
self.new(api.get(path))
|
1589
|
+
end
|
1590
|
+
end
|
1591
|
+
|
1592
|
+
class << self
|
1593
|
+
def get_list(options = {})
|
1594
|
+
path = "v1/payment-experience/web-profiles/"
|
1595
|
+
WebProfileList.new(api.get(path, options))
|
1596
|
+
end
|
1597
|
+
end
|
1598
|
+
|
1599
|
+
def delete()
|
1600
|
+
path = "v1/payment-experience/web-profiles/#{self.id}"
|
1601
|
+
response = api.delete(path, {})
|
1602
|
+
self.merge!(response)
|
1603
|
+
success?
|
1604
|
+
end
|
1605
|
+
|
1606
|
+
end
|
1607
|
+
class FlowConfig < Base
|
1608
|
+
|
1609
|
+
def self.load_members
|
1610
|
+
object_of :landing_page_type, String
|
1611
|
+
object_of :bank_txn_pending_url, String
|
1612
|
+
end
|
1613
|
+
|
1614
|
+
end
|
1615
|
+
class InputFields < Base
|
1616
|
+
|
1617
|
+
def self.load_members
|
1618
|
+
object_of :allow_note, Boolean
|
1619
|
+
object_of :no_shipping, Integer
|
1620
|
+
object_of :address_override, Integer
|
1621
|
+
end
|
1622
|
+
|
1623
|
+
end
|
1624
|
+
class Presentation < Base
|
1625
|
+
|
1626
|
+
def self.load_members
|
1627
|
+
object_of :brand_name, String
|
1628
|
+
object_of :logo_image, String
|
1629
|
+
object_of :locale_code, String
|
1630
|
+
end
|
1631
|
+
|
1632
|
+
end
|
1633
|
+
class CreateProfileResponse < Base
|
1634
|
+
|
1635
|
+
def self.load_members
|
1636
|
+
object_of :id, String
|
1637
|
+
end
|
1638
|
+
|
1639
|
+
end
|
1640
|
+
class WebProfileList < Base
|
1641
|
+
|
1642
|
+
def self.load_members
|
1643
|
+
object_of :id, String
|
1644
|
+
object_of :name, String
|
1645
|
+
object_of :flow_config, FlowConfig
|
1646
|
+
object_of :input_fields, InputFields
|
1647
|
+
object_of :presentation, Presentation
|
1648
|
+
end
|
1649
|
+
|
1650
|
+
end
|
1651
|
+
|
1652
|
+
constants.each do |data_type_klass|
|
1653
|
+
data_type_klass = const_get(data_type_klass)
|
1654
|
+
data_type_klass.load_members if defined? data_type_klass.load_members
|
1655
|
+
end
|
1656
|
+
|
1657
|
+
end
|
1658
|
+
end
|
1659
|
+
end
|