curl -X POST 'https://api.weir.ai/org/subscribe' \
-H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
-H 'Content-Type: application/json' \
-H 'x-source: console' \
-d '{
"cardId": "card_123456789",
"amount": 99.99,
"subscriptionId": "sub_plan_123"
}'
{
"data": {
"subscriptionId": "sub_123456789",
"planId": "sub_plan_123",
"status": "active",
"startDate": "2024-01-22T00:00:00Z",
"nextBillingDate": "2024-02-22T00:00:00Z",
"amount": 99.99,
"currency": "USD"
},
"message": "Subscription created successfully",
"status": "success"
}
Subscribe to a subscription plan
curl -X POST 'https://api.weir.ai/org/subscribe' \
-H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
-H 'Content-Type: application/json' \
-H 'x-source: console' \
-d '{
"cardId": "card_123456789",
"amount": 99.99,
"subscriptionId": "sub_plan_123"
}'
{
"data": {
"subscriptionId": "sub_123456789",
"planId": "sub_plan_123",
"status": "active",
"startDate": "2024-01-22T00:00:00Z",
"nextBillingDate": "2024-02-22T00:00:00Z",
"amount": 99.99,
"currency": "USD"
},
"message": "Subscription created successfully",
"status": "success"
}
curl -X POST 'https://api.weir.ai/org/subscribe' \
-H 'Authorization: Bearer YOUR_ACCESS_TOKEN' \
-H 'Content-Type: application/json' \
-H 'x-source: console' \
-d '{
"cardId": "card_123456789",
"amount": 99.99,
"subscriptionId": "sub_plan_123"
}'
{
"data": {
"subscriptionId": "sub_123456789",
"planId": "sub_plan_123",
"status": "active",
"startDate": "2024-01-22T00:00:00Z",
"nextBillingDate": "2024-02-22T00:00:00Z",
"amount": 99.99,
"currency": "USD"
},
"message": "Subscription created successfully",
"status": "success"
}
const subscribe = async (subscriptionData, accessToken) => {
const response = await fetch('https://api.weir.ai/org/subscribe', {
method: 'POST',
headers: {
'Authorization': `Bearer ${accessToken}`,
'Content-Type': 'application/json',
'x-source': 'console'
},
body: JSON.stringify(subscriptionData)
});
if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
return await response.json();
};
Was this page helpful?