Class: UnivapayClientSdk::SubscriptionsApi

Inherits:
BaseApi
  • Object
show all
Defined in:
lib/univapay_client_sdk/apis/subscriptions_api.rb,
lib/univapay_client_sdk/extensions.rb

Overview

SubscriptionsApi

Constant Summary

Constants inherited from BaseApi

BaseApi::GLOBAL_ERRORS

Instance Attribute Summary

Attributes inherited from BaseApi

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseApi

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

Constructor Details

This class inherits a constructor from UnivapayClientSdk::BaseApi

Instance Method Details

#cancel_subscription(store_id, id) ⇒ ApiResponse

Cancels an existing subscription. The subscription status will be permanently changed to canceled and it cannot be resumed. Please proceed with caution. of the store. resource.

Parameters:

  • store_id (UUID | String)

    Required parameter: The unique identifier

  • id (UUID | String)

    Required parameter: The unique identifier of the

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



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
# File 'lib/univapay_client_sdk/apis/subscriptions_api.rb', line 473

def cancel_subscription(store_id,
                        id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::DELETE,
                                 '/stores/{storeId}/subscriptions/{id}',
                                 Server::DEFAULT)
               .template_param(new_parameter(store_id, key: 'storeId')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(id, key: 'id')
                                .is_required(true)
                                .should_encode(true))
               .auth(Single.new('JWT_TOKEN')))
    .response(new_response_handler
                .is_response_void(true)
                .is_api_response(true)
                .local_error_template('400',
                                      'HTTP 400 Bad Request: {$response.body#/code}',
                                      ApiErrorException)
                .local_error_template('401',
                                      'HTTP 401 Unauthorized: {$response.body#/code}',
                                      ApiErrorException)
                .local_error_template('403',
                                      'HTTP 403 Forbidden: {$response.body#/code}',
                                      ApiErrorException)
                .local_error_template('404',
                                      'HTTP 404 Not Found: {$response.body#/code}',
                                      ApiErrorException)
                .local_error_template('429',
                                      'HTTP 429 Rate Limited: {$response.body#/code}',
                                      APIException)
                .local_error_template('409',
                                      'HTTP 409 Conflict: {$response.body#/code}',
                                      APIException)
                .local_error_template('500',
                                      'HTTP 500 Server Error: {$response.body#/code}',
                                      APIException)
                .local_error_template('503',
                                      'HTTP 503 Unavailable: {$response.body#/code}',
                                      APIException)
                .local_error_template('504',
                                      'HTTP 504 Timeout: {$response.body#/code}',
                                      APIException)
                .local_error_template('default',
                                      'HTTP {$statusCode}: {$response.body#/code}',
                                      APIException))
    .execute
end

#create_subscription(idempotency_key: nil, body: nil) ⇒ ApiResponse

Creates a new subscription. idempotency key to prevent double charges and duplicate operations. We recommend a randomly generated UUID (v4). Subscription request

Parameters:

  • idempotency_key (String) (defaults to: nil)

    Optional parameter: An optional

  • body (SubscriptionCreateRequest) (defaults to: nil)

    Optional parameter: Create

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



16
17
18
19
20
21
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
61
62
63
# File 'lib/univapay_client_sdk/apis/subscriptions_api.rb', line 16

def create_subscription(idempotency_key: nil,
                        body: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/subscriptions',
                                 Server::DEFAULT)
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .header_param(new_parameter(idempotency_key, key: 'Idempotency-Key'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('JWT_TOKEN')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(Subscription.method(:from_hash))
                .is_api_response(true)
                .local_error_template('400',
                                      'HTTP 400 Bad Request: {$response.body#/code}',
                                      APIException)
                .local_error_template('401',
                                      'HTTP 401 Unauthorized: {$response.body#/code}',
                                      APIException)
                .local_error_template('403',
                                      'HTTP 403 Forbidden: {$response.body#/code}',
                                      APIException)
                .local_error_template('404',
                                      'HTTP 404 Not Found: {$response.body#/code}',
                                      APIException)
                .local_error_template('409',
                                      'HTTP 409 Conflict: {$response.body#/code}',
                                      APIException)
                .local_error_template('429',
                                      'HTTP 429 Rate Limited: {$response.body#/code}',
                                      APIException)
                .local_error_template('500',
                                      'HTTP 500 Server Error: {$response.body#/code}',
                                      APIException)
                .local_error_template('503',
                                      'HTTP 503 Unavailable: {$response.body#/code}',
                                      APIException)
                .local_error_template('504',
                                      'HTTP 504 Timeout: {$response.body#/code}',
                                      APIException)
                .local_error_template('default',
                                      'HTTP {$statusCode}: {$response.body#/code}',
                                      APIException))
    .execute
end

#get_subscription(store_id, id, polling: nil) ⇒ ApiResponse

Retrieves the details of an existing subscription. Supports internal polling to wait for status changes. of the store. true, instructs the API to internally poll the subscription status until it changes from 'unverified' (the initial status) to another status.

Parameters:

  • store_id (UUID | String)

    Required parameter: The unique identifier

  • id (UUID | String)

    Required parameter: The Subscription ID.

  • polling (TrueClass | FalseClass) (defaults to: nil)

    Optional parameter: If set to

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



343
344
345
346
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
387
388
389
390
391
392
393
394
# File 'lib/univapay_client_sdk/apis/subscriptions_api.rb', line 343

def get_subscription(store_id,
                     id,
                     polling: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/stores/{storeId}/subscriptions/{id}',
                                 Server::DEFAULT)
               .template_param(new_parameter(store_id, key: 'storeId')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(id, key: 'id')
                                .is_required(true)
                                .should_encode(true))
               .query_param(new_parameter(polling, key: 'polling'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('JWT_TOKEN')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(Subscription.method(:from_hash))
                .is_api_response(true)
                .local_error_template('401',
                                      'HTTP 401 Unauthorized: {$response.body#/code}',
                                      ApiErrorException)
                .local_error_template('404',
                                      'HTTP 404 Not Found: {$response.body#/code}',
                                      ApiErrorException)
                .local_error_template('400',
                                      'HTTP 400 Bad Request: {$response.body#/code}',
                                      APIException)
                .local_error_template('403',
                                      'HTTP 403 Forbidden: {$response.body#/code}',
                                      APIException)
                .local_error_template('409',
                                      'HTTP 409 Conflict: {$response.body#/code}',
                                      APIException)
                .local_error_template('429',
                                      'HTTP 429 Rate Limited: {$response.body#/code}',
                                      APIException)
                .local_error_template('500',
                                      'HTTP 500 Server Error: {$response.body#/code}',
                                      APIException)
                .local_error_template('503',
                                      'HTTP 503 Unavailable: {$response.body#/code}',
                                      APIException)
                .local_error_template('504',
                                      'HTTP 504 Timeout: {$response.body#/code}',
                                      APIException)
                .local_error_template('default',
                                      'HTTP {$statusCode}: {$response.body#/code}',
                                      APIException))
    .execute
end

#get_subscription_latest_charge(store_id, subscription_id) ⇒ ApiResponse

Retrieves the most recent charge created for a specific subscription. Returns 404 if no charges have been attempted yet. of the store. identifier of the subscription.

Parameters:

  • store_id (UUID | String)

    Required parameter: The unique identifier

  • subscription_id (UUID | String)

    Required parameter: The unique

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



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
# File 'lib/univapay_client_sdk/apis/subscriptions_api.rb', line 740

def get_subscription_latest_charge(store_id,
                                   subscription_id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/stores/{storeId}/subscriptions/{subscriptionId}/charges/latest',
                                 Server::DEFAULT)
               .template_param(new_parameter(store_id, key: 'storeId')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(subscription_id, key: 'subscriptionId')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('JWT_TOKEN')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(Charge.method(:from_hash))
                .is_api_response(true)
                .local_error_template('401',
                                      'HTTP 401 Unauthorized: {$response.body#/code}',
                                      ApiErrorException)
                .local_error_template('404',
                                      'HTTP 404 Not Found: {$response.body#/code}',
                                      ApiErrorException)
                .local_error_template('400',
                                      'HTTP 400 Bad Request: {$response.body#/code}',
                                      APIException)
                .local_error_template('403',
                                      'HTTP 403 Forbidden: {$response.body#/code}',
                                      APIException)
                .local_error_template('409',
                                      'HTTP 409 Conflict: {$response.body#/code}',
                                      APIException)
                .local_error_template('429',
                                      'HTTP 429 Rate Limited: {$response.body#/code}',
                                      APIException)
                .local_error_template('500',
                                      'HTTP 500 Server Error: {$response.body#/code}',
                                      APIException)
                .local_error_template('503',
                                      'HTTP 503 Unavailable: {$response.body#/code}',
                                      APIException)
                .local_error_template('504',
                                      'HTTP 504 Timeout: {$response.body#/code}',
                                      APIException)
                .local_error_template('default',
                                      'HTTP {$statusCode}: {$response.body#/code}',
                                      APIException))
    .execute
end

#get_subscription_payment(store_id, subscription_id, payment_id) ⇒ ApiResponse

Retrieves the details of an individual payment associated with a specific subscription. of the store. identifier of the subscription. identifier of the scheduled payment of a subscription

Parameters:

  • store_id (UUID | String)

    Required parameter: The unique identifier

  • subscription_id (UUID | String)

    Required parameter: The unique

  • payment_id (UUID | String)

    Required parameter: The unique

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



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
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
# File 'lib/univapay_client_sdk/apis/subscriptions_api.rb', line 601

def get_subscription_payment(store_id,
                             subscription_id,
                             payment_id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/stores/{storeId}/subscriptions/{subscriptionId}/payments/{paymentId}',
                                 Server::DEFAULT)
               .template_param(new_parameter(store_id, key: 'storeId')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(subscription_id, key: 'subscriptionId')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(payment_id, key: 'paymentId')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('JWT_TOKEN')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(SubscriptionPayment.method(:from_hash))
                .is_api_response(true)
                .local_error_template('401',
                                      'HTTP 401 Unauthorized: {$response.body#/code}',
                                      ApiErrorException)
                .local_error_template('404',
                                      'HTTP 404 Not Found: {$response.body#/code}',
                                      ApiErrorException)
                .local_error_template('400',
                                      'HTTP 400 Bad Request: {$response.body#/code}',
                                      APIException)
                .local_error_template('403',
                                      'HTTP 403 Forbidden: {$response.body#/code}',
                                      APIException)
                .local_error_template('409',
                                      'HTTP 409 Conflict: {$response.body#/code}',
                                      APIException)
                .local_error_template('429',
                                      'HTTP 429 Rate Limited: {$response.body#/code}',
                                      APIException)
                .local_error_template('500',
                                      'HTTP 500 Server Error: {$response.body#/code}',
                                      APIException)
                .local_error_template('503',
                                      'HTTP 503 Unavailable: {$response.body#/code}',
                                      APIException)
                .local_error_template('504',
                                      'HTTP 504 Timeout: {$response.body#/code}',
                                      APIException)
                .local_error_template('default',
                                      'HTTP {$statusCode}: {$response.body#/code}',
                                      APIException))
    .execute
end

#list_all_subscriptions(search: nil, status: nil, mode: nil, limit: 10, cursor: nil, cursor_direction: CursorDirectionQuery::DESC) ⇒ ApiResponse

Lists all subscriptions across all stores. subscriptions by current status. processing mode. return in one page. resource after which pagination should continue. Pagination direction relative to the supplied cursor.

Parameters:

  • search (String) (defaults to: nil)

    Optional parameter: Search by metadata values.

  • status (SubscriptionStatus) (defaults to: nil)

    Optional parameter: Filter

  • mode (ChargeMode) (defaults to: nil)

    Optional parameter: Filter subscriptions by

  • limit (Integer) (defaults to: 10)

    Optional parameter: Maximum number of resources to

  • cursor (UUID | String) (defaults to: nil)

    Optional parameter: Cursor pointing to the

  • cursor_direction (CursorDirectionQuery) (defaults to: CursorDirectionQuery::DESC)

    Optional parameter:

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



78
79
80
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
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/univapay_client_sdk/apis/subscriptions_api.rb', line 78

def list_all_subscriptions(search: nil,
                           status: nil,
                           mode: nil,
                           limit: 10,
                           cursor: nil,
                           cursor_direction: CursorDirectionQuery::DESC)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/subscriptions',
                                 Server::DEFAULT)
               .query_param(new_parameter(search, key: 'search'))
               .query_param(new_parameter(status, key: 'status'))
               .query_param(new_parameter(mode, key: 'mode'))
               .query_param(new_parameter(limit, key: 'limit'))
               .query_param(new_parameter(cursor, key: 'cursor'))
               .query_param(new_parameter(cursor_direction, key: 'cursor_direction'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('JWT_TOKEN')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(SubscriptionList.method(:from_hash))
                .is_api_response(true)
                .local_error_template('400',
                                      'HTTP 400 Bad Request: {$response.body#/code}',
                                      APIException)
                .local_error_template('401',
                                      'HTTP 401 Unauthorized: {$response.body#/code}',
                                      APIException)
                .local_error_template('403',
                                      'HTTP 403 Forbidden: {$response.body#/code}',
                                      APIException)
                .local_error_template('404',
                                      'HTTP 404 Not Found: {$response.body#/code}',
                                      APIException)
                .local_error_template('409',
                                      'HTTP 409 Conflict: {$response.body#/code}',
                                      APIException)
                .local_error_template('429',
                                      'HTTP 429 Rate Limited: {$response.body#/code}',
                                      APIException)
                .local_error_template('500',
                                      'HTTP 500 Server Error: {$response.body#/code}',
                                      APIException)
                .local_error_template('503',
                                      'HTTP 503 Unavailable: {$response.body#/code}',
                                      APIException)
                .local_error_template('504',
                                      'HTTP 504 Timeout: {$response.body#/code}',
                                      APIException)
                .local_error_template('default',
                                      'HTTP {$statusCode}: {$response.body#/code}',
                                      APIException))
    .execute
end

#list_charges_for_subscription_payment(store_id, subscription_id, payment_id, limit: 10, cursor: nil, cursor_direction: CursorDirectionQuery::DESC) ⇒ ApiResponse

Retrieves a paginated list of all charge attempts made for a specific scheduled payment of a subscription. Useful for inspecting retry history. of the store. identifier of the subscription. identifier of the scheduled payment of a subscription return in one page. resource after which pagination should continue. Pagination direction relative to the supplied cursor.

Parameters:

  • store_id (UUID | String)

    Required parameter: The unique identifier

  • subscription_id (UUID | String)

    Required parameter: The unique

  • payment_id (UUID | String)

    Required parameter: The unique

  • limit (Integer) (defaults to: 10)

    Optional parameter: Maximum number of resources to

  • cursor (UUID | String) (defaults to: nil)

    Optional parameter: Cursor pointing to the

  • cursor_direction (CursorDirectionQuery) (defaults to: CursorDirectionQuery::DESC)

    Optional parameter:

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



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
942
# File 'lib/univapay_client_sdk/apis/subscriptions_api.rb', line 883

def list_charges_for_subscription_payment(store_id,
                                          subscription_id,
                                          payment_id,
                                          limit: 10,
                                          cursor: nil,
                                          cursor_direction: CursorDirectionQuery::DESC)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/stores/{storeId}/subscriptions/{subscriptionId}/payments/{paymentId}/charges',
                                 Server::DEFAULT)
               .template_param(new_parameter(store_id, key: 'storeId')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(subscription_id, key: 'subscriptionId')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(payment_id, key: 'paymentId')
                                .is_required(true)
                                .should_encode(true))
               .query_param(new_parameter(limit, key: 'limit'))
               .query_param(new_parameter(cursor, key: 'cursor'))
               .query_param(new_parameter(cursor_direction, key: 'cursor_direction'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('JWT_TOKEN')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ChargeList.method(:from_hash))
                .is_api_response(true)
                .local_error_template('401',
                                      'HTTP 401 Unauthorized: {$response.body#/code}',
                                      ApiErrorException)
                .local_error_template('403',
                                      'HTTP 403 Forbidden: {$response.body#/code}',
                                      ApiErrorException)
                .local_error_template('404',
                                      'HTTP 404 Not Found: {$response.body#/code}',
                                      ApiErrorException)
                .local_error_template('400',
                                      'HTTP 400 Bad Request: {$response.body#/code}',
                                      APIException)
                .local_error_template('409',
                                      'HTTP 409 Conflict: {$response.body#/code}',
                                      APIException)
                .local_error_template('429',
                                      'HTTP 429 Rate Limited: {$response.body#/code}',
                                      APIException)
                .local_error_template('500',
                                      'HTTP 500 Server Error: {$response.body#/code}',
                                      APIException)
                .local_error_template('503',
                                      'HTTP 503 Unavailable: {$response.body#/code}',
                                      APIException)
                .local_error_template('504',
                                      'HTTP 504 Timeout: {$response.body#/code}',
                                      APIException)
                .local_error_template('default',
                                      'HTTP {$statusCode}: {$response.body#/code}',
                                      APIException))
    .execute
end

#list_store_subscriptions(store_id, search: nil, status: nil, mode: nil, limit: 10, cursor: nil, cursor_direction: CursorDirectionQuery::DESC) ⇒ ApiResponse

Lists all subscriptions for a specific store. of the store. subscriptions by current status. processing mode. return in one page. resource after which pagination should continue. Pagination direction relative to the supplied cursor.

Parameters:

  • store_id (UUID | String)

    Required parameter: The unique identifier

  • search (String) (defaults to: nil)

    Optional parameter: Search by metadata values.

  • status (SubscriptionStatus) (defaults to: nil)

    Optional parameter: Filter

  • mode (ChargeMode) (defaults to: nil)

    Optional parameter: Filter subscriptions by

  • limit (Integer) (defaults to: 10)

    Optional parameter: Maximum number of resources to

  • cursor (UUID | String) (defaults to: nil)

    Optional parameter: Cursor pointing to the

  • cursor_direction (CursorDirectionQuery) (defaults to: CursorDirectionQuery::DESC)

    Optional parameter:

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



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
# File 'lib/univapay_client_sdk/apis/subscriptions_api.rb', line 208

def list_store_subscriptions(store_id,
                             search: nil,
                             status: nil,
                             mode: nil,
                             limit: 10,
                             cursor: nil,
                             cursor_direction: CursorDirectionQuery::DESC)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/stores/{storeId}/subscriptions',
                                 Server::DEFAULT)
               .template_param(new_parameter(store_id, key: 'storeId')
                                .is_required(true)
                                .should_encode(true))
               .query_param(new_parameter(search, key: 'search'))
               .query_param(new_parameter(status, key: 'status'))
               .query_param(new_parameter(mode, key: 'mode'))
               .query_param(new_parameter(limit, key: 'limit'))
               .query_param(new_parameter(cursor, key: 'cursor'))
               .query_param(new_parameter(cursor_direction, key: 'cursor_direction'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('JWT_TOKEN')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(SubscriptionList.method(:from_hash))
                .is_api_response(true)
                .local_error_template('400',
                                      'HTTP 400 Bad Request: {$response.body#/code}',
                                      APIException)
                .local_error_template('401',
                                      'HTTP 401 Unauthorized: {$response.body#/code}',
                                      APIException)
                .local_error_template('403',
                                      'HTTP 403 Forbidden: {$response.body#/code}',
                                      APIException)
                .local_error_template('404',
                                      'HTTP 404 Not Found: {$response.body#/code}',
                                      APIException)
                .local_error_template('409',
                                      'HTTP 409 Conflict: {$response.body#/code}',
                                      APIException)
                .local_error_template('429',
                                      'HTTP 429 Rate Limited: {$response.body#/code}',
                                      APIException)
                .local_error_template('500',
                                      'HTTP 500 Server Error: {$response.body#/code}',
                                      APIException)
                .local_error_template('503',
                                      'HTTP 503 Unavailable: {$response.body#/code}',
                                      APIException)
                .local_error_template('504',
                                      'HTTP 504 Timeout: {$response.body#/code}',
                                      APIException)
                .local_error_template('default',
                                      'HTTP {$statusCode}: {$response.body#/code}',
                                      APIException))
    .execute
end

#list_subscription_charges(merchant_id, store_id, subscription_id, limit: 10, cursor: nil, cursor_direction: CursorDirectionQuery::DESC) ⇒ ApiResponse

Retrieves a paginated list of charges linked to a subscription. Backend search uses the same charge search surface as normal charge listing and adds a subscription filter for the requested subscription. identifier of the merchant. of the store. identifier of the subscription. return in one page. resource after which pagination should continue. Pagination direction relative to the supplied cursor.

Parameters:

  • merchant_id (UUID | String)

    Required parameter: The unique

  • store_id (UUID | String)

    Required parameter: The unique identifier

  • subscription_id (UUID | String)

    Required parameter: The unique

  • limit (Integer) (defaults to: 10)

    Optional parameter: Maximum number of resources to

  • cursor (UUID | String) (defaults to: nil)

    Optional parameter: Cursor pointing to the

  • cursor_direction (CursorDirectionQuery) (defaults to: CursorDirectionQuery::DESC)

    Optional parameter:

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



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
# File 'lib/univapay_client_sdk/apis/subscriptions_api.rb', line 807

def list_subscription_charges(merchant_id,
                              store_id,
                              subscription_id,
                              limit: 10,
                              cursor: nil,
                              cursor_direction: CursorDirectionQuery::DESC)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/merchants/{merchantId}/stores/{storeId}/subscriptions/{subscriptionId}/charges',
                                 Server::DEFAULT)
               .template_param(new_parameter(merchant_id, key: 'merchantId')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(store_id, key: 'storeId')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(subscription_id, key: 'subscriptionId')
                                .is_required(true)
                                .should_encode(true))
               .query_param(new_parameter(limit, key: 'limit'))
               .query_param(new_parameter(cursor, key: 'cursor'))
               .query_param(new_parameter(cursor_direction, key: 'cursor_direction'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('JWT_TOKEN')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ChargeList.method(:from_hash))
                .is_api_response(true)
                .local_error_template('400',
                                      'HTTP 400 Bad Request: {$response.body#/code}',
                                      ApiErrorException)
                .local_error_template('401',
                                      'HTTP 401 Unauthorized: {$response.body#/code}',
                                      ApiErrorException)
                .local_error_template('403',
                                      'HTTP 403 Forbidden: {$response.body#/code}',
                                      ApiErrorException)
                .local_error_template('404',
                                      'HTTP 404 Not Found: {$response.body#/code}',
                                      ApiErrorException)
                .local_error_template('409',
                                      'HTTP 409 Conflict: {$response.body#/code}',
                                      APIException)
                .local_error_template('429',
                                      'HTTP 429 Rate Limited: {$response.body#/code}',
                                      APIException)
                .local_error_template('500',
                                      'HTTP 500 Server Error: {$response.body#/code}',
                                      APIException)
                .local_error_template('503',
                                      'HTTP 503 Unavailable: {$response.body#/code}',
                                      APIException)
                .local_error_template('504',
                                      'HTTP 504 Timeout: {$response.body#/code}',
                                      APIException)
                .local_error_template('default',
                                      'HTTP {$statusCode}: {$response.body#/code}',
                                      APIException))
    .execute
end

#list_subscription_payments(store_id, subscription_id, limit: 10, cursor: nil, cursor_direction: CursorDirectionQuery::DESC) ⇒ ApiResponse

Retrieves a list of all historical and scheduled payments for a specific subscription. of the store. identifier of the subscription. return in one page. resource after which pagination should continue. Pagination direction relative to the supplied cursor.

Parameters:

  • store_id (UUID | String)

    Required parameter: The unique identifier

  • subscription_id (UUID | String)

    Required parameter: The unique

  • limit (Integer) (defaults to: 10)

    Optional parameter: Maximum number of resources to

  • cursor (UUID | String) (defaults to: nil)

    Optional parameter: Cursor pointing to the

  • cursor_direction (CursorDirectionQuery) (defaults to: CursorDirectionQuery::DESC)

    Optional parameter:

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
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
# File 'lib/univapay_client_sdk/apis/subscriptions_api.rb', line 535

def list_subscription_payments(store_id,
                               subscription_id,
                               limit: 10,
                               cursor: nil,
                               cursor_direction: CursorDirectionQuery::DESC)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/stores/{storeId}/subscriptions/{subscriptionId}/payments',
                                 Server::DEFAULT)
               .template_param(new_parameter(store_id, key: 'storeId')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(subscription_id, key: 'subscriptionId')
                                .is_required(true)
                                .should_encode(true))
               .query_param(new_parameter(limit, key: 'limit'))
               .query_param(new_parameter(cursor, key: 'cursor'))
               .query_param(new_parameter(cursor_direction, key: 'cursor_direction'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('JWT_TOKEN')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(SubscriptionPaymentList.method(:from_hash))
                .is_api_response(true)
                .local_error_template('400',
                                      'HTTP 400 Bad Request: {$response.body#/code}',
                                      ApiErrorException)
                .local_error_template('401',
                                      'HTTP 401 Unauthorized: {$response.body#/code}',
                                      ApiErrorException)
                .local_error_template('403',
                                      'HTTP 403 Forbidden: {$response.body#/code}',
                                      ApiErrorException)
                .local_error_template('404',
                                      'HTTP 404 Not Found: {$response.body#/code}',
                                      ApiErrorException)
                .local_error_template('429',
                                      'HTTP 429 Rate Limited: {$response.body#/code}',
                                      APIException)
                .local_error_template('409',
                                      'HTTP 409 Conflict: {$response.body#/code}',
                                      APIException)
                .local_error_template('500',
                                      'HTTP 500 Server Error: {$response.body#/code}',
                                      APIException)
                .local_error_template('503',
                                      'HTTP 503 Unavailable: {$response.body#/code}',
                                      APIException)
                .local_error_template('504',
                                      'HTTP 504 Timeout: {$response.body#/code}',
                                      APIException)
                .local_error_template('default',
                                      'HTTP {$statusCode}: {$response.body#/code}',
                                      APIException))
    .execute
end

#poll_subscription(store_id, id, max_attempts: 10) ⇒ Object



165
166
167
168
169
170
171
172
173
174
175
# File 'lib/univapay_client_sdk/extensions.rb', line 165

def poll_subscription(store_id, id, max_attempts: 10)
  attempts = 0
  while attempts < max_attempts
    response = get_subscription(store_id, id, polling: true)
    if response && response.data && response.data.status != SubscriptionStatus::UNVERIFIED
      return response
    end
    attempts += 1
  end
  get_subscription(store_id, id, polling: true)
end

#simulate_store_subscription_plan(store_id, idempotency_key: nil, body: nil) ⇒ ApiResponse

Simulates the payment schedule that a subscription would follow for a specific store, without creating a live subscription or a transaction token. Returns a bare array of the scheduled payments that would result from the given amount, currency, period (or cyclical period), and plan settings. of the store. idempotency key to prevent double charges and duplicate operations. We recommend a randomly generated UUID (v4). Subscription Plan Simulation request

Parameters:

  • store_id (UUID | String)

    Required parameter: The unique identifier

  • idempotency_key (String) (defaults to: nil)

    Optional parameter: An optional

  • body (SubscriptionSimulationRequest) (defaults to: nil)

    Optional parameter:

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



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
# File 'lib/univapay_client_sdk/apis/subscriptions_api.rb', line 280

def simulate_store_subscription_plan(store_id,
                                     idempotency_key: nil,
                                     body: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/stores/{storeId}/subscriptions/simulate_plan',
                                 Server::DEFAULT)
               .template_param(new_parameter(store_id, key: 'storeId')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .header_param(new_parameter(idempotency_key, key: 'Idempotency-Key'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('JWT_TOKEN')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(SubscriptionSimulationPayment.method(:from_hash))
                .is_api_response(true)
                .is_response_array(true)
                .local_error_template('400',
                                      'HTTP 400 Bad Request: {$response.body#/code}',
                                      ApiErrorException)
                .local_error_template('401',
                                      'HTTP 401 Unauthorized: {$response.body#/code}',
                                      ApiErrorException)
                .local_error_template('403',
                                      'HTTP 403 Forbidden: {$response.body#/code}',
                                      ApiErrorException)
                .local_error_template('429',
                                      'HTTP 429 Rate Limited: {$response.body#/code}',
                                      APIException)
                .local_error_template('404',
                                      'HTTP 404 Not Found: {$response.body#/code}',
                                      APIException)
                .local_error_template('409',
                                      'HTTP 409 Conflict: {$response.body#/code}',
                                      APIException)
                .local_error_template('500',
                                      'HTTP 500 Server Error: {$response.body#/code}',
                                      APIException)
                .local_error_template('503',
                                      'HTTP 503 Unavailable: {$response.body#/code}',
                                      APIException)
                .local_error_template('504',
                                      'HTTP 504 Timeout: {$response.body#/code}',
                                      APIException)
                .local_error_template('default',
                                      'HTTP {$statusCode}: {$response.body#/code}',
                                      APIException))
    .execute
end

#simulate_subscription_plan(idempotency_key: nil, body: nil) ⇒ ApiResponse

Simulates the payment schedule that a subscription would follow, without creating a live subscription or a transaction token. Returns a bare array of the scheduled payments that would result from the given amount, currency, period (or cyclical period), and plan settings. idempotency key to prevent double charges and duplicate operations. We recommend a randomly generated UUID (v4). Subscription Plan Simulation request

Parameters:

  • idempotency_key (String) (defaults to: nil)

    Optional parameter: An optional

  • body (SubscriptionSimulationRequest) (defaults to: nil)

    Optional parameter:

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



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
# File 'lib/univapay_client_sdk/apis/subscriptions_api.rb', line 143

def simulate_subscription_plan(idempotency_key: nil,
                               body: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/subscriptions/simulate_plan',
                                 Server::DEFAULT)
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .header_param(new_parameter(idempotency_key, key: 'Idempotency-Key'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('JWT_TOKEN')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(SubscriptionSimulationPayment.method(:from_hash))
                .is_api_response(true)
                .is_response_array(true)
                .local_error_template('400',
                                      'HTTP 400 Bad Request: {$response.body#/code}',
                                      ApiErrorException)
                .local_error_template('401',
                                      'HTTP 401 Unauthorized: {$response.body#/code}',
                                      ApiErrorException)
                .local_error_template('403',
                                      'HTTP 403 Forbidden: {$response.body#/code}',
                                      ApiErrorException)
                .local_error_template('429',
                                      'HTTP 429 Rate Limited: {$response.body#/code}',
                                      APIException)
                .local_error_template('404',
                                      'HTTP 404 Not Found: {$response.body#/code}',
                                      APIException)
                .local_error_template('409',
                                      'HTTP 409 Conflict: {$response.body#/code}',
                                      APIException)
                .local_error_template('500',
                                      'HTTP 500 Server Error: {$response.body#/code}',
                                      APIException)
                .local_error_template('503',
                                      'HTTP 503 Unavailable: {$response.body#/code}',
                                      APIException)
                .local_error_template('504',
                                      'HTTP 504 Timeout: {$response.body#/code}',
                                      APIException)
                .local_error_template('default',
                                      'HTTP {$statusCode}: {$response.body#/code}',
                                      APIException))
    .execute
end

#suspend_subscription(store_id, subscription_id, idempotency_key: nil, body: nil) ⇒ ApiResponse

Suspends a subscription that is currently current or unpaid. The termination_mode controls when the suspension takes effect: immediate (default) suspends right away, on_next_payment waits until the next scheduled payment date before suspending. of the store. identifier of the subscription. idempotency key to prevent double charges and duplicate operations. We recommend a randomly generated UUID (v4). payload for suspending a subscription.

Parameters:

  • store_id (UUID | String)

    Required parameter: The unique identifier

  • subscription_id (UUID | String)

    Required parameter: The unique

  • idempotency_key (String) (defaults to: nil)

    Optional parameter: An optional

  • body (SubscriptionSuspendRequest) (defaults to: nil)

    Optional parameter: Request

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



958
959
960
961
962
963
964
965
966
967
968
969
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
# File 'lib/univapay_client_sdk/apis/subscriptions_api.rb', line 958

def suspend_subscription(store_id,
                         subscription_id,
                         idempotency_key: nil,
                         body: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::PATCH,
                                 '/stores/{storeId}/subscriptions/{subscriptionId}/suspend',
                                 Server::DEFAULT)
               .template_param(new_parameter(store_id, key: 'storeId')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(subscription_id, key: 'subscriptionId')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .header_param(new_parameter(idempotency_key, key: 'Idempotency-Key'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('JWT_TOKEN')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(Subscription.method(:from_hash))
                .is_api_response(true)
                .local_error_template('400',
                                      'HTTP 400 Bad Request: {$response.body#/code}',
                                      ApiErrorException)
                .local_error_template('401',
                                      'HTTP 401 Unauthorized: {$response.body#/code}',
                                      ApiErrorException)
                .local_error_template('403',
                                      'HTTP 403 Forbidden: {$response.body#/code}',
                                      ApiErrorException)
                .local_error_template('404',
                                      'HTTP 404 Not Found: {$response.body#/code}',
                                      ApiErrorException)
                .local_error_template('429',
                                      'HTTP 429 Rate Limited: {$response.body#/code}',
                                      APIException)
                .local_error_template('409',
                                      'HTTP 409 Conflict: {$response.body#/code}',
                                      APIException)
                .local_error_template('500',
                                      'HTTP 500 Server Error: {$response.body#/code}',
                                      APIException)
                .local_error_template('503',
                                      'HTTP 503 Unavailable: {$response.body#/code}',
                                      APIException)
                .local_error_template('504',
                                      'HTTP 504 Timeout: {$response.body#/code}',
                                      APIException)
                .local_error_template('default',
                                      'HTTP {$statusCode}: {$response.body#/code}',
                                      APIException))
    .execute
end

#unsuspend_subscription(store_id, subscription_id, idempotency_key: nil) ⇒ ApiResponse

Resumes a subscription that is currently suspended, setting its status back to unpaid and rescheduling the next payment. No request body is required. of the store. identifier of the subscription. idempotency key to prevent double charges and duplicate operations. We recommend a randomly generated UUID (v4).

Parameters:

  • store_id (UUID | String)

    Required parameter: The unique identifier

  • subscription_id (UUID | String)

    Required parameter: The unique

  • idempotency_key (String) (defaults to: nil)

    Optional parameter: An optional

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



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
# File 'lib/univapay_client_sdk/apis/subscriptions_api.rb', line 1026

def unsuspend_subscription(store_id,
                           subscription_id,
                           idempotency_key: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::PATCH,
                                 '/stores/{storeId}/subscriptions/{subscriptionId}/unsuspend',
                                 Server::DEFAULT)
               .template_param(new_parameter(store_id, key: 'storeId')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(subscription_id, key: 'subscriptionId')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter(idempotency_key, key: 'Idempotency-Key'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('JWT_TOKEN')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(Subscription.method(:from_hash))
                .is_api_response(true)
                .local_error_template('400',
                                      'HTTP 400 Bad Request: {$response.body#/code}',
                                      ApiErrorException)
                .local_error_template('401',
                                      'HTTP 401 Unauthorized: {$response.body#/code}',
                                      ApiErrorException)
                .local_error_template('403',
                                      'HTTP 403 Forbidden: {$response.body#/code}',
                                      ApiErrorException)
                .local_error_template('404',
                                      'HTTP 404 Not Found: {$response.body#/code}',
                                      ApiErrorException)
                .local_error_template('429',
                                      'HTTP 429 Rate Limited: {$response.body#/code}',
                                      APIException)
                .local_error_template('409',
                                      'HTTP 409 Conflict: {$response.body#/code}',
                                      APIException)
                .local_error_template('500',
                                      'HTTP 500 Server Error: {$response.body#/code}',
                                      APIException)
                .local_error_template('503',
                                      'HTTP 503 Unavailable: {$response.body#/code}',
                                      APIException)
                .local_error_template('504',
                                      'HTTP 504 Timeout: {$response.body#/code}',
                                      APIException)
                .local_error_template('default',
                                      'HTTP {$statusCode}: {$response.body#/code}',
                                      APIException))
    .execute
end

#update_subscription(store_id, id, idempotency_key: nil, body: nil) ⇒ ApiResponse

Updates the configuration, payment method, or schedule of a specific subscription. of the store. resource. idempotency key to prevent double charges and duplicate operations. We recommend a randomly generated UUID (v4). update on the subscription.

Parameters:

  • store_id (UUID | String)

    Required parameter: The unique identifier

  • id (UUID | String)

    Required parameter: The unique identifier of the

  • idempotency_key (String) (defaults to: nil)

    Optional parameter: An optional

  • body (SubscriptionUpdateRequest) (defaults to: nil)

    Optional parameter: Properties to

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



408
409
410
411
412
413
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
454
455
456
457
458
459
460
461
462
463
# File 'lib/univapay_client_sdk/apis/subscriptions_api.rb', line 408

def update_subscription(store_id,
                        id,
                        idempotency_key: nil,
                        body: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::PATCH,
                                 '/stores/{storeId}/subscriptions/{id}',
                                 Server::DEFAULT)
               .template_param(new_parameter(store_id, key: 'storeId')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(id, key: 'id')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .header_param(new_parameter(idempotency_key, key: 'Idempotency-Key'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('JWT_TOKEN')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(Subscription.method(:from_hash))
                .is_api_response(true)
                .local_error_template('400',
                                      'HTTP 400 Bad Request: {$response.body#/code}',
                                      ApiErrorException)
                .local_error_template('401',
                                      'HTTP 401 Unauthorized: {$response.body#/code}',
                                      ApiErrorException)
                .local_error_template('404',
                                      'HTTP 404 Not Found: {$response.body#/code}',
                                      ApiErrorException)
                .local_error_template('403',
                                      'HTTP 403 Forbidden: {$response.body#/code}',
                                      APIException)
                .local_error_template('409',
                                      'HTTP 409 Conflict: {$response.body#/code}',
                                      APIException)
                .local_error_template('429',
                                      'HTTP 429 Rate Limited: {$response.body#/code}',
                                      APIException)
                .local_error_template('500',
                                      'HTTP 500 Server Error: {$response.body#/code}',
                                      APIException)
                .local_error_template('503',
                                      'HTTP 503 Unavailable: {$response.body#/code}',
                                      APIException)
                .local_error_template('504',
                                      'HTTP 504 Timeout: {$response.body#/code}',
                                      APIException)
                .local_error_template('default',
                                      'HTTP {$statusCode}: {$response.body#/code}',
                                      APIException))
    .execute
end

#update_subscription_payment(store_id, subscription_id, payment_id, body, idempotency_key: nil) ⇒ ApiResponse

Updates properties of a specific scheduled payment for a subscription. Can be used to change the due date when permitted, mark the payment as paid, schedule a termination status, or set a retry interval. of the store. identifier of the subscription. identifier of the scheduled payment of a subscription payload for updating a scheduled subscription payment. idempotency key to prevent double charges and duplicate operations. We recommend a randomly generated UUID (v4).

Parameters:

  • store_id (UUID | String)

    Required parameter: The unique identifier

  • subscription_id (UUID | String)

    Required parameter: The unique

  • payment_id (UUID | String)

    Required parameter: The unique

  • body (SubscriptionPatchPaymentRequest)

    Required parameter: Request

  • idempotency_key (String) (defaults to: nil)

    Optional parameter: An optional

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



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
# File 'lib/univapay_client_sdk/apis/subscriptions_api.rb', line 671

def update_subscription_payment(store_id,
                                subscription_id,
                                payment_id,
                                body,
                                idempotency_key: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::PATCH,
                                 '/stores/{storeId}/subscriptions/{subscriptionId}/payments/{paymentId}',
                                 Server::DEFAULT)
               .template_param(new_parameter(store_id, key: 'storeId')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(subscription_id, key: 'subscriptionId')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(payment_id, key: 'paymentId')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body)
                            .is_required(true))
               .header_param(new_parameter(idempotency_key, key: 'Idempotency-Key'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('JWT_TOKEN')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(SubscriptionPayment.method(:from_hash))
                .is_api_response(true)
                .local_error_template('400',
                                      'HTTP 400 Bad Request: {$response.body#/code}',
                                      ApiErrorException)
                .local_error_template('401',
                                      'HTTP 401 Unauthorized: {$response.body#/code}',
                                      ApiErrorException)
                .local_error_template('403',
                                      'HTTP 403 Forbidden: {$response.body#/code}',
                                      ApiErrorException)
                .local_error_template('404',
                                      'HTTP 404 Not Found: {$response.body#/code}',
                                      ApiErrorException)
                .local_error_template('409',
                                      'HTTP 409 Conflict: {$response.body#/code}',
                                      APIException)
                .local_error_template('429',
                                      'HTTP 429 Rate Limited: {$response.body#/code}',
                                      APIException)
                .local_error_template('500',
                                      'HTTP 500 Server Error: {$response.body#/code}',
                                      APIException)
                .local_error_template('503',
                                      'HTTP 503 Unavailable: {$response.body#/code}',
                                      APIException)
                .local_error_template('504',
                                      'HTTP 504 Timeout: {$response.body#/code}',
                                      APIException)
                .local_error_template('default',
                                      'HTTP {$statusCode}: {$response.body#/code}',
                                      APIException))
    .execute
end

#update_subscription_token(store_id, subscription_id, body, idempotency_key: nil) ⇒ ApiResponse

Replaces the payment method (transaction token) used for a subscription. Useful when a card expires or a customer wants to switch payment methods. The new token must belong to the same store, be active, and match the subscription's processing mode (live/test). One-time tokens are not accepted; use a recurring or subscription token. of the store. identifier of the subscription. payload for replacing a subscription payment token. idempotency key to prevent double charges and duplicate operations. We recommend a randomly generated UUID (v4).

Parameters:

  • store_id (UUID | String)

    Required parameter: The unique identifier

  • subscription_id (UUID | String)

    Required parameter: The unique

  • body (SubscriptionPatchTokenRequest)

    Required parameter: Request

  • idempotency_key (String) (defaults to: nil)

    Optional parameter: An optional

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



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
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
# File 'lib/univapay_client_sdk/apis/subscriptions_api.rb', line 1094

def update_subscription_token(store_id,
                              subscription_id,
                              body,
                              idempotency_key: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::PATCH,
                                 '/stores/{storeId}/subscriptions/{subscriptionId}/token',
                                 Server::DEFAULT)
               .template_param(new_parameter(store_id, key: 'storeId')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(subscription_id, key: 'subscriptionId')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body)
                            .is_required(true))
               .header_param(new_parameter(idempotency_key, key: 'Idempotency-Key'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('JWT_TOKEN')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(Subscription.method(:from_hash))
                .is_api_response(true)
                .local_error_template('400',
                                      'HTTP 400 Bad Request: {$response.body#/code}',
                                      ApiErrorException)
                .local_error_template('401',
                                      'HTTP 401 Unauthorized: {$response.body#/code}',
                                      ApiErrorException)
                .local_error_template('403',
                                      'HTTP 403 Forbidden: {$response.body#/code}',
                                      ApiErrorException)
                .local_error_template('404',
                                      'HTTP 404 Not Found: {$response.body#/code}',
                                      ApiErrorException)
                .local_error_template('429',
                                      'HTTP 429 Rate Limited: {$response.body#/code}',
                                      APIException)
                .local_error_template('409',
                                      'HTTP 409 Conflict: {$response.body#/code}',
                                      APIException)
                .local_error_template('500',
                                      'HTTP 500 Server Error: {$response.body#/code}',
                                      APIException)
                .local_error_template('503',
                                      'HTTP 503 Unavailable: {$response.body#/code}',
                                      APIException)
                .local_error_template('504',
                                      'HTTP 504 Timeout: {$response.body#/code}',
                                      APIException)
                .local_error_template('default',
                                      'HTTP {$statusCode}: {$response.body#/code}',
                                      APIException))
    .execute
end