{"_id":"59a45d2bd12e81000f842ef7","category":{"_id":"59a45d2bd12e81000f842eea","version":"59a45d2bd12e81000f842ee2","project":"57336fd5a6a9c40e00e13a0b","__v":0,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-07-27T10:22:06.636Z","from_sync":false,"order":7,"slug":"subscriptions","title":"Subscriptions"},"parentDoc":null,"user":"560d5913af97231900938124","project":"57336fd5a6a9c40e00e13a0b","version":{"_id":"59a45d2bd12e81000f842ee2","project":"57336fd5a6a9c40e00e13a0b","__v":1,"createdAt":"2017-08-28T18:12:59.168Z","releaseDate":"2017-08-28T18:12:59.168Z","categories":["59a45d2bd12e81000f842ee3","59a45d2bd12e81000f842ee4","59a45d2bd12e81000f842ee5","59a45d2bd12e81000f842ee6","59a45d2bd12e81000f842ee7","59a45d2bd12e81000f842ee8","59a45d2bd12e81000f842ee9","59a45d2bd12e81000f842eea","59a45d2bd12e81000f842eeb","59a45d2bd12e81000f842eec","59a45d2bd12e81000f842eed","59a45d2bd12e81000f842eee","59a45d2bd12e81000f842eef","59a45d2bd12e81000f842ef0","59a45d2bd12e81000f842ef1"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":false,"codename":"3.22.1","version_clean":"8976.0.0-JSON","version":"8976-JSON"},"__v":0,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-07-29T17:16:53.270Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[{"language":"text","code":""}]},"settings":"57ee593a21ceb20e0061959e","examples":{"codes":[]},"method":"put","auth":"optional","params":[{"_id":"579b92475623be2200832642","ref":"","in":"path","required":true,"desc":"BlueSnap identifier for the subscription.","default":"","type":"int","name":"subscriptionId"}],"url":"/recurring/subscriptions/:subscriptionId"},"isReference":false,"order":22,"body":"The Update Subscription request enables you to change any of the following settings for an existing subscription:\n  * Plan associated to the subscription\n  * Payment source\n  * Override value for the recurring charge amount\n  * Auto-renew setting (if you set it to false, the subscription will expire at the end of the current period)\n  * Next charge date\n  * Subscription status (ACTIVE/CANCELED)\n\nFor more information about working with subscriptions, see the [Subscriptions tutorial](doc:subscription-management#section-tutorial-subscriptions).\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Changing payment source\",\n  \"body\": \"If you wish to change the credit card associated with the subscription:  \\n\\n1. Make sure card details are saved to the vaulted shopper (If not, [update vaulted shopper](doc:update-vaulted-shopper) with new card details). \\n2.  Update the subscription to specify the new payment source.\"\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"Switch contract separately from other changes\",\n  \"body\": \"If you are switching the contract associated with the subscription, we recommend you do this in a separate API call from other changes, such as updating the payment source or overriding the recurring charge amount. For example if you want to switch a subscription from plan 1 to plan 2 and also override the recurring charge amount for plan 2, we recommend that you first make an Update Subscription call to change the plan. Then make a separate call to override the recurring charge amount.\"\n}\n[/block]\n<a class=\"btn btn-success\" href=\"#section-api-explorer\" role=\"button\">Try it in the API Explorer</a>\n\n###Request Content\n\nSend a **[subscription](doc:recurring-subscription)** object, with the following:\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`planId` &nbsp;&nbsp;&nbsp; *integer* &nbsp;&nbsp;&nbsp;optional\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`paymentSource` &nbsp;&nbsp;&nbsp; *object* &nbsp;&nbsp;&nbsp;optional (see [paymentSource](doc:payment-source))\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`overrideRecurringChargeAmount` &nbsp;&nbsp;&nbsp; *decimal* &nbsp;&nbsp;optional\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`autoRenew` &nbsp;&nbsp;&nbsp; *boolean* &nbsp;&nbsp;&nbsp;optional\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`nextChargeDate` &nbsp;&nbsp;&nbsp; *string* &nbsp;&nbsp;&nbsp;optional\n\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`status` &nbsp;&nbsp;&nbsp; *string* &nbsp;&nbsp;&nbsp;optional\n\n###Response Details\nIf successful, the response HTTP status code is 200 OK.\nThe response contains the **[subscription](doc:recurring-subscription)** object.\n\n<hr>\n\n##Examples\n\n###Request Examples\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"curl -v -X PUT https://sandbox.bluesnap.com/services/2/recurring/subscriptions/8491543 \\\\\\n-H 'Content-Type: application/json' \\\\\\n-H 'Accept: application/json' \\\\ \\n-H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \\\\\\n-d '\\n{\\\"planId\\\": 2283849}'\",\n      \"language\": \"curl\",\n      \"name\": \"Update Subscription Request: change plan\"\n    },\n    {\n      \"code\": \"curl -v -X PUT https://sandbox.bluesnap.com/services/2/recurring/subscriptions/8491543 \\\\\\n-H 'Content-Type: application/json' \\\\\\n-H 'Accept: application/json' \\\\ \\n-H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \\\\\\n-d '\\n{\\\"status\\\": \\\"CANCELED\\\"}'\",\n      \"language\": \"curl\",\n      \"name\": \"cancel subscription\"\n    },\n    {\n      \"code\": \"curl -v -X PUT https://sandbox.bluesnap.com/services/2/recurring/subscriptions/8491543 \\\\\\n-H 'Content-Type: application/json' \\\\\\n-H 'Accept: application/json' \\\\ \\n-H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \\\\\\n-d '\\n{\\\"nextChargeDate\\\": \\\"2017-10-01\\\"}'\",\n      \"language\": \"curl\",\n      \"name\": \"change next charge date\"\n    },\n    {\n      \"code\": \"curl -v -X PUT https://sandbox.bluesnap.com/services/2/recurring/subscriptions/8491543 \\\\\\n-H 'Content-Type: application/json' \\\\\\n-H 'Accept: application/json' \\\\ \\n-H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \\\\\\n-d '\\n{  \\n  \\\"paymentSource\\\":{  \\n    \\\"creditCardInfo\\\":{  \\n      \\\"creditCard\\\":{  \\n        \\\"cardLastFourDigits\\\":\\\"9299\\\",\\n        \\\"cardType\\\":\\\"VISA\\\"\\n         }\\n      }\\n   }\\n}'\",\n      \"language\": \"curl\",\n      \"name\": \"Change payment source\"\n    }\n  ],\n  \"sidebar\": true\n}\n[/block]\n###Response Example\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n    \\\"nextChargeDate\\\": \\\"2016-08-16\\\",\\n    \\\"quantity\\\": 1,\\n    \\\"charge\\\": {\\n        \\\"amount\\\": 100,\\n        \\\"vaultedShopperId\\\": 21188909,\\n        \\\"chargeInfo\\\": {\\n            \\\"fromDate\\\": \\\"2016-08-02\\\",\\n            \\\"toDate\\\": \\\"2016-08-16\\\",\\n            \\\"chargeType\\\": \\\"INITIAL\\\"\\n        },\\n        \\\"chargeId\\\": 12117877,\\n        \\\"paymentSource\\\": {\\\"creditCardInfo\\\": {\\\"creditCard\\\": {\\n            \\\"expirationYear\\\": 2019,\\n            \\\"cardLastFourDigits\\\": 1111,\\n            \\\"cardSubType\\\": \\\"CREDIT\\\",\\n            \\\"cardType\\\": \\\"VISA\\\",\\n            \\\"expirationMonth\\\": \\\"07\\\"\\n        }}},\\n        \\\"softDescriptor\\\": \\\"BLS&#x2a;default_descriptor\\\",\\n        \\\"planId\\\": 2283845,\\n        \\\"currency\\\": \\\"USD\\\",\\n        \\\"transactionDate\\\": \\\"2016-08-02\\\",\\n        \\\"subscriptionId\\\": 8492717,\\n        \\\"transactionId\\\": 1012463333\\n    },\\n    \\\"trialPeriodDays\\\": 14,\\n    \\\"paymentSource\\\": {\\\"creditCardInfo\\\": {\\n        \\\"billingContactInfo\\\": {\\n            \\\"firstName\\\": \\\"John\\\",\\n            \\\"lastName\\\": \\\"Doe\\\"\\n        },\\n        \\\"creditCard\\\": {\\n            \\\"expirationYear\\\": 2019,\\n            \\\"cardLastFourDigits\\\": 1111,\\n            \\\"cardSubType\\\": \\\"CREDIT\\\",\\n          \\t\\\"cardCategory\\\": \\\"CLASSIC\\\",\\n            \\\"cardType\\\": \\\"VISA\\\",\\n            \\\"expirationMonth\\\": \\\"07\\\"\\n        }\\n    }},\\n    \\\"softDescriptor\\\": \\\"BLS&#x2a;default_descriptor\\\",\\n    \\\"recurringChargeAmount\\\": 29.99,\\n    \\\"chargeFrequency\\\": \\\"MONTHLY\\\",\\n    \\\"vaultedShopperId\\\": 21188909,\\n    \\\"payerInfo\\\": {\\n        \\\"firstName\\\": \\\"John\\\",\\n        \\\"lastName\\\": \\\"Doe\\\"\\n    },\\n    \\\"initialChargeAmount\\\": 100,\\n    \\\"autoRenew\\\": true,\\n    \\\"planId\\\": 2283849,\\n    \\\"currency\\\": \\\"USD\\\",\\n    \\\"subscriptionId\\\": 8492717,\\n    \\\"fraudResultInfo\\\": {\\\"deviceDataCollector\\\": \\\"N\\\"},\\n    \\\"status\\\": \\\"ACTIVE\\\"\\n}\",\n      \"language\": \"json\",\n      \"name\": \"Update Subscription Response: 200 OK\"\n    }\n  ],\n  \"sidebar\": true\n}\n[/block]\n<a class=\"btn btn-primary\" href=\"#\" role=\"button\">Back to Top</a>\n\n<hr>\n\n##Example Descriptions\nTo update any subscription setting, simply send the relevant field within the request. No other fields are required.\n\n<br>\n<a class=\"btn btn-primary\" href=\"#\" role=\"button\">Back to Top</a>\n\n<hr>\n\n##API Explorer\nTo test out a call, in the `subscriptionId` field, enter the ID of an existing subscription (e.g. 8491543). In the Body Content field, paste in the JSON portion of the request and then click **Try it!**\n\n**Tip**: Use the JSON code below as a starting point. You can enter different parameters to see how your test scenario would work. *The request headers, including authorization, are already built in for you in this test area, so you should not include them here.*\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\\"nextChargeDate\\\": \\\"2017-07-01\\\"}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"update-subscription","type":"put","title":"Update Subscription"}

putUpdate Subscription


Definition

{{ api_url }}{{ page_api_url }}

Parameters

Path Params

subscriptionId:
required
integer
BlueSnap identifier for the subscription.

Documentation

The Update Subscription request enables you to change any of the following settings for an existing subscription:

  • Plan associated to the subscription
  • Payment source
  • Override value for the recurring charge amount
  • Auto-renew setting (if you set it to false, the subscription will expire at the end of the current period)
  • Next charge date
  • Subscription status (ACTIVE/CANCELED)

For more information about working with subscriptions, see the Subscriptions tutorial.

Changing payment source

If you wish to change the credit card associated with the subscription:

  1. Make sure card details are saved to the vaulted shopper (If not, update vaulted shopper with new card details).
  2. Update the subscription to specify the new payment source.

Switch contract separately from other changes

If you are switching the contract associated with the subscription, we recommend you do this in a separate API call from other changes, such as updating the payment source or overriding the recurring charge amount. For example if you want to switch a subscription from plan 1 to plan 2 and also override the recurring charge amount for plan 2, we recommend that you first make an Update Subscription call to change the plan. Then make a separate call to override the recurring charge amount.

Try it in the API Explorer

Request Content

Send a subscription object, with the following:

      planId     integer    optional

      paymentSource     object    optional (see paymentSource)

      overrideRecurringChargeAmount     decimal   optional

      autoRenew     boolean    optional

      nextChargeDate     string    optional

      status     string    optional

Response Details

If successful, the response HTTP status code is 200 OK.
The response contains the subscription object.


Examples

Request Examples

curl -v -X PUT https://sandbox.bluesnap.com/services/2/recurring/subscriptions/8491543 \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \ 
-H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \
-d '
{"planId": 2283849}'
curl -v -X PUT https://sandbox.bluesnap.com/services/2/recurring/subscriptions/8491543 \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \ 
-H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \
-d '
{"status": "CANCELED"}'
curl -v -X PUT https://sandbox.bluesnap.com/services/2/recurring/subscriptions/8491543 \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \ 
-H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \
-d '
{"nextChargeDate": "2017-10-01"}'
curl -v -X PUT https://sandbox.bluesnap.com/services/2/recurring/subscriptions/8491543 \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \ 
-H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \
-d '
{  
  "paymentSource":{  
    "creditCardInfo":{  
      "creditCard":{  
        "cardLastFourDigits":"9299",
        "cardType":"VISA"
         }
      }
   }
}'

Response Example

{
    "nextChargeDate": "2016-08-16",
    "quantity": 1,
    "charge": {
        "amount": 100,
        "vaultedShopperId": 21188909,
        "chargeInfo": {
            "fromDate": "2016-08-02",
            "toDate": "2016-08-16",
            "chargeType": "INITIAL"
        },
        "chargeId": 12117877,
        "paymentSource": {"creditCardInfo": {"creditCard": {
            "expirationYear": 2019,
            "cardLastFourDigits": 1111,
            "cardSubType": "CREDIT",
            "cardType": "VISA",
            "expirationMonth": "07"
        }}},
        "softDescriptor": "BLS&#x2a;default_descriptor",
        "planId": 2283845,
        "currency": "USD",
        "transactionDate": "2016-08-02",
        "subscriptionId": 8492717,
        "transactionId": 1012463333
    },
    "trialPeriodDays": 14,
    "paymentSource": {"creditCardInfo": {
        "billingContactInfo": {
            "firstName": "John",
            "lastName": "Doe"
        },
        "creditCard": {
            "expirationYear": 2019,
            "cardLastFourDigits": 1111,
            "cardSubType": "CREDIT",
          	"cardCategory": "CLASSIC",
            "cardType": "VISA",
            "expirationMonth": "07"
        }
    }},
    "softDescriptor": "BLS&#x2a;default_descriptor",
    "recurringChargeAmount": 29.99,
    "chargeFrequency": "MONTHLY",
    "vaultedShopperId": 21188909,
    "payerInfo": {
        "firstName": "John",
        "lastName": "Doe"
    },
    "initialChargeAmount": 100,
    "autoRenew": true,
    "planId": 2283849,
    "currency": "USD",
    "subscriptionId": 8492717,
    "fraudResultInfo": {"deviceDataCollector": "N"},
    "status": "ACTIVE"
}

Back to Top


Example Descriptions

To update any subscription setting, simply send the relevant field within the request. No other fields are required.



Back to Top


API Explorer

To test out a call, in the subscriptionId field, enter the ID of an existing subscription (e.g. 8491543). In the Body Content field, paste in the JSON portion of the request and then click Try it!

Tip: Use the JSON code below as a starting point. You can enter different parameters to see how your test scenario would work. The request headers, including authorization, are already built in for you in this test area, so you should not include them here.

{"nextChargeDate": "2017-07-01"}

User Information

Try It Out


put
{{ tryResults.results }}
Method{{ tryResults.method }}
Request Headers
{{ tryResults.requestHeaders }}
URL{{ tryResults.url }}
Request Data
{{ tryResults.data }}
Status
Response Headers
{{ tryResults.responseHeaders }}