/subscriptions/
-
GET
http --verify=no --pretty=colors https://vagrant.local/wp-json/wc/v1/subscriptions/?per_page=2 --auth=ck_170731846b4e2616c225a9570da4dfc2718adccc:cs_8fb8974ef419e6c96fc84e6a048c0ebd8d121d39
// get subscriptions for customer ID#1
http --verify=no https://vagrant.local/wp-json/wc/v1/subscriptions/?customer=1 --auth=ck_170731846b4e2616c225a9570da4dfc2718adccc:cs_8fb8974ef419e6c96fc84e6a048c0ebd8d121d39
// get subscriptions for customer ID#1 and status active
curl -k "https://vagrant.local/wp-json/wc/v1/subscriptions/?customer=1&status=active" \
-u ck_170731846b4e2616c225a9570da4dfc2718adccc:cs_8fb8974ef419e6c96fc84e6a048c0ebd8d121d39
-
valid params
-
status, customer, product, dp (number of decimal points to use in each resource)
-
POST
curl -kX POST https://vagrant.local/wp-json/wc/v1/subscriptions/ \
-u ck_170731846b4e2616c225a9570da4dfc2718adccc:cs_8fb8974ef419e6c96fc84e6a048c0ebd8d121d39 \
-H "Content-Type: application/json" \
-d '{
"payment_method": "bacs",
"payment_method_title": "Direct Bank Transfer",
"status":"active",
"customer_id":1,
"billing_period":"month",
"billing_interval":1
}'
curl -kX POST https://vagrant.local/wp-json/wc/v1/subscriptions/ \
-u ck_170731846b4e2616c225a9570da4dfc2718adccc:cs_8fb8974ef419e6c96fc84e6a048c0ebd8d121d39 \
-H "Content-Type: application/json" \
-d '{
"customer_id":1,
"status":"active",
"billing_period":"month",
"billing_interval":2,
"next_payment_date":"2017-05-05 08:08:08",
"order_total":17.99,
"payment_details":{
"method_id":"stripe",
"method_title":"Credit Card (Stripe)",
"post_meta":{
"_stripe_customer_id":"cus_484hfj3m4fm3",
"_stripe_card_id":"card_5n4fndsn0"
}
}
}'
## invalid payment meta test
curl -kX POST https://vagrant.local/wp-json/wc/v1/subscriptions/ \
-u ck_170731846b4e2616c225a9570da4dfc2718adccc:cs_8fb8974ef419e6c96fc84e6a048c0ebd8d121d39 \
-H "Content-Type: application/json" \
-d '{
"customer_id":1,
"status":"active",
"billing_period":"month",
"billing_interval":2,
"next_payment_date":"2017-05-05 08:08:08",
"order_total":17.99,
"payment_details":{
"method_id":"stripe",
"method_title":"Credit Card (Stripe)",
"post_meta":{
"_stripe_customer_id":"cu_484hfj3m4fm3",
"_stripe_card_id":"ca_5n4fndsn0"
}
}
}'
/subscriptions/<id>
-
GET
http --verify=no --pretty=colors https://vagrant.local/wp-json/wc/v1/subscriptions/251 --auth=ck_170731846b4e2616c225a9570da4dfc2718adccc:cs_8fb8974ef419e6c96fc84e6a048c0ebd8d121d39
-
PUT
## change a subscription status to on-hold
curl -kX PUT https://vagrant.local/wp-json/wc/v1/subscriptions/30 \
-u ck_170731846b4e2616c225a9570da4dfc2718adccc:cs_8fb8974ef419e6c96fc84e6a048c0ebd8d121d39 \
-H "Content-Type: application/json" \
-d '{
"status": "on-hold"
}'
## quicker way to change the status to active by passing the new status in URL params
http --verify=no PUT https://vagrant.local/wp-json/wc/v1/subscriptions/25?status=active --auth=ck_170731846b4e2616c225a9570da4dfc2718adccc:cs_8fb8974ef419e6c96fc84e6a048c0ebd8d121d39
## updating billing address and payment_details
curl -kX PUT https://vagrant.local/wp-json/wc/v1/subscriptions/25 \
-u ck_170731846b4e2616c225a9570da4dfc2718adccc:cs_8fb8974ef419e6c96fc84e6a048c0ebd8d121d39 \
-H "Content-Type: application/json" \
-d '{
"status": "on-hold",
"payment_details":{
"method_id":"paypal",
"method_title":"PayPal",
"post_meta":{
"_paypal_subscription_id":"B-**************"
}
}
}'
curl -kX PUT https://vagrant.local/wp-json/wc/v1/subscriptions/25 \
-u ck_170731846b4e2616c225a9570da4dfc2718adccc:cs_8fb8974ef419e6c96fc84e6a048c0ebd8d121d39 \
-H "Content-Type: application/json" \
-d '{
"status": "on-hold",
"payment_details":{
"method_id":"stripe",
"method_title":"Credit Card (Stripe)",
"post_meta":{
"_stripe_customer_id":"cus_484hfj3m4fm3",
"_stripe_card_id":"card_5n4fndsn0"
}
}
}'
-
DELETE
http --verify=no DELETE https://vagrant.local/wp-json/wc/v1/subscriptions/22?force=true --auth=ck_170731846b4e2616c225a9570da4dfc2718adccc:cs_8fb8974ef419e6c96fc84e6a048c0ebd8d121d39
/subscriptions/<id>/orders
-
GET
curl -k https://vagrant.local/wp-json/wc/v1/subscriptions/25/orders \
-u ck_170731846b4e2616c225a9570da4dfc2718adccc:cs_8fb8974ef419e6c96fc84e6a048c0ebd8d121d39
curl -k https://vagrant.local/wp-json/wc/v1/subscriptions/statuses
http --verify=no https://vagrant.local/wp-json/wc/v1/subscriptions/statuses --auth=ck_170731846b4e2616c225a9570da4dfc2718adccc:cs_8fb8974ef419e6c96fc84e6a048c0ebd8d121d39
- POST
curl -kX POST https://vagrant.local/wp-json/wc/v1/subscriptions/251/notes \
-u ck_170731846b4e2616c225a9570da4dfc2718adccc:cs_8fb8974ef419e6c96fc84e6a048c0ebd8d121d39 \
-H "Content-Type: application/json" \
-d '{
"note": "Subscription ok!!!",
"customer_note":"true"
}'
curl -kX DELETE https://local.dev/Subs2.0/wc-api/v3/subscriptions/3368/notes/9456 \
-u ck_02002ffabb45f220a9aed0b679aa3e5175d3fe34:cs_ca4ab6d5e8dc700b9f7b7657e00a064666cf9970
curl -kX POST https://vagrant.local/wp-json/wc/v1/subscriptions/batch \
-u ck_170731846b4e2616c225a9570da4dfc2718adccc:cs_8fb8974ef419e6c96fc84e6a048c0ebd8d121d39 \
-H "Content-Type: application/json" \
-d '{
"create": [
{
"customer_id":1,
"status":"active",
"billing_period":"month",
"billing_interval":1,
"next_payment_date":"2017-05-05 08:08:08",
"order_total":17.99,
"payment_details":{
"method_id":"stripe",
"method_title":"Credit Card (Stripe)",
"post_meta":{
"_stripe_customer_id":"cu_484hfj3m4fm3",
"_stripe_card_id":"ca_5n4fndsn0"
}
"billing": {
"first_name": "John",
"last_name": "Doe",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US",
"email": "[email protected]",
"phone": "(555) 555-5555"
},
"shipping": {
"first_name": "John",
"last_name": "Doe",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US"
},
"line_items": [],
"shipping_lines": [
{
"method_id": "flat_rate",
"method_title": "Flat Rate",
"total": 30
}
]
}
],
"update": [
{
"id": 284,
"status": "on-hold"
}
],
"delete": [
281
]
}'
curl -kX POST https://vagrant.local/wp-json/wc/v1/subscriptions/batch
-u ck_170731846b4e2616c225a9570da4dfc2718adccc:cs_8fb8974ef419e6c96fc84e6a048c0ebd8d121d39
-H "Content-Type: application/json"
-d '{
"create": [
{
"customer_id":1,
"status":"active",
"billing_period":"month",
"billing_interval":1,
"next_payment_date":"2017-05-05 08:08:08",
"order_total":17.99,
"payment_details":{
"method_id":"stripe",
"method_title":"Credit Card (Stripe)",
"post_meta":{
"_stripe_customer_id":"cu_484hfj3m4fm3",
"_stripe_card_id":"ca_5n4fndsn0"
}
"billing": {
"first_name": "John",
"last_name": "Doe",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US",
"email": "[email protected]",
"phone": "(555) 555-5555"
},
"shipping": {
"first_name": "John",
"last_name": "Doe",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US"
},
"line_items": [],
"shipping_lines": [
{
"method_id": "flat_rate",
"method_title": "Flat Rate",
"total": 30
}
]
}
],
"update": [
{
"id": 284,
"status": "on-hold"
}
],
"delete": [
281
]
}'
curl -kX POST https://subs.localhost/wp-json/wc/v1/subscriptions/batch
-u ck_24b14854c87359c81113e1370419e50749c713b7:cs_702955396bf494b43a3a24691c59ff523fcd2745
-H "Content-Type: application/json"
-d '{
"create": [
{
"customer_id":1,
"status":"active",
"billing_period":"month",
"billing_interval":1,
"next_payment_date":"2017-05-05 08:08:08",
"order_total":17.99,
"payment_details":{
"method_id":"stripe",
"method_title":"Credit Card (Stripe)",
"post_meta":{
"_stripe_customer_id":"cu_484hfj3m4fm3",
"_stripe_card_id":"ca_5n4fndsn0"
}
"billing": {
"first_name": "John",
"last_name": "Doe",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US",
"email": "[email protected]",
"phone": "(555) 555-5555"
},
"shipping": {
"first_name": "John",
"last_name": "Doe",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US"
},
"line_items": [],
"shipping_lines": [
{
"method_id": "flat_rate",
"method_title": "Flat Rate",
"total": 30
}
]
}
],
"update": [
{
"id": 247,
"status": "on-hold"
}
],
"delete": [
261
]
}'