Cadence
API Reference

Checkout

Initialize subscriptions, update cards, and handle the payment callback.

POST /checkout/initialize

Initialize a checkout session for customer subscription. Creates checkout session and customer records in database.

Base URL

https://cadence-api.pleasurebyplease.com

Request

POST https://cadence-api.pleasurebyplease.com/checkout/initialize

Headers

  • X-Api-Key: {your-api-key}
  • X-Api-Secret: {your-api-secret}

Checkout Flow

  1. Call this endpoint with customer data
  2. Render the returned checkoutFormContent HTML in your page
  3. Customer completes payment on iyzico form
  4. iyzico redirects to your callbackUrl

Request Body

NameTypeRequiredDescriptionExample
pricingPlanReferenceCodestringNoReference code of the pricing plan. Required if segno-plan-id is not provided (mutually exclusive)plan_abc123
segno-plan-idstringNoInternal Cadence plan ID. Required if pricingPlanReferenceCode is not provided (mutually exclusive)plan_id_8r2n3k1p
callbackUrlstringYesURL where iyzico redirects after paymenthttps://cadence-api.pleasurebyplease.com/checkout/callback
namestringYesCustomer first nameJohn
surnamestringYesCustomer last nameDoe
emailstringYesCustomer email addressjohn@example.com
gsmNumberstringYesPhone number (E.164 format preferred)+905551234567
identityNumberstringYesTurkish ID number (11 digits)12345678901
subscriptionInitialStatusstring ("ACTIVE" | "PENDING")NoInitial status of subscription
billingAddressobjectNoBilling address object
billingAddress.contactNamestringYesContact name for billing
billingAddress.countrystringYesCountry
billingAddress.citystringYesCity
billingAddress.addressstringYesStreet address
billingAddress.zipCodestringNoPostal code
shippingAddressobjectNoShipping address (same structure as billingAddress)

Response (Success)

FieldTypeDescription
status"success"Operation result
checkoutFormContentstringHTML/JS content to render checkout form
tokenstringCheckout session token
tokenExpireTimenumberToken validity in seconds
paymentPageUrlstringURL to redirect user for payment (alternative to rendering checkoutFormContent)
clientReferenceIdstringYour tracking ID for this session
segnoPlanIdstring | nullInternal Cadence plan identifier for the selected plan

Example Request

cURL

curl -X POST \
  "https://cadence-api.pleasurebyplease.com/checkout/initialize" \
  -H "X-Api-Key: {your-api-key}" \
  -H "X-Api-Secret: {your-api-secret}" \
  -H "Content-Type: application/json" \
  -d '{
    "pricingPlanReferenceCode": "plan_abc123",
    "callbackUrl": "https://cadence-api.pleasurebyplease.com/checkout/callback",
    "name": "John",
    "surname": "Doe",
    "email": "john@example.com",
    "gsmNumber": "+905551234567",
    "identityNumber": "12345678901"
  }'

TypeScript

const response = await fetch('https://cadence-api.pleasurebyplease.com/checkout/initialize', {
  method: 'POST',
  headers: {
    'X-Api-Key': '{your-api-key}',
    'X-Api-Secret': '{your-api-secret}',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    pricingPlanReferenceCode: 'plan_abc123',
    callbackUrl: 'https://cadence-api.pleasurebyplease.com/checkout/callback',
    name: 'John',
    surname: 'Doe',
    email: 'john@example.com',
    gsmNumber: '+905551234567',
    identityNumber: '12345678901',
  }),
});

const data: CheckoutInitializeResponse = await response.json();

if (data.status === 'success' && data.checkoutFormContent) {
  // Render the checkout form in your page
  document.getElementById('checkout')!.innerHTML = data.checkoutFormContent;
}

Node.js

const response = await fetch('https://cadence-api.pleasurebyplease.com/checkout/initialize', {
  method: 'POST',
  headers: {
    'X-Api-Key': '{your-api-key}',
    'X-Api-Secret': '{your-api-secret}',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    pricingPlanReferenceCode: 'plan_abc123',
    callbackUrl: 'https://cadence-api.pleasurebyplease.com/checkout/callback',
    name: 'John',
    surname: 'Doe',
    email: 'john@example.com',
    gsmNumber: '+905551234567',
    identityNumber: '12345678901',
  }),
});

const data = await response.json();
console.log(data);

PHP

<?php
$data = [
    'pricingPlanReferenceCode' => 'plan_abc123',
    'callbackUrl' => 'https://cadence-api.pleasurebyplease.com/checkout/callback',
    'name' => 'John',
    'surname' => 'Doe',
    'email' => 'john@example.com',
    'gsmNumber' => '+905551234567',
    'identityNumber' => '12345678901'
];

$ch = curl_init();
curl_setopt_array($ch, [
    CURLOPT_URL => 'https://cadence-api.pleasurebyplease.com/checkout/initialize',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => json_encode($data),
    CURLOPT_HTTPHEADER => [
        'X-Api-Key: {your-api-key}',
        'X-Api-Secret: {your-api-secret}',
        'Content-Type: application/json'
    ]
]);

$response = curl_exec($ch);
curl_close($ch);

$result = json_decode($response, true);

if ($result['status'] === 'success') {
    echo $result['checkoutFormContent'];
}

Go

package main

import (
    "bytes"
    "encoding/json"
    "net/http"
)

type CheckoutRequest struct {
    PricingPlanReferenceCode string `json:"pricingPlanReferenceCode"`
    CallbackUrl              string `json:"callbackUrl"`
    Name                     string `json:"name"`
    Surname                  string `json:"surname"`
    Email                    string `json:"email"`
    GsmNumber                string `json:"gsmNumber"`
    IdentityNumber           string `json:"identityNumber"`
}

func main() {
    data := CheckoutRequest{
        PricingPlanReferenceCode: "plan_abc123",
        CallbackUrl:              "https://cadence-api.pleasurebyplease.com/checkout/callback",
        Name:                     "John",
        Surname:                  "Doe",
        Email:                    "john@example.com",
        GsmNumber:                "+905551234567",
        IdentityNumber:           "12345678901",
    }

    jsonData, _ := json.Marshal(data)
    req, _ := http.NewRequest("POST", 
        "https://cadence-api.pleasurebyplease.com/checkout/initialize", 
        bytes.NewBuffer(jsonData))
    
    req.Header.Set("X-Api-Key", "{your-api-key}")
    req.Header.Set("X-Api-Secret", "{your-api-secret}")
    req.Header.Set("Content-Type", "application/json")

    client := &http.Client{}
    resp, _ := client.Do(req)
    defer resp.Body.Close()
}

Ruby

require 'net/http'
require 'json'

uri = URI('https://cadence-api.pleasurebyplease.com/checkout/initialize')
request = Net::HTTP::Post.new(uri)
request['X-Api-Key'] = '{your-api-key}'
request['X-Api-Secret'] = '{your-api-secret}'
request['Content-Type'] = 'application/json'
request.body = {
  pricingPlanReferenceCode: 'plan_abc123',
  callbackUrl: 'https://cadence-api.pleasurebyplease.com/checkout/callback',
  name: 'John',
  surname: 'Doe',
  email: 'john@example.com',
  gsmNumber: '+905551234567',
  identityNumber: '12345678901'
}.to_json

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
  http.request(request)
end

result = JSON.parse(response.body)
puts result['checkoutFormContent'] if result['status'] == 'success'

Python

import requests

response = requests.post(
    'https://cadence-api.pleasurebyplease.com/checkout/initialize',
    headers={
        'X-Api-Key': '{your-api-key}',
        'X-Api-Secret': '{your-api-secret}',
        'Content-Type': 'application/json'
    },
    json={
        'pricingPlanReferenceCode': 'plan_abc123',
        'callbackUrl': 'https://cadence-api.pleasurebyplease.com/checkout/callback',
        'name': 'John',
        'surname': 'Doe',
        'email': 'john@example.com',
        'gsmNumber': '+905551234567',
        'identityNumber': '12345678901'
    }
)

data = response.json()
if data['status'] == 'success':
    print(data['checkoutFormContent'])

Example Response

{
  "status": "success",
  "checkoutFormContent": "<script>...</script>",
  "token": "checkout_token_xyz",
  "tokenExpireTime": 1800,
  "paymentPageUrl": "https://sandbox-merchant.iyzipay.com/checkout/test/...",
  "clientReferenceId": "550e8400-e29b-41d4-a716-446655440000",
  "segnoPlanId": "plan_id_8r2n3k1p"
}

POST /checkout/initialize-direct

Initialize a subscription directly with credit card information (Non-3DS). Creates subscription immediately.

Base URL

https://cadence-api.pleasurebyplease.com

Request

POST https://cadence-api.pleasurebyplease.com/checkout/initialize-direct

Headers

  • X-Api-Key: {your-api-key}
  • X-Api-Secret: {your-api-secret}

Flow

  1. Collect card information securely
  2. Call this endpoint
  3. Subscription is created immediately if successful

Request Body

NameTypeRequiredDescriptionExample
pricingPlanReferenceCodestringNoReference code of the pricing plan. Required if segno-plan-id is not provided (mutually exclusive)plan_abc123
segno-plan-idstringNoInternal Cadence plan ID. Required if pricingPlanReferenceCode is not provided (mutually exclusive)plan_id_8r2n3k1p
namestringYesCustomer first nameJohn
surnamestringYesCustomer last nameDoe
emailstringYesCustomer email addressjohn@example.com
gsmNumberstringYesPhone number (E.164 format preferred)+905551234567
identityNumberstringYesTurkish ID number (11 digits)12345678901
paymentCardobjectYesCredit Card Information
paymentCard.cardHolderNamestringYesName on the cardJohn Doe
paymentCard.cardNumberstringYesCard number5528790000000008
paymentCard.expireMonthstringYesExpiration month (2 digits)12
paymentCard.expireYearstringYesExpiration year (4 digits)2030
paymentCard.cvcstringYesCard CVC/CVV123
subscriptionInitialStatusstring ("ACTIVE" | "PENDING")NoInitial status of subscription (default: ACTIVE if successful)
billingAddressobjectNoBilling address object
shippingAddressobjectNoShipping address object
clientReferenceIdstringNoYour unique reference ID for trackingorder_12345

Response (Success)

FieldTypeDescription
status"success"Operation result
segnoSubscriptionIdstringInternal Cadence subscription identifier
segnoCustomerIdstring | nullInternal Cadence customer identifier
segnoPlanIdstring | nullInternal Cadence plan identifier
dataobjectIyzico response data (referenceCode, customerReferenceCode, subscriptionStatus, etc.)

Example Request

cURL

curl -X POST \
  "https://cadence-api.pleasurebyplease.com/checkout/initialize-direct" \
  -H "X-Api-Key: {your-api-key}" \
  -H "X-Api-Secret: {your-api-secret}" \
  -H "Content-Type: application/json" \
  -d '{
    "pricingPlanReferenceCode": "plan_abc123",
    "clientReferenceId": "order_12345",
    "name": "John",
    "surname": "Doe",
    "email": "john@example.com",
    "gsmNumber": "+905551234567",
    "identityNumber": "12345678901",
    "paymentCard": {
        "cardHolderName": "John Doe",
        "cardNumber": "5528790000000008",
        "expireMonth": "12",
        "expireYear": "2030",
        "cvc": "123"
    }
  }'

TypeScript

const response = await fetch('https://cadence-api.pleasurebyplease.com/checkout/initialize-direct', {
  method: 'POST',
  headers: {
    'X-Api-Key': '{your-api-key}',
    'X-Api-Secret': '{your-api-secret}',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    pricingPlanReferenceCode: 'plan_abc123',
    clientReferenceId: 'order_12345',
    name: 'John',
    surname: 'Doe',
    email: 'john@example.com',
    gsmNumber: '+905551234567',
    identityNumber: '12345678901',
    paymentCard: {
        cardHolderName: 'John Doe',
        cardNumber: '5528790000000008',
        expireMonth: '12',
        expireYear: '2030',
        cvc: '123'
    },
    billingAddress: {
        contactName: 'John Doe',
        country: 'Turkey',
        city: 'Istanbul',
        address: 'Example Address 123'
    }
  }),
});

const data = await response.json();

if (data.status === 'success') {
  console.log('Cadence subscription ID:', data.segnoSubscriptionId);
  console.log('Iyzico ref:', data.data?.referenceCode);
} else {
  console.error('Failed:', data.message);
}

Node.js

// Using node-fetch or native fetch (Node 18+)
const response = await fetch('https://cadence-api.pleasurebyplease.com/checkout/initialize-direct', {
  method: 'POST',
  headers: {
    'X-Api-Key': '{your-api-key}',
    'X-Api-Secret': '{your-api-secret}',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    pricingPlanReferenceCode: 'plan_abc123',
    clientReferenceId: 'order_12345',
    name: 'John',
    surname: 'Doe',
    email: 'john@example.com',
    gsmNumber: '+905551234567',
    identityNumber: '12345678901',
    paymentCard: {
        cardHolderName: 'John Doe',
        cardNumber: '5528790000000008',
        expireMonth: '12',
        expireYear: '2030',
        cvc: '123'
    }
  }),
});

const data = await response.json();
console.log(data);

PHP

<?php
$data = [
    'pricingPlanReferenceCode' => 'plan_abc123',
    'clientReferenceId' => 'order_12345',
    'name' => 'John',
    'surname' => 'Doe',
    'email' => 'john@example.com',
    'gsmNumber' => '+905551234567',
    'identityNumber' => '12345678901',
    'paymentCard' => [
        'cardHolderName' => 'John Doe',
        'cardNumber' => '5528790000000008',
        'expireMonth' => '12',
        'expireYear' => '2030',
        'cvc' => '123'
    ]
];

$ch = curl_init();
curl_setopt_array($ch, [
    CURLOPT_URL => 'https://cadence-api.pleasurebyplease.com/checkout/initialize-direct',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => json_encode($data),
    CURLOPT_HTTPHEADER => [
        'X-Api-Key: {your-api-key}',
        'X-Api-Secret: {your-api-secret}',
        'Content-Type: application/json'
    ]
]);

$response = curl_exec($ch);
curl_close($ch);

$result = json_decode($response, true);
print_r($result);

Go

package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "net/http"
)

type PaymentCard struct {
    CardHolderName string `json:"cardHolderName"`
    CardNumber     string `json:"cardNumber"`
    ExpireMonth    string `json:"expireMonth"`
    ExpireYear     string `json:"expireYear"`
    Cvc            string `json:"cvc"`
}

type SubscriptionRequest struct {
    PricingPlanReferenceCode string      `json:"pricingPlanReferenceCode"`
    ClientReferenceId        string      `json:"clientReferenceId"`
    Name                     string      `json:"name"`
    Surname                  string      `json:"surname"`
    Email                    string      `json:"email"`
    GsmNumber                string      `json:"gsmNumber"`
    IdentityNumber           string      `json:"identityNumber"`
    PaymentCard              PaymentCard `json:"paymentCard"`
}

func main() {
    data := SubscriptionRequest{
        PricingPlanReferenceCode: "plan_abc123",
        ClientReferenceId:        "order_12345",
        Name:                     "John",
        Surname:                  "Doe",
        Email:                    "john@example.com",
        GsmNumber:                "+905551234567",
        IdentityNumber:           "12345678901",
        PaymentCard: PaymentCard{
            CardHolderName: "John Doe",
            CardNumber:     "5528790000000008",
            ExpireMonth:    "12",
            ExpireYear:     "2030",
            Cvc:            "123",
        },
    }

    jsonData, _ := json.Marshal(data)
    req, _ := http.NewRequest("POST", 
        "https://cadence-api.pleasurebyplease.com/checkout/initialize-direct", 
        bytes.NewBuffer(jsonData))
    
    req.Header.Set("X-Api-Key", "{your-api-key}")
    req.Header.Set("X-Api-Secret", "{your-api-secret}")
    req.Header.Set("Content-Type", "application/json")

    client := &http.Client{}
    resp, _ := client.Do(req)
    defer resp.Body.Close()
    
    // Read and print response body...
}

Ruby

require 'net/http'
require 'json'

uri = URI('https://cadence-api.pleasurebyplease.com/checkout/initialize-direct')
request = Net::HTTP::Post.new(uri)
request['X-Api-Key'] = '{your-api-key}'
request['X-Api-Secret'] = '{your-api-secret}'
request['Content-Type'] = 'application/json'

data = {
  pricingPlanReferenceCode: 'plan_abc123',
  clientReferenceId: 'order_12345',
  name: 'John',
  surname: 'Doe',
  email: 'john@example.com',
  gsmNumber: '+905551234567',
  identityNumber: '12345678901',
  paymentCard: {
    cardHolderName: 'John Doe',
    cardNumber: '5528790000000008',
    expireMonth: '12',
    expireYear: '2030',
    cvc: '123'
  }
}

request.body = data.to_json

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
  http.request(request)
end

puts response.body

Python

import requests

response = requests.post(
    'https://cadence-api.pleasurebyplease.com/checkout/initialize-direct',
    headers={
        'X-Api-Key': '{your-api-key}',
        'X-Api-Secret': '{your-api-secret}',
        'Content-Type': 'application/json'
    },
    json={
        'pricingPlanReferenceCode': 'plan_abc123',
        'clientReferenceId': 'order_12345',
        'name': 'John',
        'surname': 'Doe',
        'email': 'john@example.com',
        'gsmNumber': '+905551234567',
        'identityNumber': '12345678901',
        'paymentCard': {
            'cardHolderName': 'John Doe',
            'cardNumber': '5528790000000008',
            'expireMonth': '12',
            'expireYear': '2030',
            'cvc': '123'
        }
    }
)

print(response.json())

Example Response

{
  "status": "success",
  "segnoSubscriptionId": "sub_id_5x4n2v8k",
  "segnoCustomerId": "cust_id_3m7k9p2q",
  "segnoPlanId": "plan_id_8r2n3k1p",
  "data": {
    "referenceCode": "b7879942-5645-42df-b695-94943725b820",
    "parentReferenceCode": "b7879942-5645-42df-b695-94943725b820",
    "pricingPlanReferenceCode": "plan_abc123",
    "customerReferenceCode": "cust_12345",
    "subscriptionStatus": "ACTIVE",
    "createdDate": 1738075594000,
    "startDate": 1738075594000,
    "endDate": null
  }
}

POST /checkout/update-card

Initialize a checkout form session to update a subscriber's credit card.

Base URL

https://cadence-api.pleasurebyplease.com

Request

POST https://cadence-api.pleasurebyplease.com/checkout/update-card

Headers

  • X-Api-Key: {your-api-key}
  • X-Api-Secret: {your-api-secret}

Flow

  1. Call this endpoint to get form content
  2. Render form on your frontend
  3. User enters new card details
  4. Redirects to callback URL upon completion

Request Body

NameTypeRequiredDescriptionExample
callbackUrlstringYesURL where iyzico redirects after operationhttps://cadence-api.pleasurebyplease.com/checkout/callback
subscriptionReferenceCodestringNoReference code of the subscription. Required if segno-id is not provided; use with customerReferenceCode (mutually exclusive with segno-id)b7879942-5645-42df-b695-94943725b820
customerReferenceCodestringNoReference code of the customer. Required if segno-id is not provided; use with subscriptionReferenceCode (mutually exclusive with segno-id)cust_12345
segno-idstringNoInternal Cadence subscription ID. Required if subscriptionReferenceCode/customerReferenceCode are not provided (mutually exclusive)sub_id_5x4n2v8k
clientReferenceIdstringNoYour unique reference ID for trackingreq_12345

Response (Success)

FieldTypeDescription
status"success"Operation result
tokenstringCheckout session token
checkoutFormContentstringHTML/JS content to render checkout form
tokenExpireTimenumberToken validity in seconds
paymentPageUrlstringURL to redirect user for card update
segnoIdstring | nullInternal Cadence subscription identifier

Example Request

cURL

curl -X POST \
  "https://cadence-api.pleasurebyplease.com/checkout/update-card" \
  -H "X-Api-Key: {your-api-key}" \
  -H "X-Api-Secret: {your-api-secret}" \
  -H "Content-Type: application/json" \
  -d '{
    "callbackUrl": "https://cadence-api.pleasurebyplease.com/checkout/callback",
    "subscriptionReferenceCode": "b7879942-5645-42df-b695-94943725b820",
    "customerReferenceCode": "cust_12345",
    "clientReferenceId": "req_12345"
  }'

TypeScript

const response = await fetch('https://cadence-api.pleasurebyplease.com/checkout/update-card', {
  method: 'POST',
  headers: {
    'X-Api-Key': '{your-api-key}',
    'X-Api-Secret': '{your-api-secret}',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    callbackUrl: 'https://cadence-api.pleasurebyplease.com/checkout/callback',
    subscriptionReferenceCode: 'b7879942-5645-42df-b695-94943725b820',
    customerReferenceCode: 'cust_12345',
    clientReferenceId: 'req_12345'
  }),
});

const data = await response.json();

if (data.status === 'success' && data.checkoutFormContent) {
  // Render form, or redirect to data.paymentPageUrl
  document.getElementById('checkout-container').innerHTML = data.checkoutFormContent;
}

Node.js

const response = await fetch('https://cadence-api.pleasurebyplease.com/checkout/update-card', {
  method: 'POST',
  headers: {
    'X-Api-Key': '{your-api-key}',
    'X-Api-Secret': '{your-api-secret}',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    callbackUrl: 'https://cadence-api.pleasurebyplease.com/checkout/callback',
    subscriptionReferenceCode: 'b7879942-5645-42df-b695-94943725b820',
    customerReferenceCode: 'cust_12345',
    clientReferenceId: 'req_12345'
  }),
});

const data = await response.json();
console.log(data);

PHP

<?php
$data = [
    'callbackUrl' => 'https://cadence-api.pleasurebyplease.com/checkout/callback',
    'subscriptionReferenceCode' => 'b7879942-5645-42df-b695-94943725b820',
    'customerReferenceCode' => 'cust_12345',
    'clientReferenceId' => 'req_12345'
];

$ch = curl_init();
curl_setopt_array($ch, [
    CURLOPT_URL => 'https://cadence-api.pleasurebyplease.com/checkout/update-card',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => json_encode($data),
    CURLOPT_HTTPHEADER => [
        'X-Api-Key: {your-api-key}',
        'X-Api-Secret: {your-api-secret}',
        'Content-Type: application/json'
    ]
]);

$response = curl_exec($ch);
curl_close($ch);

$result = json_decode($response, true);
print_r($result);

Go

package main

import (
    "bytes"
    "encoding/json"
    "net/http"
)

func main() {
    values := map[string]string{
        "callbackUrl": "https://cadence-api.pleasurebyplease.com/checkout/callback",
        "subscriptionReferenceCode": "b7879942-5645-42df-b695-94943725b820",
        "customerReferenceCode": "cust_12345",
        "clientReferenceId": "req_12345",
    }
    jsonData, _ := json.Marshal(values)

    req, _ := http.NewRequest("POST", 
        "https://cadence-api.pleasurebyplease.com/checkout/update-card", 
        bytes.NewBuffer(jsonData))
    
    req.Header.Set("X-Api-Key", "{your-api-key}")
    req.Header.Set("X-Api-Secret", "{your-api-secret}")
    req.Header.Set("Content-Type", "application/json")

    client := &http.Client{}
    resp, _ := client.Do(req)
    defer resp.Body.Close()
}

Ruby

require 'net/http'
require 'json'

uri = URI('https://cadence-api.pleasurebyplease.com/checkout/update-card')
req = Net::HTTP::Post.new(uri)
req['X-Api-Key'] = '{your-api-key}'
req['X-Api-Secret'] = '{your-api-secret}'
req['Content-Type'] = 'application/json'

req.body = {
  callbackUrl: 'https://cadence-api.pleasurebyplease.com/checkout/callback',
  subscriptionReferenceCode: 'b7879942-5645-42df-b695-94943725b820',
  customerReferenceCode: 'cust_12345',
  clientReferenceId: 'req_12345'
}.to_json

res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
  http.request(req)
end

puts res.body

Python

import requests

response = requests.post(
    'https://cadence-api.pleasurebyplease.com/checkout/update-card',
    headers={
        'X-Api-Key': '{your-api-key}',
        'X-Api-Secret': '{your-api-secret}',
        'Content-Type': 'application/json'
    },
    json={
        'callbackUrl': 'https://cadence-api.pleasurebyplease.com/checkout/callback',
        'subscriptionReferenceCode': 'b7879942-5645-42df-b695-94943725b820',
        'customerReferenceCode': 'cust_12345',
        'clientReferenceId': 'req_12345'
    }
)

print(response.json())

Example Response

{
  "status": "success",
  "token": "token_xyz123",
  "checkoutFormContent": "<script>...</script>",
  "tokenExpireTime": 1800,
  "paymentPageUrl": "https://sandbox-merchant.iyzipay.com/checkout/test/...",
  "segnoId": "sub_id_5x4n2v8k"
}

GET /checkout/callback

Callback endpoint that iyzico redirects to after payment. Activates the subscription with iyzico and redirects to your callbackUrl with the result.

Base URL

https://cadence-api.pleasurebyplease.com

Request

GET https://cadence-api.pleasurebyplease.com/checkout/callback

Headers

  • X-Api-Key: {your-api-key}
  • X-Api-Secret: {your-api-secret}

How It Works

  1. iyzico redirects customer to this endpoint with a token
  2. We retrieve the checkout result from iyzico
  3. If successful, we activate the subscription with iyzico
  4. We redirect to YOUR callbackUrl with result data as query params

Query Parameters (from iyzico)

NameTypeRequiredDescriptionExample
tokenstringYesCheckout token provided by iyzico redirect

Redirect Query Params (Success)

FieldTypeDescription
status"success"Indicates successful checkout
subscriptionReferencestringUnique reference code for the created subscription (iyzico)
customerReferencestringUnique reference code for the customer in iyzico
planReferencestringThe pricing plan reference code
segnoSubscriptionIdstringInternal Cadence subscription identifier
segnoCustomerIdstringInternal Cadence customer identifier

Redirect Query Params (Error)

FieldTypeDescription
status"error"Indicates failed checkout
errorCodestringError code from iyzico or internal error code
errorMessagestringHuman-readable error description

Behavior

On Success:

  • Retrieves checkout result from iyzico
  • Activates subscription with iyzico (if PENDING)
  • Updates checkout session to SUCCESS
  • Updates customer record with iyzico reference
  • Creates subscription record in database
  • Redirects to your callbackUrl with success params

On Failure:

  • Updates checkout session to FAILED
  • Stores error code and message
  • Redirects to your callbackUrl with error params

Example Success Redirect

https://yoursite.com/payment/callback?status=success&subscriptionReference=sub_abc123&customerReference=cust_xyz789&planReference=plan_pro_monthly

Example Error Redirect

https://yoursite.com/payment/callback?status=error&errorCode=PAYMENT_DECLINED&errorMessage=Insufficient%20funds

Handle the Redirect

const url = new URL(window.location.href);
const status = url.searchParams.get('status');

if (status === 'success') {
  const subscriptionRef = url.searchParams.get('subscriptionReference');
  const segnoSubscriptionId = url.searchParams.get('segnoSubscriptionId');
  const segnoCustomerId = url.searchParams.get('segnoCustomerId');
  // Show success message, redirect to dashboard, etc.
} else {
  const errorCode = url.searchParams.get('errorCode');
  const errorMessage = url.searchParams.get('errorMessage');
  // Show error message to user
}

On this page