Initialize Pay with iyzico

The payWithIyzicoPageUrl value that you will receive as a result of the request mentioned as below is a unique page where your customers will be directed to pay with iyzico. Once your customer completes the payment process, he/she will automatically be directed to the callBackUrl you specified in the pay-with-iyzico init request.

You can show the generated link as a button / link / div on your payment page. The token you receive with the link can be stored at this stage or when it is posted to callBackUrl (if the customer continues the payment process). In addition, the generated link and token values are valid for 30 minutes. If no payment is received during this period, the token will expire.

The Buyer parameters must be the real name, surname, email, and gsmNumber. These values are important for both technical integration and your customers' experience on the checkout page. They are shown by default in the input fields on the "Pay with iyzico" page.

Pay with iyzico Customer Welcome Screen

The following screen is where your customer will be directed when they click on the link. After opening the pay with iyzico page, your customer can complete the payment process as they wish. It will be enough for Merchants to check the token which is sent to callBackUrl.

Request

Parameters to be sent to the service are as follows:

Input Name Type Mandatory Description
price Decimal Yes Total amount of basket. The sum of basket items’ amount must be equal to the price of basket
paidPrice Decimal Yes Final amount (including installment fee) that will be charged to customer’s card
currency String Yes Currency (default: TRY). Alternatively, you can set USD, EUR, GBP and IRR
callbackUrl String Yes Merchant callback URL for payment result notification
id(Buyer) String Yes ID of buyer.
name(Buyer) String Yes Name of buyer
surname(Buyer) String Yes Surname of buyer
identityNumber(Buyer) String Yes Identity number of buyer. TCKN for Turkish merchants, passport number for foreign merchants
city(Buyer) String Yes City of buyer
country(Buyer) String Yes Country of buyer
email(Buyer) String Yes Email of buyer
ip(Buyer) String Yes IP of buyer
registrationAddress(Buyer) String Yes Registration address of buyer
contactName(BillingAddress) String Yes Contact name of billing address
city(BillingAddress) String Yes City name of billing address
country(BillingAddress) String Yes Country name of billing address
address(BillingAddress) String Yes Address details of billing address
contactName(ShippingAddress) String Yes Contact name of shipping adress. If one of the itemType in basket is PHYSICAL, then this parameter will be mandatory
city(ShippingAddress) String Yes City name of shipping address. If one of the itemType in basket is PHYSICAL, then this parameter will be mandatory
country(ShippingAddress) String Yes Country name of shipping address. If one of the itemType in basket is PHYSICAL, then this parameter will be mandatory
address(ShippingAddress) String Yes Address details of shipping address. If one of the itemType in basket is PHYSICAL, then this parameter will be mandatory
id(BasketItems) String Yes Basket Item ID
itemType(BasketItems) String Yes Item Type. Valid values are PHYSICAL,VIRTUAL
price(BasketItems) Decimal Yes Price value for each item. Must be greater than zero
name(BasketItems) String Yes Name of the item in the basket
category1(BasketItems) String Yes Category 1 for item in the basket
enabledinstallments Integer No Enabled installments value. it should be set as 1
zipCode(Buyer) String No Zip code of buyer
zipCode(ShippingAddress) String No Zip code of shipping address
zipCode(BillingAddress) String No Zip code of billing address
category2(BasketItems) String No Category 2 for item in the basket
gsmNumber(Buyer) String No GSM number of buyer
subMerchantPrice(BasketItem) Decimal No Payout amount to subMerchant of each item. Must be greater than zero. Mandatory value for marketplace solution
subMerchantKey(BasketItem) String No Submerchant ID value. Mandatory value for marketplace solution
registerCard Integer No Parameter that shows card details will store or not. Default value is 0 and valid values are 0 or 1
cardAlias Integer No If registerCard value is 1 cardAlias can send within request.
registrationDate(Buyer) String No Registration date of buyer. Format should be “2015-09-17 23:45:06”
lastLoginDate(Buyer) String No Last login date of buyer. Format should be “2015-09-17 23:45:06”
locale String No Language (default: tr)
conversationId String No Conversation ID to match request and response
basketId String No Merchant's basket ID
paymentChannel String No Payment channel. Valid values are WEB, MOBILE, MOBILE_WEB, MOBILE_IOS, MOBILE_ANDROID, MOBILE_WINDOWS, MOBILE_TABLET, MOBILE_PHONE
paymentGroup String No Payment group (default: PRODUCT). Valid values are PRODUCT, LISTING, SUBSCRIPTION
paymentSource String No Payment source. Valid values are SHOPIFY, MAGENTO, PRESTASHOP, WOOCOMMERCE, OPENCART

 

Response

Parameters to be returned from the service are as follows:

Input Name Type Description
payWithIyzicoPageUrl String Unique link of pay with iyzico page. The end user should be directed to this page
token String Unique value created for each pay with iyzico request. This token is also used to access the payment result
tokenExpireTime Integer Expiration time of the token and pay with iyzico page
status String Service response result (success / failure)
errorCode String Error code if service response status is failure
errorMessage String Error message if service response status is failure
errorGroup String Error group if service response status is failure
locale String Language (default: tr)
systemTime Integer Response system timestamp value
conversationId String If set, conversation ID to match request and response

payWithIyzicoPageUrl value in the response should be used to access "pay with iyzico" page.

$request = new \Iyzipay\Request\CreatePayWithIyzicoInitializeRequest();
$request->setLocale(\Iyzipay\Model\Locale::TR);
$request->setConversationId("123456789");
$request->setPrice("1");
$request->setPaidPrice("1.2");
$request->setCurrency(\Iyzipay\Model\Currency::TL);
$request->setBasketId("B67832");
$request->setPaymentGroup(\Iyzipay\Model\PaymentGroup::PRODUCT);
$request->setCallbackUrl("https://www.merchant.com/callback");
$request->setEnabledInstallments(array(2, 3, 6, 9));
$buyer = new \Iyzipay\Model\Buyer();
$buyer->setId("BY789");
$buyer->setName("John");
$buyer->setSurname("Doe");
$buyer->setGsmNumber("+905350000000");
$buyer->setEmail("email@email.com");
$buyer->setIdentityNumber("74300864791");
$buyer->setLastLoginDate("2015-10-05 12:43:35");
$buyer->setRegistrationDate("2013-04-21 15:12:09");
$buyer->setRegistrationAddress("Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1");
$buyer->setIp("85.34.78.112");
$buyer->setCity("Istanbul");
$buyer->setCountry("Turkey");
$buyer->setZipCode("34732");
$request->setBuyer($buyer);
$shippingAddress = new \Iyzipay\Model\Address();
$shippingAddress->setContactName("Jane Doe");
$shippingAddress->setCity("Istanbul");
$shippingAddress->setCountry("Turkey");
$shippingAddress->setAddress("Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1");
$shippingAddress->setZipCode("34742");
$request->setShippingAddress($shippingAddress);
$billingAddress = new \Iyzipay\Model\Address();
$billingAddress->setContactName("Jane Doe");
$billingAddress->setCity("Istanbul");
$billingAddress->setCountry("Turkey");
$billingAddress->setAddress("Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1");
$billingAddress->setZipCode("34742");
$request->setBillingAddress($billingAddress);
$basketItems = array();
$firstBasketItem = new \Iyzipay\Model\BasketItem();
$firstBasketItem->setId("BI101");
$firstBasketItem->setName("Binocular");
$firstBasketItem->setCategory1("Collectibles");
$firstBasketItem->setCategory2("Accessories");
$firstBasketItem->setItemType(\Iyzipay\Model\BasketItemType::PHYSICAL);
$firstBasketItem->setPrice("0.3");
$basketItems[0] = $firstBasketItem;
$secondBasketItem = new \Iyzipay\Model\BasketItem();
$secondBasketItem->setId("BI102");
$secondBasketItem->setName("Game code");
$secondBasketItem->setCategory1("Game");
$secondBasketItem->setCategory2("Online Game Items");
$secondBasketItem->setItemType(\Iyzipay\Model\BasketItemType::VIRTUAL);
$secondBasketItem->setPrice("0.5");
$basketItems[1] = $secondBasketItem;
$thirdBasketItem = new \Iyzipay\Model\BasketItem();
$thirdBasketItem->setId("BI103");
$thirdBasketItem->setName("Usb");
$thirdBasketItem->setCategory1("Electronics");
$thirdBasketItem->setCategory2("Usb / Cable");
$thirdBasketItem->setItemType(\Iyzipay\Model\BasketItemType::PHYSICAL);
$thirdBasketItem->setPrice("0.2");
$basketItems[2] = $thirdBasketItem;
$request->setBasketItems($basketItems);
# make request
$payWithIyzicoInitialize = \Iyzipay\Model\PayWithIyzicoInitialize::create($request, Config::options());
//Request
{
    "locale": "tr",
    "conversationId": "123456789",
    "price": "1.0",
    "basketId": "MAC",
    "paymentGroup": "PRODUCT",
    "buyer": {
        "id": "BY789",
        "name": "John",
        "surname": "Doe",
        "identityNumber": "74300864791",
        "email": "email@email.com",
        "gsmNumber": "+905350000000",
        "registrationDate": "2013-04-21 15:12:09",
        "lastLoginDate": "2015-10-05 12:43:35",
        "registrationAddress": "Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1",
        "city": "Istanbul",
        "country": "Turkey",
        "zipCode": "34732",
        "ip": "85.34.78.112"
    },
    "shippingAddress": {
        "address": "Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1",
        "zipCode": "34742",
        "contactName": "Jane Doe",
        "city": "Istanbul",
        "country": "Turkey"
    },
    "billingAddress": {
        "address": "Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1",
        "zipCode": "34742",
        "contactName": "Jane Doe",
        "city": "Istanbul",
        "country": "Turkey"
    },
    "basketItems": [
        {
            "id": "BI101",
            "price": "0.3",
            "name": "Binocular",
            "category1": "Collectibles",
            "category2": "Accessories",
            "itemType": "PHYSICAL"
        },
        {
            "id": "BI102",
            "price": "0.5",
            "name": "Game code",
            "category1": "Game",
            "category2": "Online Game Items",
            "itemType": "VIRTUAL"
        },
        {
            "id": "BI103",
            "name": "Usb",
            "price": "0.2",
            "category1": "Electronics",
            "category2": "Usb / Cable",
            "itemType": "PHYSICAL"
        }
    ],

    "callbackUrl": "https://merchantwebsite.com",
    "currency": "TRY",
    "paidPrice": "1.2"
}

//Response
{
    "status": "success",
    "locale": "tr",
    "systemTime": 1570477711152,
    "conversationId": "123456789",
    "token": "15327f52-e048-4z09-9928-4g083dfdf25c",
    "tokenExpireTime": 1800,
    "payWithIyzicoPageUrl": "https://sandbox-consumer.iyzico.com/checkout?token=15327f52-e048-4z09-9928-4g083dfdf25c&lang=tr"
}

Sample Code

NOTE: If you need any assistance please send an email to integration@iyzico.com