API kullanarak yeni abonelik oluşturabilmeniz için 3 bilgiye ihtiyaç var:
Method: POST
Path: /api/subscriptions/start
Sandbox Url: https://sandbox.subscreasy.com/api/subscriptions/start
Bu servis, güvenlik açısından, API yetkilendirmesine gerek duyar. API yetkilendirmesi hakkında detay için tıklayınız.
Curl
curl -X POST https://sandbox.subscreasy.com/api/subscriptions/start \
-H 'Accept: application/json' -H 'Content-Type: application/json' -H 'Cache-Control: no-cache' \
-H 'Authorization: Apikey brs-1234567890' \
-d '{
"offer": {"id":240},
"subscriber": {
"email": "john.doe@gmail.com",
"name": "John",
"surname": "Doe"
},
"paymentCard": {
"cardHolderName": "John Doe",
"cardNumber": "5528790000000008",
"expireYear": "2030",
"expireMonth": "12",
"cvc": "123",
"registerCard": 0
}
}'
C#
var client = new RestClient("https://sandbox.subscreasy.com/api/subscriptions/start");
var request = new RestRequest(Method.POST);
request.AddHeader("Cache-Control", "no-cache");
request.AddHeader("Authorization", "Apikey brs-1234567890");
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Accept", "application/json");
request.AddParameter("undefined", "{ \"offer\": {\"id\": 240}, \"subscriber\": { \"email\": \"john.doe@gmail.com\", \"name\": \"John\", \"surname\": \"Doe\" }, \"paymentCard\": { \"cardHolderName\": \"John Doe\", \"cardNumber\": \"5528790000000008\", \"expireYear\": \"2030\", \"expireMonth\": \"12\", \"cvc\": \"123\", \"registerCard\": 0 }}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
JSON
{
"offer": {"id": 240},
"subscriber": {
"email": "john.doe@gmail.com",
"name": "John",
"surname": "Doe"
},
"paymentCard": {
"cardHolderName": "John Doe",
"cardNumber": "5528790000000008",
"expireYear": "2030",
"expireMonth": "12",
"cvc": "123",
"registerCard": 0
}
}
{
"subscription": {
"id": 4,
"status": "ACTIVE",
"paymentMethod": "CC",
"startDate": "2018-08-30T13:45:18.615+03:00",
"termStartDate": "2018-08-30T13:45:18.615+03:00",
"termEndDate": "2018-08-30T13:46:18.615+03:00",
"endDate": "2018-08-30T13:48:18.615+03:00",
"subscriber": {
"id": -1,
"name": "John",
"surname": "Doe"
},
"card": {
"id": 2,
"binNumber": "5571-xxxx-xxxx-5575"
},
"services": []
},
"payment": {
"id": 4,
"price": 0.99,
"appliedCoupon": null,
"paymentId": "71741081",
"authCode": "649237",
"errorCode": null,
"errorText": "Authorized.",
"jobId": null,
"invoiceId": null,
"subscriptionId": 4,
"serviceInstanceId": null,
"subscriberSecureId": "0c42c6f3-cea0-4997-a2e2-fd66fbaf50f5",
"companyId": -1,
"paymentGateway": "PAYU",
"status": "PAID",
"reason": "START",
"currency": "TRY",
"transactionId": "c8c253c1c15f48a2a3cefa6f0c6ca6ef",
"createDate": "2018-08-30T13:45:23.702+03:00",
"parentId": null,
"savedCardId": null,
"savedCard": null
}
}