save-product
POST /api/{team}/gateway/save-product
Kanal içindeki ürün kataloğuna ürün kaydeder. Aynı channel_token ve channel_reference ile bir ürün varsa yeni ürün açılmaz, mevcut ürün güncellenir. Sipariş kalemleri ve abonelikler ürünleri bu channel_reference ile adlandırır. Ödeme uçları katalogdaki ürünü değiştirmez.
Kimlik doğrulama
X-Api-Key, X-Signature, Content-Type: application/json. Ayrıntılar: Kimlik Doğrulama ve İmza.
İstek
{
"product": {
"channel_token": "6f1c2e7a-4b3d-4c8e-9a61-2f5d7b0c3e14",
"channel_reference": "PREMIUM-AYLIK",
"name": "Premium üyelik",
"type": "recurring",
"amount": "149.90",
"tax_rate": "20",
"period": "monthly"
}
}
| Alan | Tip | Zorunlu | Açıklama |
|---|---|---|---|
product.channel_token | string (UUID) | evet | Çalışma alanınıza ait kanalın token'ı. |
product.channel_reference | string | evet | Ürünün sizin sisteminizdeki kimliği. En çok 255 karakter. |
product.name | string | evet | En çok 255 karakter. |
product.type | string | evet | simple ya da recurring. |
product.amount | string | number | evet | Birim fiyat (KDV dahil). En az 0.01, en çok iki ondalık. |
product.tax_rate | string | number | evet | Fiyatın içindeki KDV oranı. 0–100, en çok iki ondalık. |
product.period | string | koşullu | monthly ya da yearly. type: recurring için zorunlu; simple üründe yok sayılır ve null kaydedilir. |
product.currency | string | hayır | TRY, USD, EUR, GBP. Gönderilmezse TRY. |
product.is_active | boolean | hayır | Satışta mı. Gönderilmezse true. |
product içinde bu alanlar dışında bir anahtar gönderilirse istek 422 ile reddedilir.
SDK örnekleri
- PHP
- Node.js
- Python
- Java
- cURL
use Gurmehub\Odemehub\Request\SaveProduct;
$product = $client->saveProduct(new SaveProduct(
channelReference: 'PREMIUM-AYLIK',
name: 'Premium üyelik',
type: 'recurring',
amount: '149.90',
taxRate: '20',
period: 'monthly',
));
const product = await client.saveProduct({
channelReference: 'PREMIUM-AYLIK',
name: 'Premium üyelik',
type: 'recurring',
amount: '149.90',
taxRate: '20',
period: 'monthly',
});
from odemehub.request import SaveProduct
product = client.save_product(SaveProduct(
channel_reference="PREMIUM-AYLIK",
name="Premium üyelik",
type="recurring",
amount="149.90",
tax_rate="20",
period="monthly",
))
import com.odemehub.request.SaveProduct;
var product = client.saveProduct(SaveProduct.builder()
.channelReference("PREMIUM-AYLIK")
.name("Premium üyelik")
.type("recurring")
.amount("149.90")
.taxRate("20")
.period("monthly")
.build());
BODY='{"product":{"channel_token":"6f1c2e7a-4b3d-4c8e-9a61-2f5d7b0c3e14","channel_reference":"PREMIUM-AYLIK","name":"Premium üyelik","type":"recurring","amount":"149.90","tax_rate":"20","period":"monthly"}}'
SIGNATURE=$(printf '%s' "$BODY" | openssl dgst -sha256 -hmac "$ODEMEHUB_API_SECRET" | sed 's/^.* //')
curl -X POST "https://odeme.gurmehub.com/api/$ODEMEHUB_TEAM/gateway/save-product" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "X-Api-Key: $ODEMEHUB_API_KEY" \
-H "X-Signature: $SIGNATURE" \
--data-raw "$BODY"
Yanıt
{
"result": {
"successful": true,
"message": null
},
"product": {
"channel_token": "6f1c2e7a-4b3d-4c8e-9a61-2f5d7b0c3e14",
"channel_reference": "PREMIUM-AYLIK",
"name": "Premium üyelik",
"type": "recurring",
"amount": "149.90",
"currency": "TRY",
"tax_rate": "20.00",
"period": "monthly",
"is_active": true
}
}
| Alan | Tip | Açıklama |
|---|---|---|
product.channel_token | string | Ürünün kanalı. |
product.channel_reference | string | Ürünün kimliği. |
product.name | string | |
product.type | string | simple ya da recurring. |
product.amount | string | İki ondalıklı birim fiyat. |
product.currency | string | |
product.tax_rate | string | İki ondalıklı KDV oranı. |
product.period | string | null | recurring üründe monthly/yearly; simple üründe null. |
product.is_active | boolean |
Fiyat değişikliği
- Açık siparişler, oluşturuldukları andaki kalem fiyatlarını korur.
- Abonelik dönemlerinin tutarı dönem açılırken katalogdan hesaplanır; değişiklik bir sonraki dönemden itibaren geçerli olur.
- Satıştan kaldırmak için
is_active: falsegönderin. Ürün silme ucu yoktur. Satışta olmayan ürünle abonelik açılamaz.
HTTP durum kodları
| Kod | Durum |
|---|---|
200 | Ürün kaydedildi ya da güncellendi. |
401 | API anahtarı ya da imza geçersiz. |
403 | Çalışma alanı işlem yapamıyor. |
422 | Doğrulama hatası. |