### Install iyzipay via PyPI Source: https://github.com/iyzico/iyzipay-python/blob/master/README.md Install the iyzipay Python bindings using pip or easy_install. ```bash pip install iyzipay ``` ```bash easy_install iyzipay ``` -------------------------------- ### Install iyzipay Python Client Source: https://context7.com/iyzico/iyzipay-python/llms.txt Install the library using pip. Ensure you are using Python 3.9+. ```bash pip install iyzipay ``` -------------------------------- ### Initialize Subscription Source: https://context7.com/iyzico/iyzipay-python/llms.txt Starts a new customer subscription with provided card details and pricing plan. Ensure all customer and payment card information is accurate. ```python import iyzipay options = { 'api_key': iyzipay.api_key, 'secret_key': iyzipay.secret_key, 'base_url': iyzipay.base_url } init_request = { 'locale': 'tr', 'conversationId': 'conv-1001', 'pricingPlanReferenceCode': '36fcd8e3-f99b-4b19-9dc4-f7c30d7f0cd4', 'subscriptionInitialStatus': 'ACTIVE', 'customer': { 'name': 'John', 'surname': 'Stone', 'email': 'john@gmail.com', 'gsmNumber': '+905545545512', 'identityNumber': '1234567890', 'billingAddress': { 'address': 'Altunizade Mah. İnci Çıkmazı Sokak No: 3', 'contactName': 'John Stone', 'city': 'Istanbul', 'country': 'Türkiye' }, 'shippingAddress': { 'address': 'Address', 'zipCode': '34000', 'contactName': 'John Stone', 'city': 'Istanbul', 'country': 'Türkiye' } }, 'paymentCard': { 'cardHolderName': 'John Doe', 'cardNumber': '5528790000000008', 'expireMonth': '12', 'expireYear': '2030', 'cvc': '123' } } result = iyzipay.Subscription().initialize(init_request, options) print(result.read().decode('utf-8')) ``` -------------------------------- ### Create Payment Request Source: https://github.com/iyzico/iyzipay-python/blob/master/README.md Example demonstrating how to set up payment options, card details, buyer information, addresses, and basket items for a payment request. Ensure all sensitive information like API keys and card details are handled securely. ```python options = { 'api_key': 'your api key', 'secret_key': 'your secret key', 'base_url': 'sandbox-api.iyzipay.com' } payment_card = { 'cardHolderName': 'John Doe', 'cardNumber': '5528790000000008', 'expireMonth': '12', 'expireYear': '2030', 'cvc': '123', 'registerCard': '0' } buyer = { 'id': 'BY789', 'name': 'John', 'surname': 'Doe', 'gsmNumber': '+905350000000', 'email': 'email@email.com', 'identityNumber': '74300864791', 'lastLoginDate': '2015-10-05 12:43:35', 'registrationDate': '2013-04-21 15:12:09', 'registrationAddress': 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1', 'ip': '85.34.78.112', 'city': 'Istanbul', 'country': 'Turkey', 'zipCode': '34732' } address = { 'contactName': 'Jane Doe', 'city': 'Istanbul', 'country': 'Turkey', 'address': 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1', 'zipCode': '34732' } basket_items = [ { 'id': 'BI101', 'name': 'Binocular', 'category1': 'Collectibles', 'category2': 'Accessories', 'itemType': 'PHYSICAL', 'price': '0.3' }, { 'id': 'BI102', 'name': 'Game code', 'category1': 'Game', 'category2': 'Online Game Items', 'itemType': 'VIRTUAL', 'price': '0.5' }, { 'id': 'BI103', 'name': 'Usb', 'category1': 'Electronics', 'category2': 'Usb / Cable', 'itemType': 'PHYSICAL', 'price': '0.2' } ] request = { 'locale': 'tr', 'conversationId': '123456789', 'price': '1', 'paidPrice': '1.2', 'currency': 'TRY', 'installment': '1', 'basketId': 'B67832', 'paymentChannel': 'WEB', 'paymentGroup': 'PRODUCT', 'paymentCard': payment_card, 'buyer': buyer, 'shippingAddress': address, 'billingAddress': address, 'basketItems': basket_items } payment = iyzipay.Payment().create(request, options) ``` -------------------------------- ### Query Installment Options Source: https://context7.com/iyzico/iyzipay-python/llms.txt Retrieves available installment counts and pricing for a given BIN number and payment amount. The result includes installment details like number, total price, and installment price. ```python import iyzipay options = { 'api_key': iyzipay.api_key, 'secret_key': iyzipay.secret_key, 'base_url': iyzipay.base_url } request = { 'locale': 'tr', 'conversationId': '123456789', 'binNumber': '554960', 'price': '100' } result = iyzipay.InstallmentInfo().retrieve(request, options) print(result.read().decode('utf-8')) # Returns: installmentDetails list with installmentNumber, totalPrice, installmentPrice per option ``` -------------------------------- ### Import iyzipay Package Source: https://github.com/iyzico/iyzipay-python/blob/master/README.md Import the iyzipay package for use in your Python project after manual installation. ```python import iyzipay ``` -------------------------------- ### InstallmentInfo — Query Installment Options Source: https://context7.com/iyzico/iyzipay-python/llms.txt Returns the available installment counts and pricing for a given BIN number and payment amount. ```APIDOC ## InstallmentInfo — Query Installment Options Returns the available installment counts and pricing for a given BIN number and payment amount. ```python import iyzipay options = { 'api_key': iyzipay.api_key, 'secret_key': iyzipay.secret_key, 'base_url': iyzipay.base_url } request = { 'locale': 'tr', 'conversationId': '123456789', 'binNumber': '554960', 'price': '100' } result = iyzipay.InstallmentInfo().retrieve(request, options) print(result.read().decode('utf-8')) # Returns: installmentDetails list with installmentNumber, totalPrice, installmentPrice per option ``` ``` -------------------------------- ### Create a Subscription Product with iyzipay-python Source: https://context7.com/iyzico/iyzipay-python/llms.txt Creates a subscription product entry in the catalog, which serves as a container for pricing plans. Requires product name and description. ```python import iyzipay options = { 'api_key': iyzipay.api_key, 'secret_key': iyzipay.secret_key, 'base_url': iyzipay.base_url } product = { 'locale': 'tr', 'conversationId': '123456789', 'name': 'Coffee Pack', 'description': 'Turkish Coffee Subscription' } result = iyzipay.SubscriptionProduct().create(product, options) print(result.read().decode('utf-8')) ``` -------------------------------- ### Retrieve Transaction Data Source: https://context7.com/iyzico/iyzipay-python/llms.txt Examples of retrieving large transaction sets and completed payout transactions using the iyzipay-python library. ```APIDOC ## Retrieve Transaction Data ### Scroll through large transaction sets ```python scroll_request = { 'transactionDate': '20231115', 'documentScrollVoSortingOrder': 'ASC', 'lastId': '0', 'conversationId': '123456789' } scroll_result = iyzipay.ReportingScrollTransaction().retrieve(scroll_request, options) print(scroll_result.read().decode('utf-8')) ``` ### Retrieve payout completed transactions ```python payout_request = {'locale': 'tr', 'conversationId': '123456789', 'date': '2023-11-15'} payout = iyzipay.PayoutCompletedTransactionList().retrieve(payout_request, options) print(payout.read().decode('utf-8')) ``` ``` -------------------------------- ### Configuration Options Dictionary Source: https://context7.com/iyzico/iyzipay-python/llms.txt Prepare an options dictionary containing your API credentials and the target base URL. This dictionary is passed to API calls. ```python # Sandbox options = { 'api_key': 'sandbox_api_key', 'secret_key': 'sandbox_secret_key', 'base_url': 'sandbox-api.iyzipay.com' } # Production options = { 'api_key': 'live_api_key', 'secret_key': 'live_secret_key', 'base_url': 'api.iyzipay.com' } ``` -------------------------------- ### List Pricing Plans for a Product Source: https://context7.com/iyzico/iyzipay-python/llms.txt Retrieves all pricing plans associated with a specific subscription product. Requires the product's reference code. ```python list_request = {'product_reference_code': 'fe7b7a27-4192-45da-964e-7a5934b3a6ef'} plans = iyzipay.SubscriptionPricingPlan().list(list_request, options) print(plans.read().decode('utf-8')) ``` -------------------------------- ### List Subscription Products Source: https://context7.com/iyzico/iyzipay-python/llms.txt Retrieves a list of all available subscription products. Ensure 'options' are correctly configured. ```python products = iyzipay.SubscriptionProduct().list(options) print(products.read().decode('utf-8')) ``` -------------------------------- ### Create a Pay-by-Link Product with iyzipay-python Source: https://context7.com/iyzico/iyzipay-python/llms.txt Creates a shareable payment link product. Supports image uploads via base64 encoding. Requires product details and an optional encoded image file. ```python import iyzipay options = { 'api_key': iyzipay.api_key, 'secret_key': iyzipay.secret_key, 'base_url': iyzipay.base_url } create_request = { 'locale': 'tr', 'conversationId': '123456789', 'name': 'Awesome Product', 'description': 'Test product description', 'currencyCode': 'TRY', 'price': '1.0', 'addressIgnorable': 0, 'installmentRequested': False, 'soldLimit': True, 'encodedImageFile': iyzipay.IyziFileBase64Encoder.encode('./samples/images/image.png') } result = iyzipay.IyziLinkProduct().create(create_request, options) print(result.read().decode('utf-8')) ``` -------------------------------- ### Pre-Authorization and Capture with iyzipay-python Source: https://context7.com/iyzico/iyzipay-python/llms.txt Use PaymentPreAuth to reserve funds without immediate capture, then use PaymentPostAuth to capture them. Ensure the signature is verified before proceeding with the capture. ```python import json import iyzipay options = { 'api_key': iyzipay.api_key, 'secret_key': iyzipay.secret_key, 'base_url': iyzipay.base_url } preauth_request = { 'locale': 'tr', 'conversationId': '123456789', 'price': '1', 'paidPrice': '1.2', 'currency': 'TRY', 'installment': '1', 'basketId': 'B67832', 'paymentChannel': 'WEB', 'paymentGroup': 'PRODUCT', 'paymentCard': { 'cardHolderName': 'John Doe', 'cardNumber': '5528790000000008', 'expireMonth': '12', 'expireYear': '2030', 'cvc': '123', 'registerCard': '0' }, 'buyer': { 'id': 'BY789', 'name': 'John', 'surname': 'Doe', 'gsmNumber': '+905350000000', 'email': 'email@email.com', 'identityNumber': '74300864791', 'lastLoginDate': '2015-10-05 12:43:35', 'registrationDate': '2013-04-21 15:12:09', 'registrationAddress': 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1', 'ip': '85.34.78.112', 'city': 'Istanbul', 'country': 'Turkey', 'zipCode': '34732' }, 'shippingAddress': { 'contactName': 'Jane Doe', 'city': 'Istanbul', 'country': 'Turkey', 'address': 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1', 'zipCode': '34732' }, 'billingAddress': { 'contactName': 'Jane Doe', 'city': 'Istanbul', 'country': 'Turkey', 'address': 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1', 'zipCode': '34732' }, 'basketItems': [ {'id': 'BI101', 'name': 'Binocular', 'category1': 'Collectibles', 'category2': 'Accessories', 'itemType': 'PHYSICAL', 'price': '0.3'}, {'id': 'BI102', 'name': 'Game code', 'category1': 'Game', 'category2': 'Online Game Items', 'itemType': 'VIRTUAL', 'price': '0.5'}, {'id': 'BI103', 'name': 'Usb', 'category1': 'Electronics', 'category2': 'Usb / Cable', 'itemType': 'PHYSICAL', 'price': '0.2'} ] } preauth = iyzipay.PaymentPreAuth() preauth_result = json.load(preauth.create(preauth_request, options)) print('PreAuth response:', preauth_result) if preauth_result['status'] == 'success': preauth.verify_signature( [preauth_result['paymentId'], preauth_result['currency'], preauth_result['basketId'], preauth_result['conversationId'], preauth.strip_zero(str(preauth_result['paidPrice'])), preauth.strip_zero(str(preauth_result['price']))], options['secret_key'], preauth_result['signature'] ) # Capture the reserved funds postauth_request = { 'locale': 'tr', 'conversationId': '123456789', 'paymentId': preauth_result['paymentId'] } postauth_result = json.loads( iyzipay.PaymentPostAuth().create(postauth_request, options).read().decode('utf-8') ) print('PostAuth response:', postauth_result) ``` -------------------------------- ### ThreedsInitialize / ThreedsPayment Source: https://context7.com/iyzico/iyzipay-python/llms.txt Initiates a 3DS challenge and then completes the payment once the bank redirects back with a `paymentId` and `conversationData`. ```APIDOC ## ThreedsInitialize / ThreedsPayment — 3D Secure Payment (Two-Step) Initiates a 3DS challenge and then completes the payment once the bank redirects back with a `paymentId` and `conversationData`. ```python import json import iyzipay options = { 'api_key': iyzipay.api_key, 'secret_key': iyzipay.secret_key, 'base_url': iyzipay.base_url } ``` -------------------------------- ### SubscriptionCheckoutForm - Create and Retrieve Source: https://context7.com/iyzico/iyzipay-python/llms.txt Initializes a hosted checkout form for subscription sign-up and retrieves the subscription result after user completion. ```APIDOC ## SubscriptionCheckoutForm - Create ### Description Initializes a hosted checkout form for subscription sign-up. ### Method POST ### Endpoint /v2/subscription/checkoutform/initialize ### Parameters #### Request Body - **locale** (string) - Required - Locale of the API response. - **conversationId** (string) - Required - Unique identifier for the conversation. - **pricingPlanReferenceCode** (string) - Required - Reference code of the pricing plan. - **subscriptionInitialStatus** (string) - Required - Initial status of the subscription (e.g., 'ACTIVE'). - **callbackUrl** (string) - Required - URL to redirect the user after form completion. - **customer** (object) - Required - Customer details. - **name** (string) - Required - **surname** (string) - Required - **email** (string) - Required - **gsmNumber** (string) - Required - **identityNumber** (string) - Required - **billingAddress** (object) - Required - **address** (string) - Required - **contactName** (string) - Required - **city** (string) - Required - **country** (string) - Required ### Request Example ```json { "locale": "tr", "conversationId": "conv-checkout-001", "pricingPlanReferenceCode": "36fcd8e3-f99b-4b19-9dc4-f7c30d7f0cd4", "subscriptionInitialStatus": "ACTIVE", "callbackUrl": "https://www.merchant.com/subscription/callback", "customer": { "name": "John", "surname": "Stone", "email": "john@gmail.com", "gsmNumber": "+905545545512", "identityNumber": "1234567890", "billingAddress": { "address": "Altunizade Mah. No: 3", "contactName": "John Stone", "city": "Istanbul", "country": "Türkiye" } } } ``` ### Response #### Success Response (200) - **token** (string) - Token for the checkout form. - **checkoutFormContent** (string) - HTML content to embed the form. #### Response Example ```json { "token": "checkout-token", "checkoutFormContent": "..." } ``` ## SubscriptionCheckoutForm - Retrieve ### Description Retrieves the subscription result after the user completes the hosted checkout form. ### Method POST ### Endpoint /v2/subscription/checkoutform/retrieve ### Parameters #### Request Body - **token** (string) - Required - The token obtained from the checkout form initialization or callback. ### Request Example ```json { "token": "checkout-token-from-callback" } ``` ### Response #### Success Response (200) - **status** (string) - Status of the operation. - **data** (object) - Subscription details. #### Response Example ```json { "status": "success", "data": { "subscriptionReferenceCode": "sub-ref-123", "subscriptionStatus": "ACTIVE", "customerReferenceCode": "cust-ref-456" } } ``` ``` -------------------------------- ### Initialize Subscription Checkout Form Source: https://context7.com/iyzico/iyzipay-python/llms.txt Initializes a hosted checkout form for subscription sign-up. Use this to create a new subscription via a hosted form. The result contains a token and checkoutFormContent to embed in your page. ```python import iyzipay options = { 'api_key': iyzipay.api_key, 'secret_key': iyzipay.secret_key, 'base_url': iyzipay.base_url } init_request = { 'locale': 'tr', 'conversationId': 'conv-checkout-001', 'pricingPlanReferenceCode': '36fcd8e3-f99b-4b19-9dc4-f7c30d7f0cd4', 'subscriptionInitialStatus': 'ACTIVE', 'callbackUrl': 'https://www.merchant.com/subscription/callback', 'customer': { 'name': 'John', 'surname': 'Stone', 'email': 'john@gmail.com', 'gsmNumber': '+905545545512', 'identityNumber': '1234567890', 'billingAddress': { 'address': 'Altunizade Mah. No: 3', 'contactName': 'John Stone', 'city': 'Istanbul', 'country': 'Türkiye' } } } init_result = iyzipay.SubscriptionCheckoutForm().create(init_request, options) print(init_result.read().decode('utf-8')) # Returns token and checkoutFormContent to embed in your page # Retrieve result after customer completes checkout retrieve_request = {'token': 'checkout-token-from-callback'} checkout_result = iyzipay.SubscriptionCheckoutForm().retrieve(retrieve_request, options) print(checkout_result.read().decode('utf-8')) ``` -------------------------------- ### List Pay-by-Link Products with iyzipay-python Source: https://context7.com/iyzico/iyzipay-python/llms.txt Retrieves a paginated list of pay-by-link products. Supports specifying page number and count. ```python list_request = {'page': 1, 'count': 10} product_list = iyzipay.IyziLinkProduct().get(list_request, options) print(product_list.read().decode('utf-8')) ``` -------------------------------- ### Initialize 3DS Payment Request Source: https://context7.com/iyzico/iyzipay-python/llms.txt Prepare and send the initial request for a 3D Secure payment. This includes all necessary payment, buyer, shipping, billing, and basket item details. Ensure 'options' are correctly configured. ```python init_request = { 'locale': 'tr', 'conversationId': '123456789', 'price': '1', 'paidPrice': '1.2', 'currency': 'TRY', 'installment': '1', 'basketId': 'B67832', 'paymentChannel': 'WEB', 'paymentGroup': 'PRODUCT', 'callbackUrl': 'https://www.merchant.com/callback', 'paymentCard': { 'cardHolderName': 'John Doe', 'cardNumber': '5528790000000008', 'expireMonth': '12', 'expireYear': '2030', 'cvc': '123', 'registerCard': '0' }, 'buyer': { 'id': 'BY789', 'name': 'John', 'surname': 'Doe', 'gsmNumber': '+905350000000', 'email': 'email@email.com', 'identityNumber': '74300864791', 'lastLoginDate': '2015-10-05 12:43:35', 'registrationDate': '2013-04-21 15:12:09', 'registrationAddress': 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1', 'ip': '85.34.78.112', 'city': 'Istanbul', 'country': 'Turkey', 'zipCode': '34732' }, 'shippingAddress': { 'contactName': 'Jane Doe', 'city': 'Istanbul', 'country': 'Turkey', 'address': 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1', 'zipCode': '34732' }, 'billingAddress': { 'contactName': 'Jane Doe', 'city': 'Istanbul', 'country': 'Turkey', 'address': 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1', 'zipCode': '34732' }, 'basketItems': [ {'id': 'BI101', 'name': 'Binocular', 'category1': 'Collectibles', 'category2': 'Accessories', 'itemType': 'PHYSICAL', 'price': '0.3'}, {'id': 'BI102', 'name': 'Game code', 'category1': 'Game', 'category2': 'Online Game Items', 'itemType': 'VIRTUAL', 'price': '0.5'}, {'id': 'BI103', 'name': 'Usb', 'category1': 'Electronics', 'category2': 'Usb / Cable', 'itemType': 'PHYSICAL', 'price': '0.2'} ] } threeds_init = iyzipay.ThreedsInitialize() init_result = json.load(threeds_init.create(init_request, options)) if init_result['status'] == 'success': threeds_init.verify_signature( [init_result['paymentId'], init_result['conversationId']], options['secret_key'], init_result['signature'] ) # Render init_result['threeDSHtmlContent'] to the user ``` -------------------------------- ### Create a Personal Sub-Merchant with iyzipay-python Source: https://context7.com/iyzico/iyzipay-python/llms.txt Creates a new personal sub-merchant account for marketplace payments. Requires detailed contact and financial information. ```python import iyzipay options = { 'api_key': iyzipay.api_key, 'secret_key': iyzipay.secret_key, 'base_url': iyzipay.base_url } create_request = { 'locale': 'tr', 'conversationId': '123456789', 'subMerchantExternalId': 'B49224', 'subMerchantType': 'PERSONAL', 'address': 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1', 'contactName': 'John', 'contactSurname': 'Doe', 'email': 'email@submerchantemail.com', 'gsmNumber': '+905350000000', 'name': "John's market", 'iban': 'TR180006200119000006672315', 'identityNumber': '31300864726', 'currency': 'TRY' } result = iyzipay.SubMerchant().create(create_request, options) print(result.read().decode('utf-8')) ``` -------------------------------- ### Initiate 3D Secure Payment with iyzipay-python Source: https://context7.com/iyzico/iyzipay-python/llms.txt Initiates a 3DS challenge and then completes the payment once the bank redirects back with a paymentId and conversationData. Requires API keys and base URL configuration. ```python import json import iyzipay options = { 'api_key': iyzipay.api_key, 'secret_key': iyzipay.secret_key, 'base_url': iyzipay.base_url } ``` -------------------------------- ### Create Subscription Pricing Plan Source: https://context7.com/iyzico/iyzipay-python/llms.txt Defines recurring billing terms for a subscription product. Requires details like name, recurrence, interval, currency, price, and associated product reference code. ```python import iyzipay options = { 'api_key': iyzipay.api_key, 'secret_key': iyzipay.secret_key, 'base_url': iyzipay.base_url } pricing_plan = { 'locale': 'tr', 'conversationId': 'conv-001', 'name': 'Monthly Plan', 'recurrenceCount': 12, 'planPaymentType': 'RECURRING', 'trialPeriodDays': 0, 'paymentIntervalCount': 1, 'paymentInterval': 'MONTHLY', # DAILY, WEEKLY, MONTHLY, YEARLY 'currencyCode': 'TRY', 'price': 99.99, 'product_reference_code': 'fe7b7a27-4192-45da-964e-7a5934b3a6ef' } result = iyzipay.SubscriptionPricingPlan().create(pricing_plan, options) print(result.read().decode('utf-8')) ``` -------------------------------- ### Retrieve a Pay-by-Link Product by Token with iyzipay-python Source: https://context7.com/iyzico/iyzipay-python/llms.txt Retrieves details of a specific pay-by-link product using its unique token. ```python retrieve_request = {'token': 'product-token-here'} product = iyzipay.IyziLinkProduct().retrieve(retrieve_request, options) print(product.read().decode('utf-8')) ``` -------------------------------- ### Create Subscription Product Source: https://context7.com/iyzico/iyzipay-python/llms.txt Creates a subscription product catalog entry, which acts as a container for pricing plans. ```APIDOC ## Create Subscription Product ### Description Creates a product entry in the subscription catalog. This product serves as a container for defining various pricing plans. ### Method ```python create(product, options) ``` ### Parameters #### Request Body - **locale** (string) - Required - The locale for the request. - **conversationId** (string) - Required - A unique identifier for the conversation. - **name** (string) - Required - The name of the subscription product. - **description** (string) - Optional - A description for the subscription product. ### Request Example ```python product = { 'locale': 'tr', 'conversationId': '123456789', 'name': 'Coffee Pack', 'description': 'Turkish Coffee Subscription' } result = iyzipay.SubscriptionProduct().create(product, options) ``` ### Response #### Success Response Returns a JSON object indicating the status of the subscription product creation. ``` -------------------------------- ### SubscriptionCardUpdate - Initialize Source: https://context7.com/iyzico/iyzipay-python/llms.txt Initializes a secure card update flow for an existing subscription. ```APIDOC ## SubscriptionCardUpdate - Initialize (Standalone) ### Description Initializes a secure card update flow for a customer, allowing them to provide new card details via a checkout form. ### Method POST ### Endpoint /v2/subscription/cardupdate/initialize ### Parameters #### Request Body - **locale** (string) - Required - Locale of the API response. - **conversationId** (string) - Required - Unique identifier for the conversation. - **customerReferenceCode** (string) - Required - The reference code of the customer whose card is to be updated. - **callbackUrl** (string) - Required - URL to redirect the user after card update completion. ### Request Example ```json { "locale": "tr", "conversationId": "123456789", "customerReferenceCode": "customer-ref-code", "callbackUrl": "https://www.merchant.com/card-update/callback" } ``` ### Response #### Success Response (200) - **token** (string) - Token for the card update checkout form. - **checkoutFormContent** (string) - HTML content to embed the form. #### Response Example ```json { "token": "card-update-token", "checkoutFormContent": "..." } ``` ## SubscriptionCardUpdate - Initialize with Subscription ### Description Initializes a secure card update flow specifically tied to an existing subscription. ### Method POST ### Endpoint /v2/subscription/cardupdate/initialize ### Parameters #### Request Body - **locale** (string) - Required - Locale of the API response. - **conversationId** (string) - Required - Unique identifier for the conversation. - **subscriptionReferenceCode** (string) - Required - The reference code of the subscription to update the card for. - **callbackUrl** (string) - Required - URL to redirect the user after card update completion. ### Request Example ```json { "locale": "tr", "conversationId": "123456789", "subscriptionReferenceCode": "sub-reference-code", "callbackUrl": "https://www.merchant.com/card-update/callback" } ``` ### Response #### Success Response (200) - **token** (string) - Token for the card update checkout form. - **checkoutFormContent** (string) - HTML content to embed the form. #### Response Example ```json { "token": "card-update-token", "checkoutFormContent": "..." } ``` ``` -------------------------------- ### Create Direct Card Payment with iyzipay-python Source: https://context7.com/iyzico/iyzipay-python/llms.txt Charges a card immediately using the Payment.create method. Always verify the signature of the response to confirm authenticity. Requires API keys and base URL configuration. ```python import json import iyzipay options = { 'api_key': iyzipay.api_key, 'secret_key': iyzipay.secret_key, 'base_url': iyzipay.base_url } request = { 'locale': 'tr', 'conversationId': '123456789', 'price': '1', 'paidPrice': '1.2', 'currency': 'TRY', 'installment': '1', 'basketId': 'B67832', 'paymentChannel': 'WEB', 'paymentGroup': 'PRODUCT', 'paymentCard': { 'cardHolderName': 'John Doe', 'cardNumber': '5528790000000008', 'expireMonth': '12', 'expireYear': '2030', 'cvc': '123', 'registerCard': '0' }, 'buyer': { 'id': 'BY789', 'name': 'John', 'surname': 'Doe', 'gsmNumber': '+905350000000', 'email': 'email@email.com', 'identityNumber': '74300864791', 'lastLoginDate': '2015-10-05 12:43:35', 'registrationDate': '2013-04-21 15:12:09', 'registrationAddress': 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1', 'ip': '85.34.78.112', 'city': 'Istanbul', 'country': 'Turkey', 'zipCode': '34732' }, 'shippingAddress': { 'contactName': 'Jane Doe', 'city': 'Istanbul', 'country': 'Turkey', 'address': 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1', 'zipCode': '34732' }, 'billingAddress': { 'contactName': 'Jane Doe', 'city': 'Istanbul', 'country': 'Turkey', 'address': 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1', 'zipCode': '34732' }, 'basketItems': [ {'id': 'BI101', 'name': 'Binocular', 'category1': 'Collectibles', 'category2': 'Accessories', 'itemType': 'PHYSICAL', 'price': '0.3'}, {'id': 'BI102', 'name': 'Game code', 'category1': 'Game', 'category2': 'Online Game Items', 'itemType': 'VIRTUAL', 'price': '0.5'}, {'id': 'BI103', 'name': 'Usb', 'category1': 'Electronics', 'category2': 'Usb / Cable', 'itemType': 'PHYSICAL', 'price': '0.2'} ] } payment = iyzipay.Payment() result = json.load(payment.create(request, options)) print('response:', result) if result['status'] == 'success': # Verify HMAC-SHA256 signature to protect against replay attacks payment.verify_signature( [result['paymentId'], result['currency'], result['basketId'], result['conversationId'], payment.strip_zero(str(result['paidPrice'])), payment.strip_zero(str(result['price']))], options['secret_key'], result['signature'] ) # Output: Signature verified: True ``` -------------------------------- ### Retrieve Specific Pricing Plan Source: https://context7.com/iyzico/iyzipay-python/llms.txt Fetches details for a single pricing plan using its reference code. Requires 'pricing_plan_reference_code'. ```python retrieve_request = {'pricing_plan_reference_code': 'plan-ref-code'} plan = iyzipay.SubscriptionPricingPlan().retrieve(retrieve_request, options) print(plan.read().decode('utf-8')) ``` -------------------------------- ### Retrieve Specific Subscription Product Source: https://context7.com/iyzico/iyzipay-python/llms.txt Fetches details for a single subscription product using its reference code. Requires a valid 'product_reference_code'. ```python retrieve_request = {'product_reference_code': 'fe7b7a27-4192-45da-964e-7a5934b3a6ef'} product_detail = iyzipay.SubscriptionProduct().retrieve(retrieve_request, options) ``` -------------------------------- ### Initialize Subscription Card Update Source: https://context7.com/iyzico/iyzipay-python/llms.txt Initializes a secure card update flow for an existing subscription. This can be done standalone or tied to a specific subscription reference code. The result provides a token and checkoutFormContent for embedding. ```python import iyzipay options = { 'api_key': iyzipay.api_key, 'secret_key': iyzipay.secret_key, 'base_url': iyzipay.base_url } # Standalone card update (customer provides new card via checkout form) init_request = { 'locale': 'tr', 'conversationId': '123456789', 'customerReferenceCode': 'customer-ref-code', 'callbackUrl': 'https://www.merchant.com/card-update/callback' } result = iyzipay.SubscriptionCardUpdate().initialize(init_request, options) print(result.read().decode('utf-8')) # Returns: token and checkoutFormContent to embed # Tied to a specific subscription sub_init_request = { 'locale': 'tr', 'conversationId': '123456789', 'subscriptionReferenceCode': 'sub-reference-code', 'callbackUrl': 'https://www.merchant.com/card-update/callback' } result = iyzipay.SubscriptionCardUpdate().initialize_with_subscription(sub_init_request, options) print(result.read().decode('utf-8')) ``` -------------------------------- ### Configure iyzipay Credentials Globally Source: https://context7.com/iyzico/iyzipay-python/llms.txt Set your API key, secret key, and base URL globally for the iyzipay library. This configuration can be overridden per-call by passing an options dictionary. ```python import iyzipay # Configure globally (or pass per-call via options dict) iyzipay.api_key = 'your_api_key' iyzipay.secret_key = 'your_secret_key' iyzipay.base_url = 'sandbox-api.iyzipay.com' # or 'api.iyzipay.com' for production ``` -------------------------------- ### Upgrade Subscription Plan Source: https://context7.com/iyzico/iyzipay-python/llms.txt Changes a customer's subscription to a new pricing plan. Specify when the upgrade should take effect ('NOW' or 'NEXT_PERIOD') and whether to ignore prorated refunds. ```python upgrade_request = { 'subscriptionReferenceCode': 'sub-reference-code', 'newPricingPlanReferenceCode': 'new-plan-ref-code', 'upgradePeriod': 'NOW', # or 'NEXT_PERIOD' 'ignoreProratedRefund': False } iyzipay.Subscription().upgrade(upgrade_request, options) ``` -------------------------------- ### Payment.create Source: https://context7.com/iyzico/iyzipay-python/llms.txt Charges a card immediately. Returns a signed response; always verify the signature to confirm authenticity. ```APIDOC ## Payment.create — Direct Card Payment Charges a card immediately. Returns a signed response; always verify the signature to confirm authenticity. ```python import json import iyzipay options = { 'api_key': iyzipay.api_key, 'secret_key': iyzipay.secret_key, 'base_url': iyzipay.base_url } request = { 'locale': 'tr', 'conversationId': '123456789', 'price': '1', 'paidPrice': '1.2', 'currency': 'TRY', 'installment': '1', 'basketId': 'B67832', 'paymentChannel': 'WEB', 'paymentGroup': 'PRODUCT', 'paymentCard': { 'cardHolderName': 'John Doe', 'cardNumber': '5528790000000008', 'expireMonth': '12', 'expireYear': '2030', 'cvc': '123', 'registerCard': '0' }, 'buyer': { 'id': 'BY789', 'name': 'John', 'surname': 'Doe', 'gsmNumber': '+905350000000', 'email': 'email@email.com', 'identityNumber': '74300864791', 'lastLoginDate': '2015-10-05 12:43:35', 'registrationDate': '2013-04-21 15:12:09', 'registrationAddress': 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1', 'ip': '85.34.78.112', 'city': 'Istanbul', 'country': 'Turkey', 'zipCode': '34732' }, 'shippingAddress': { 'contactName': 'Jane Doe', 'city': 'Istanbul', 'country': 'Turkey', 'address': 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1', 'zipCode': '34732' }, 'billingAddress': { 'contactName': 'Jane Doe', 'city': 'Istanbul', 'country': 'Turkey', 'address': 'Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1', 'zipCode': '34732' }, 'basketItems': [ {'id': 'BI101', 'name': 'Binocular', 'category1': 'Collectibles', 'category2': 'Accessories', 'itemType': 'PHYSICAL', 'price': '0.3'}, {'id': 'BI102', 'name': 'Game code', 'category1': 'Game', 'category2': 'Online Game Items', 'itemType': 'VIRTUAL', 'price': '0.5'}, {'id': 'BI103', 'name': 'Usb', 'category1': 'Electronics', 'category2': 'Usb / Cable', 'itemType': 'PHYSICAL', 'price': '0.2'} ] } payment = iyzipay.Payment() result = json.load(payment.create(request, options)) print('response:', result) if result['status'] == 'success': # Verify HMAC-SHA256 signature to protect against replay attacks payment.verify_signature( [result['paymentId'], result['currency'], result['basketId'], result['conversationId'], payment.strip_zero(str(result['paidPrice'])), payment.strip_zero(str(result['price']))], options['secret_key'], result['signature'] ) # Output: Signature verified: True ``` ``` -------------------------------- ### Create IyziLink Product Source: https://context7.com/iyzico/iyzipay-python/llms.txt Creates a shareable payment link product (IyziLink). Supports product details and image upload. ```APIDOC ## Create IyziLink Product ### Description Creates a shareable payment link product. Supports product name, description, price, and optional image upload. ### Method ```python create(request, options) ``` ### Parameters #### Request Body - **locale** (string) - Required - The locale for the request. - **conversationId** (string) - Required - A unique identifier for the conversation. - **name** (string) - Required - The name of the product. - **description** (string) - Optional - The description of the product. - **currencyCode** (string) - Required - The currency code (e.g., TRY). - **price** (string) - Required - The price of the product. - **addressIgnorable** (integer) - Optional - Flag to ignore address (0 or 1). - **installmentRequested** (boolean) - Optional - Whether installments are requested. - **soldLimit** (boolean) - Optional - Whether there is a sales limit. - **encodedImageFile** (string) - Optional - Base64 encoded image file. ### Request Example ```python create_request = { 'locale': 'tr', 'conversationId': '123456789', 'name': 'Awesome Product', 'description': 'Test product description', 'currencyCode': 'TRY', 'price': '1.0', 'addressIgnorable': 0, 'installmentRequested': False, 'soldLimit': True, 'encodedImageFile': iyzipay.IyziFileBase64Encoder.encode('./samples/images/image.png') } result = iyzipay.IyziLinkProduct().create(create_request, options) ``` ### Response #### Success Response Returns a JSON object with status, token, and the payment link URL. ``` -------------------------------- ### List IyziLink Products Source: https://context7.com/iyzico/iyzipay-python/llms.txt Retrieves a paginated list of IyziLink products. ```APIDOC ## List IyziLink Products ### Description Retrieves a paginated list of IyziLink products, allowing for fetching products in batches. ### Method ```python get(request, options) ``` ### Parameters #### Request Body - **page** (integer) - Optional - The page number to retrieve. - **count** (integer) - Optional - The number of items per page. ### Request Example ```python list_request = {'page': 1, 'count': 10} product_list = iyzipay.IyziLinkProduct().get(list_request, options) ``` ### Response #### Success Response Returns a JSON object containing a list of products and pagination information. ```