Class: PaypalServerSdk::SubscriptionsController

Inherits:
BaseController show all
Defined in:
lib/paypal_server_sdk/controllers/subscriptions_controller.rb

Overview

SubscriptionsController

Constant Summary

Constants inherited from BaseController

BaseController::GLOBAL_ERRORS

Instance Attribute Summary

Attributes inherited from BaseController

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseController

#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters

Constructor Details

This class inherits a constructor from PaypalServerSdk::BaseController

Instance Method Details

#activate_billing_plan(id) ⇒ ApiResponse

Activates a plan, by ID.

Parameters:

  • id (String)

    Required parameter: The ID of the plan.

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



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
# File 'lib/paypal_server_sdk/controllers/subscriptions_controller.rb', line 210

def activate_billing_plan(id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v1/billing/plans/{id}/activate',
                                 Server::DEFAULT)
               .template_param(new_parameter(id, key: 'id')
                                .should_encode(true))
               .auth(Single.new('Oauth2')))
    .response(new_response_handler
                .is_response_void(true)
                .is_api_response(true)
                .local_error('401',
                             'Authentication failed due to missing authorization header, or'\
                              ' invalid authentication credentials.',
                             SubscriptionErrorException)
                .local_error('403',
                             'Authorization failed due to insufficient permissions.',
                             SubscriptionErrorException)
                .local_error('404',
                             'The specified resource does not exist.',
                             SubscriptionErrorException)
                .local_error('422',
                             'The requested action could not be performed, semantically'\
                              ' incorrect, or failed business validation.',
                             SubscriptionErrorException)
                .local_error('500',
                             'An internal server error has occurred.',
                             SubscriptionErrorException)
                .local_error('default',
                             'The error response.',
                             SubscriptionErrorException))
    .execute
end

#activate_subscription(options = {}) ⇒ ApiResponse

Activates the subscription. description here

Parameters:

  • id (String)

    Required parameter: The ID of the subscription.

  • body (ActivateSubscriptionRequest)

    Optional parameter: TODO: type

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



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
# File 'lib/paypal_server_sdk/controllers/subscriptions_controller.rb', line 705

def activate_subscription(options = {})
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v1/billing/subscriptions/{id}/activate',
                                 Server::DEFAULT)
               .template_param(new_parameter(options['id'], key: 'id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(options['body']))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('Oauth2')))
    .response(new_response_handler
                .is_response_void(true)
                .is_api_response(true)
                .local_error('400',
                             'Bad Request. Request is not well-formed, syntactically'\
                              ' incorrect, or violates schema.',
                             SubscriptionErrorException)
                .local_error('401',
                             'Authentication failed due to missing authorization header, or'\
                              ' invalid authentication credentials.',
                             SubscriptionErrorException)
                .local_error('403',
                             'Authorization failed due to insufficient permissions.',
                             SubscriptionErrorException)
                .local_error('404',
                             'The specified resource does not exist.',
                             SubscriptionErrorException)
                .local_error('422',
                             'The requested action could not be performed, semantically'\
                              ' incorrect, or failed business validation.',
                             SubscriptionErrorException)
                .local_error('500',
                             'An internal server error has occurred.',
                             SubscriptionErrorException)
                .local_error('default',
                             'The error response.',
                             SubscriptionErrorException))
    .execute
end

#cancel_subscription(options = {}) ⇒ ApiResponse

Cancels the subscription. description here

Parameters:

  • id (String)

    Required parameter: The ID of the subscription.

  • body (CancelSubscriptionRequest)

    Optional parameter: TODO: type

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



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
# File 'lib/paypal_server_sdk/controllers/subscriptions_controller.rb', line 659

def cancel_subscription(options = {})
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v1/billing/subscriptions/{id}/cancel',
                                 Server::DEFAULT)
               .template_param(new_parameter(options['id'], key: 'id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(options['body']))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('Oauth2')))
    .response(new_response_handler
                .is_response_void(true)
                .is_api_response(true)
                .local_error('400',
                             'Bad Request. Request is not well-formed, syntactically'\
                              ' incorrect, or violates schema.',
                             SubscriptionErrorException)
                .local_error('401',
                             'Authentication failed due to missing authorization header, or'\
                              ' invalid authentication credentials.',
                             SubscriptionErrorException)
                .local_error('403',
                             'Authorization failed due to insufficient permissions.',
                             SubscriptionErrorException)
                .local_error('404',
                             'The specified resource does not exist.',
                             SubscriptionErrorException)
                .local_error('422',
                             'The requested action could not be performed, semantically'\
                              ' incorrect, or failed business validation.',
                             SubscriptionErrorException)
                .local_error('500',
                             'An internal server error has occurred.',
                             SubscriptionErrorException)
                .local_error('default',
                             'The error response.',
                             SubscriptionErrorException))
    .execute
end

#capture_subscription(options = {}) ⇒ ApiResponse

Captures an authorized payment from the subscriber on the subscription. keys for 72 hours. description here

Parameters:

  • id (String)

    Required parameter: The ID of the subscription.

  • paypal_request_id (String)

    Optional parameter: The server stores

  • body (CaptureSubscriptionRequest)

    Optional parameter: TODO: type

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



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
# File 'lib/paypal_server_sdk/controllers/subscriptions_controller.rb', line 753

def capture_subscription(options = {})
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v1/billing/subscriptions/{id}/capture',
                                 Server::DEFAULT)
               .template_param(new_parameter(options['id'], key: 'id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .header_param(new_parameter(options['paypal_request_id'], key: 'PayPal-Request-Id'))
               .body_param(new_parameter(options['body']))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('Oauth2')))
    .response(new_response_handler
                .is_nullable_response(true)
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(SubscriptionTransactionDetails.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Bad Request. Request is not well-formed, syntactically'\
                              ' incorrect, or violates schema.',
                             SubscriptionErrorException)
                .local_error('401',
                             'Authentication failed due to missing authorization header, or'\
                              ' invalid authentication credentials.',
                             SubscriptionErrorException)
                .local_error('403',
                             'Authorization failed due to insufficient permissions.',
                             SubscriptionErrorException)
                .local_error('404',
                             'The specified resource does not exist.',
                             SubscriptionErrorException)
                .local_error('422',
                             'The requested action could not be performed, semantically'\
                              ' incorrect, or failed business validation.',
                             SubscriptionErrorException)
                .local_error('500',
                             'An internal server error has occurred.',
                             SubscriptionErrorException)
                .local_error('default',
                             'The error response.',
                             SubscriptionErrorException))
    .execute
end

#create_billing_plan(options = {}) ⇒ ApiResponse

Creates a plan that defines pricing and billing cycle details for subscriptions. upon successful completion of the request. Value is: return=minimal. The server returns a minimal response to optimize communication between the API caller and the server. A minimal response includes the id, status and HATEOAS links. return=representation. The server returns a complete resource representation, including the current state of the resource. keys for 72 hours. here

Parameters:

  • prefer (String)

    Optional parameter: The preferred server response

  • paypal_request_id (String)

    Optional parameter: The server stores

  • body (PlanRequest)

    Optional parameter: TODO: type description

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/paypal_server_sdk/controllers/subscriptions_controller.rb', line 22

def create_billing_plan(options = {})
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v1/billing/plans',
                                 Server::DEFAULT)
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .header_param(new_parameter(options['prefer'], key: 'Prefer'))
               .header_param(new_parameter(options['paypal_request_id'], key: 'PayPal-Request-Id'))
               .body_param(new_parameter(options['body']))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('Oauth2')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(BillingPlan.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Bad Request. Request is not well-formed, syntactically'\
                              ' incorrect, or violates schema.',
                             SubscriptionErrorException)
                .local_error('401',
                             'Authentication failed due to missing authorization header, or'\
                              ' invalid authentication credentials.',
                             SubscriptionErrorException)
                .local_error('403',
                             'Authorization failed due to insufficient permissions.',
                             SubscriptionErrorException)
                .local_error('422',
                             'The requested action could not be performed, semantically'\
                              ' incorrect, or failed business validation.',
                             SubscriptionErrorException)
                .local_error('500',
                             'An internal server error has occurred.',
                             SubscriptionErrorException)
                .local_error('default',
                             'The error response.',
                             SubscriptionErrorException))
    .execute
end

#create_subscription(options = {}) ⇒ ApiResponse

Creates a subscription. upon successful completion of the request. Value is: return=minimal. The server returns a minimal response to optimize communication between the API caller and the server. A minimal response includes the id, status and HATEOAS links. return=representation. The server returns a complete resource representation, including the current state of the resource. keys for 72 hours. Client Metadata Id(CMID) is used to provide device-specific information to PayPal’s risk engine. This is crucial for transactions that require device-specific risk assessments. Merchants typically use the Paypal SDK that automatically submits the CMID or they use tools like Fraudnet JS for web or Magnes JS for mobile to generate the CMID on the frontend and then pass it to the API as part of the request headers. description here

Parameters:

  • prefer (String)

    Optional parameter: The preferred server response

  • paypal_request_id (String)

    Optional parameter: The server stores

  • paypal_client_metadata_id (String)

    Optional parameter: The PayPal

  • body (CreateSubscriptionRequest)

    Optional parameter: TODO: type

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



347
348
349
350
351
352
353
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
385
386
# File 'lib/paypal_server_sdk/controllers/subscriptions_controller.rb', line 347

def create_subscription(options = {})
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v1/billing/subscriptions',
                                 Server::DEFAULT)
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .header_param(new_parameter(options['prefer'], key: 'Prefer'))
               .header_param(new_parameter(options['paypal_request_id'], key: 'PayPal-Request-Id'))
               .header_param(new_parameter(options['paypal_client_metadata_id'], key: 'PayPal-Client-Metadata-Id'))
               .body_param(new_parameter(options['body']))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('Oauth2')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(Subscription.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Bad Request. Request is not well-formed, syntactically'\
                              ' incorrect, or violates schema.',
                             SubscriptionErrorException)
                .local_error('401',
                             'Authentication failed due to missing authorization header, or'\
                              ' invalid authentication credentials.',
                             SubscriptionErrorException)
                .local_error('403',
                             'Authorization failed due to insufficient permissions.',
                             SubscriptionErrorException)
                .local_error('422',
                             'The requested action could not be performed, semantically'\
                              ' incorrect, or failed business validation.',
                             SubscriptionErrorException)
                .local_error('500',
                             'An internal server error has occurred.',
                             SubscriptionErrorException)
                .local_error('default',
                             'The error response.',
                             SubscriptionErrorException))
    .execute
end

#deactivate_billing_plan(id) ⇒ ApiResponse

Deactivates a plan, by ID.

Parameters:

  • id (String)

    Required parameter: The ID of the plan.

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



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
275
276
277
278
279
# File 'lib/paypal_server_sdk/controllers/subscriptions_controller.rb', line 247

def deactivate_billing_plan(id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v1/billing/plans/{id}/deactivate',
                                 Server::DEFAULT)
               .template_param(new_parameter(id, key: 'id')
                                .should_encode(true))
               .auth(Single.new('Oauth2')))
    .response(new_response_handler
                .is_response_void(true)
                .is_api_response(true)
                .local_error('401',
                             'Authentication failed due to missing authorization header, or'\
                              ' invalid authentication credentials.',
                             SubscriptionErrorException)
                .local_error('403',
                             'Authorization failed due to insufficient permissions.',
                             SubscriptionErrorException)
                .local_error('404',
                             'The specified resource does not exist.',
                             SubscriptionErrorException)
                .local_error('422',
                             'The requested action could not be performed, semantically'\
                              ' incorrect, or failed business validation.',
                             SubscriptionErrorException)
                .local_error('500',
                             'An internal server error has occurred.',
                             SubscriptionErrorException)
                .local_error('default',
                             'The error response.',
                             SubscriptionErrorException))
    .execute
end

#get_billing_plan(id) ⇒ ApiResponse

Shows details for a plan, by ID.

Parameters:

  • id (String)

    Required parameter: The ID of the plan.

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



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
# File 'lib/paypal_server_sdk/controllers/subscriptions_controller.rb', line 123

def get_billing_plan(id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v1/billing/plans/{id}',
                                 Server::DEFAULT)
               .template_param(new_parameter(id, key: 'id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('Oauth2')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(BillingPlan.method(:from_hash))
                .is_api_response(true)
                .local_error('401',
                             'Authentication failed due to missing authorization header, or'\
                              ' invalid authentication credentials.',
                             SubscriptionErrorException)
                .local_error('403',
                             'Authorization failed due to insufficient permissions.',
                             SubscriptionErrorException)
                .local_error('404',
                             'The specified resource does not exist.',
                             SubscriptionErrorException)
                .local_error('500',
                             'An internal server error has occurred.',
                             SubscriptionErrorException)
                .local_error('default',
                             'The error response.',
                             SubscriptionErrorException))
    .execute
end

#get_subscription(options = {}) ⇒ ApiResponse

Shows details for a subscription, by ID. returned in the response. Possible value for fields are last_failed_payment and plan.

Parameters:

  • id (String)

    Required parameter: The ID of the subscription.

  • fields (String)

    Optional parameter: List of fields that are to be

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



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
# File 'lib/paypal_server_sdk/controllers/subscriptions_controller.rb', line 461

def get_subscription(options = {})
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v1/billing/subscriptions/{id}',
                                 Server::DEFAULT)
               .template_param(new_parameter(options['id'], key: 'id')
                                .should_encode(true))
               .query_param(new_parameter(options['fields'], key: 'fields'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('Oauth2')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(Subscription.method(:from_hash))
                .is_api_response(true)
                .local_error('401',
                             'Authentication failed due to missing authorization header, or'\
                              ' invalid authentication credentials.',
                             SubscriptionErrorException)
                .local_error('403',
                             'Authorization failed due to insufficient permissions.',
                             SubscriptionErrorException)
                .local_error('404',
                             'The specified resource does not exist.',
                             SubscriptionErrorException)
                .local_error('500',
                             'An internal server error has occurred.',
                             SubscriptionErrorException)
                .local_error('default',
                             'The error response.',
                             SubscriptionErrorException))
    .execute
end

#list_billing_plans(options = {}) ⇒ ApiResponse

Lists billing plans. upon successful completion of the request. Value is: return=minimal. The server returns a minimal response to optimize communication between the API caller and the server. A minimal response includes the id, name, description and HATEOAS links. return=representation. The server returns a complete resource representation, including the current state of the resource. Product ID. return in the response. start index of the entire list of items to return in the response. The combination of ‘page=1` and `page_size=20` returns the first 20 items. The combination of `page=2` and `page_size=20` returns the next 20 items. Indicates whether to show the total count in the response.

Parameters:

  • prefer (String)

    Optional parameter: The preferred server response

  • product_id (String)

    Optional parameter: Filters the response by a

  • page_size (Integer)

    Optional parameter: The number of items to

  • page (Integer)

    Optional parameter: A non-zero integer which is the

  • total_required (TrueClass | FalseClass)

    Optional parameter:

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



81
82
83
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
# File 'lib/paypal_server_sdk/controllers/subscriptions_controller.rb', line 81

def list_billing_plans(options = {})
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v1/billing/plans',
                                 Server::DEFAULT)
               .header_param(new_parameter(options['prefer'], key: 'Prefer'))
               .query_param(new_parameter(options['product_id'], key: 'product_id'))
               .query_param(new_parameter(options['page_size'], key: 'page_size'))
               .query_param(new_parameter(options['page'], key: 'page'))
               .query_param(new_parameter(options['total_required'], key: 'total_required'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('Oauth2')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(PlanCollection.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Request is not well-formed, syntactically incorrect, or'\
                              ' violates schema.',
                             SubscriptionErrorException)
                .local_error('401',
                             'Authentication failed due to missing authorization header, or'\
                              ' invalid authentication credentials.',
                             SubscriptionErrorException)
                .local_error('403',
                             'Authorization failed due to insufficient permissions.',
                             SubscriptionErrorException)
                .local_error('404',
                             'The specified resource does not exist.',
                             SubscriptionErrorException)
                .local_error('500',
                             'An internal server error has occurred.',
                             SubscriptionErrorException)
                .local_error('default',
                             'The error response.',
                             SubscriptionErrorException))
    .execute
end

#list_subscription_transactions(options = {}) ⇒ ApiResponse

Lists transactions for a subscription. of transactions to list. transactions to list.

Parameters:

  • id (String)

    Required parameter: The ID of the subscription.

  • start_time (String)

    Required parameter: The start time of the range

  • end_time (String)

    Required parameter: The end time of the range of

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



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
# File 'lib/paypal_server_sdk/controllers/subscriptions_controller.rb', line 805

def list_subscription_transactions(options = {})
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v1/billing/subscriptions/{id}/transactions',
                                 Server::DEFAULT)
               .template_param(new_parameter(options['id'], key: 'id')
                                .should_encode(true))
               .query_param(new_parameter(options['start_time'], key: 'start_time'))
               .query_param(new_parameter(options['end_time'], key: 'end_time'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('Oauth2')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(TransactionsList.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Bad Request. Request is not well-formed, syntactically'\
                              ' incorrect, or violates schema.',
                             SubscriptionErrorException)
                .local_error('401',
                             'Authentication failed due to missing authorization header, or'\
                              ' invalid authentication credentials.',
                             SubscriptionErrorException)
                .local_error('403',
                             'Authorization failed due to insufficient permissions.',
                             SubscriptionErrorException)
                .local_error('404',
                             'The specified resource does not exist.',
                             SubscriptionErrorException)
                .local_error('500',
                             'An internal server error has occurred.',
                             SubscriptionErrorException)
                .local_error('default',
                             'The error response.',
                             SubscriptionErrorException))
    .execute
end

#list_subscriptions(options = {}) ⇒ ApiResponse

List all subscriptions for merchant account. of plan IDs. Filter supports upto 70 plan IDs. URLs should not exceed a length of 2000 characters. of subscription statuses. subscription creation start time for a range of subscriptions. subscription creation end time for a range of subscriptions. response by status update start time for a range of subscriptions. response by status update end time for a range of subscriptions. complex expressions that could use comparison operators like ge, gt, le, lt and logical operators such as ‘and’ and ‘or’. return in the response. start index of the entire list of items to return in the response. The combination of ‘page=1` and `page_size=20` returns the first 20 items. The combination of `page=2` and `page_size=20` returns the next 20 items. response by comma separated vault customer IDs (FSS subscriptions only).

Parameters:

  • plan_ids (String)

    Optional parameter: Filters the response by list

  • statuses (String)

    Optional parameter: Filters the response by list

  • created_after (String)

    Optional parameter: Filters the response by

  • created_before (String)

    Optional parameter: Filters the response by

  • status_updated_before (String)

    Optional parameter: Filters the

  • status_updated_after (String)

    Optional parameter: Filters the

  • filter (String)

    Optional parameter: Filter the response using

  • page_size (Integer)

    Optional parameter: The number of items to

  • page (Integer)

    Optional parameter: A non-zero integer which is the

  • customer_ids (Array[String])

    Optional parameter: Filters the

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
# File 'lib/paypal_server_sdk/controllers/subscriptions_controller.rb', line 414

def list_subscriptions(options = {})
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v1/billing/subscriptions',
                                 Server::DEFAULT)
               .query_param(new_parameter(options['plan_ids'], key: 'plan_ids'))
               .query_param(new_parameter(options['statuses'], key: 'statuses'))
               .query_param(new_parameter(options['created_after'], key: 'created_after'))
               .query_param(new_parameter(options['created_before'], key: 'created_before'))
               .query_param(new_parameter(options['status_updated_before'], key: 'status_updated_before'))
               .query_param(new_parameter(options['status_updated_after'], key: 'status_updated_after'))
               .query_param(new_parameter(options['filter'], key: 'filter'))
               .query_param(new_parameter(options['page_size'], key: 'page_size'))
               .query_param(new_parameter(options['page'], key: 'page'))
               .query_param(new_parameter(options['customer_ids'], key: 'customer_ids'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('Oauth2')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(SubscriptionCollection.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Request is not well-formed, syntactically incorrect, or'\
                              ' violates schema.',
                             SubscriptionErrorException)
                .local_error('401',
                             'Authentication failed due to missing authorization header, or'\
                              ' invalid authentication credentials.',
                             SubscriptionErrorException)
                .local_error('403',
                             'Authorization failed due to insufficient permissions.',
                             SubscriptionErrorException)
                .local_error('500',
                             'An internal server error has occurred.',
                             SubscriptionErrorException)
                .local_error('default',
                             'The error response.',
                             SubscriptionErrorException))
    .execute
end

#patch_billing_plan(options = {}) ⇒ ApiResponse

Updates a plan with the ‘CREATED` or `ACTIVE` status. For an `INACTIVE` plan, you can make only status updates. You can patch these attributes and objects: Attribute or object Operations description replace payment_preferences.auto_bill_outstanding replace taxes.percentage replace payment_preferences.payment_failure_threshold replace payment_preferences.setup_fee replace payment_preferences.setup_fee_failure_action replace name replace here

Parameters:

  • id (String)

    Required parameter: The ID of the plan.

  • body (Array[Patch])

    Optional parameter: TODO: type description

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



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
# File 'lib/paypal_server_sdk/controllers/subscriptions_controller.rb', line 166

def patch_billing_plan(options = {})
  @api_call
    .request(new_request_builder(HttpMethodEnum::PATCH,
                                 '/v1/billing/plans/{id}',
                                 Server::DEFAULT)
               .template_param(new_parameter(options['id'], key: 'id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(options['body']))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('Oauth2')))
    .response(new_response_handler
                .is_response_void(true)
                .is_api_response(true)
                .local_error('400',
                             'Request is not well-formed, syntactically incorrect, or'\
                              ' violates schema.',
                             SubscriptionErrorException)
                .local_error('401',
                             'Authentication failed due to missing authorization header, or'\
                              ' invalid authentication credentials.',
                             SubscriptionErrorException)
                .local_error('403',
                             'Authorization failed due to insufficient permissions.',
                             SubscriptionErrorException)
                .local_error('404',
                             'The specified resource does not exist.',
                             SubscriptionErrorException)
                .local_error('422',
                             'The requested action could not be performed, semantically'\
                              ' incorrect, or failed business validation.',
                             SubscriptionErrorException)
                .local_error('500',
                             'An internal server error has occurred.',
                             SubscriptionErrorException)
                .local_error('default',
                             'The error response.',
                             SubscriptionErrorException))
    .execute
end

#patch_subscription(options = {}) ⇒ ApiResponse

Updates a subscription which could be in ACTIVE or SUSPENDED status. You can override plan level default attributes by providing customised values for plan path in the patch request. You cannot update attributes that have already completed (Example - trial cycles can’t be updated if completed). Once overridden, changes to plan resource will not impact subscription. Any price update will not impact billing cycles within next 10 days (Applicable only for subscriptions funded by PayPal account). Following are the fields eligible for patch. Attribute or object Operations billing_info.outstanding_balance replace custom_id add,replace plan.billing_cycles. pricing_scheme.fixed_price add,replace plan.billing_cycles. pricing_scheme.tiers replace plan.billing_cycles. total_cycles replace plan.payment_preferences. auto_bill_outstanding replace plan.payment_preferences. payment_failure_threshold replace plan.taxes.inclusive add,replace plan.taxes.percentage add,replace shipping_amount add,replace start_time replace subscriber.shipping_address add,replace subscriber.payment_source (for subscriptions funded by card payments) replace here

Parameters:

  • id (String)

    Required parameter: The ID for the subscription.

  • body (Array[Patch])

    Optional parameter: TODO: type description

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



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
553
554
555
# File 'lib/paypal_server_sdk/controllers/subscriptions_controller.rb', line 516

def patch_subscription(options = {})
  @api_call
    .request(new_request_builder(HttpMethodEnum::PATCH,
                                 '/v1/billing/subscriptions/{id}',
                                 Server::DEFAULT)
               .template_param(new_parameter(options['id'], key: 'id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(options['body']))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('Oauth2')))
    .response(new_response_handler
                .is_response_void(true)
                .is_api_response(true)
                .local_error('400',
                             'Request is not well-formed, syntactically incorrect, or'\
                              ' violates schema.',
                             SubscriptionErrorException)
                .local_error('401',
                             'Authentication failed due to missing authorization header, or'\
                              ' invalid authentication credentials.',
                             SubscriptionErrorException)
                .local_error('403',
                             'Authorization failed due to insufficient permissions.',
                             SubscriptionErrorException)
                .local_error('404',
                             'The specified resource does not exist.',
                             SubscriptionErrorException)
                .local_error('422',
                             'The requested action could not be performed, semantically'\
                              ' incorrect, or failed business validation.',
                             SubscriptionErrorException)
                .local_error('500',
                             'An internal server error has occurred.',
                             SubscriptionErrorException)
                .local_error('default',
                             'The error response.',
                             SubscriptionErrorException))
    .execute
end

#revise_subscription(options = {}) ⇒ ApiResponse

Updates the quantity of the product or service in a subscription. You can also use this method to switch the plan and update the ‘shipping_amount`, `shipping_address` values for the subscription. This type of update requires the buyer’s consent. description here

Parameters:

  • id (String)

    Required parameter: The ID of the subscription.

  • body (ModifySubscriptionRequest)

    Optional parameter: TODO: type

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



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
# File 'lib/paypal_server_sdk/controllers/subscriptions_controller.rb', line 565

def revise_subscription(options = {})
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v1/billing/subscriptions/{id}/revise',
                                 Server::DEFAULT)
               .template_param(new_parameter(options['id'], key: 'id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(options['body']))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('Oauth2')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ModifySubscriptionResponse.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Bad Request. Request is not well-formed, syntactically'\
                              ' incorrect, or violates schema.',
                             SubscriptionErrorException)
                .local_error('401',
                             'Authentication failed due to missing authorization header, or'\
                              ' invalid authentication credentials.',
                             SubscriptionErrorException)
                .local_error('403',
                             'Authorization failed due to insufficient permissions.',
                             SubscriptionErrorException)
                .local_error('404',
                             'The specified resource does not exist.',
                             SubscriptionErrorException)
                .local_error('422',
                             'The requested action could not be performed, semantically'\
                              ' incorrect, or failed business validation.',
                             SubscriptionErrorException)
                .local_error('500',
                             'An internal server error has occurred.',
                             SubscriptionErrorException)
                .local_error('default',
                             'The error response.',
                             SubscriptionErrorException))
    .execute
end

#suspend_subscription(options = {}) ⇒ ApiResponse

Suspends the subscription. description here

Parameters:

  • id (String)

    Required parameter: The ID of the subscription.

  • body (SuspendSubscription)

    Optional parameter: TODO: type

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



613
614
615
616
617
618
619
620
621
622
623
624
625
626
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
# File 'lib/paypal_server_sdk/controllers/subscriptions_controller.rb', line 613

def suspend_subscription(options = {})
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v1/billing/subscriptions/{id}/suspend',
                                 Server::DEFAULT)
               .template_param(new_parameter(options['id'], key: 'id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(options['body']))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('Oauth2')))
    .response(new_response_handler
                .is_response_void(true)
                .is_api_response(true)
                .local_error('400',
                             'Bad Request. Request is not well-formed, syntactically'\
                              ' incorrect, or violates schema.',
                             SubscriptionErrorException)
                .local_error('401',
                             'Authentication failed due to missing authorization header, or'\
                              ' invalid authentication credentials.',
                             SubscriptionErrorException)
                .local_error('403',
                             'Authorization failed due to insufficient permissions.',
                             SubscriptionErrorException)
                .local_error('404',
                             'The specified resource does not exist.',
                             SubscriptionErrorException)
                .local_error('422',
                             'The requested action could not be performed, semantically'\
                              ' incorrect, or failed business validation.',
                             SubscriptionErrorException)
                .local_error('500',
                             'An internal server error has occurred.',
                             SubscriptionErrorException)
                .local_error('default',
                             'The error response.',
                             SubscriptionErrorException))
    .execute
end

#update_billing_plan_pricing_schemes(options = {}) ⇒ ApiResponse

Updates pricing for a plan. For example, you can update a regular billing cycle from $5 per month to $7 per month. description here

Parameters:

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



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
# File 'lib/paypal_server_sdk/controllers/subscriptions_controller.rb', line 287

def update_billing_plan_pricing_schemes(options = {})
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v1/billing/plans/{id}/update-pricing-schemes',
                                 Server::DEFAULT)
               .template_param(new_parameter(options['id'], key: 'id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(options['body']))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('Oauth2')))
    .response(new_response_handler
                .is_response_void(true)
                .is_api_response(true)
                .local_error('400',
                             'Bad Request. Request is not well-formed, syntactically'\
                              ' incorrect, or violates schema.',
                             SubscriptionErrorException)
                .local_error('401',
                             'Authentication failed due to missing authorization header, or'\
                              ' invalid authentication credentials.',
                             SubscriptionErrorException)
                .local_error('403',
                             'Authorization failed due to insufficient permissions.',
                             SubscriptionErrorException)
                .local_error('404',
                             'The specified resource does not exist.',
                             SubscriptionErrorException)
                .local_error('422',
                             'The requested action could not be performed, semantically'\
                              ' incorrect, or failed business validation.',
                             SubscriptionErrorException)
                .local_error('500',
                             'An internal server error has occurred.',
                             SubscriptionErrorException)
                .local_error('default',
                             'The error response.',
                             SubscriptionErrorException))
    .execute
end