# PWI-Initialize

After making the request mentioned below, you will receive the payWithIyzicoPageUrl value, which is a unique page where your customers will be directed to Pay with iyzico. Your customers will be automatically redirected to the callBackUrl you specified in the Pay-with-iyzico init request after completing the payment process.

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

{% hint style="info" %}
callBackUrl address should have SSL.
{% endhint %}

By incorporating these features, you can provide a seamless payment experience for your customers, with real-time feedback on the success or failure of their transactions.

## Pay with iyzico (PWI) — Initialize

> Starts a PWI session; returns the token and page URL for redirection.

```json
{"openapi":"3.0.3","info":{"title":"Pay with iyzico (PWI)","version":"1.0.0"},"servers":[{"url":"https://api.iyzipay.com","description":"iyzico API"}],"paths":{"/payment/pay-with-iyzico/initialize":{"post":{"summary":"Pay with iyzico (PWI) — Initialize","description":"Starts a PWI session; returns the token and page URL for redirection.","tags":["Pay with iyzico"],"parameters":[{"$ref":"#/components/parameters/AuthHeader"},{"$ref":"#/components/parameters/ContentTypeHeader"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PwiInitializeRequest"}}}},"responses":{"200":{"description":"Successful response (PWI initialized)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PwiInitializeResponse"}}}},"400":{"description":"Bad request / validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}},"components":{"parameters":{"AuthHeader":{"name":"Authorization","in":"header","required":true,"description":"Authorization header; starts with IYZWSv2 and is a signed hash in Base64.","schema":{"type":"string"}},"ContentTypeHeader":{"name":"Content-Type","in":"header","required":true,"schema":{"type":"string"}}},"schemas":{"PwiInitializeRequest":{"type":"object","required":["price","basketId","callbackUrl","currency","paidPrice","buyer","billingAddress","shippingAddress","basketItems"],"properties":{"locale":{"type":"string","enum":["tr","en"],"description":"Language code. Default; tr"},"conversationId":{"type":"string","description":"Request/response correlation ID."},"price":{"type":"decimal","description":"Basket total amount."},"basketId":{"type":"string","description":"Basket ID."},"paymentGroup":{"type":"string","enum":["PRODUCT","LISTING","SUBSCRIPTION"],"description":"Payment group."},"callbackUrl":{"type":"string","description":"URL to redirect after the transaction."},"currency":{"type":"string","enum":["TRY","USD","EUR","GBP","NOK","CHF"],"description":"Currency. Default; TRY."},"paidPrice":{"type":"decimal","description":"Amount to be collected."},"paymentChannel":{"type":"string","enum":["WEB","MOBILE","MOBILE_WEB","MOBILE_IOS","MOBILE_ANDROID","MOBILE_WINDOWS","MOBILE_TABLET","MOBILE_PHONE"],"description":"Payment channel."},"enabledInstallments":{"type":"array","items":{"type":"integer","enum":[1,2,3,6,9,12]},"description":"Installment options to offer."},"buyer":{"$ref":"#/components/schemas/PwiBuyer"},"shippingAddress":{"$ref":"#/components/schemas/PwiAddress","description":"Shipping Address. Required if at least one basket item is PHYSICAL. If all items are VIRTUAL, this is not required."},"billingAddress":{"$ref":"#/components/schemas/PwiAddress"},"basketItems":{"type":"array","description":"Basket items.","minItems":1,"items":{"$ref":"#/components/schemas/PwiBasketItem"}}}},"PwiBuyer":{"type":"object","description":"Buyer information","required":["id","name","surname","identityNumber","email","gsmNumber","registrationAddress","city","country","ip"],"properties":{"id":{"type":"string","description":"Customer ID."},"name":{"type":"string","description":"First name."},"surname":{"type":"string","description":"Last name."},"identityNumber":{"type":"string","description":"National ID number (e.g., TR ID)."},"email":{"type":"string","description":"Email address."},"gsmNumber":{"type":"string","description":"Mobile phone number."},"registrationAddress":{"type":"string","description":"Registered address."},"city":{"type":"string","description":"City."},"country":{"type":"string","description":"Country."},"ip":{"type":"string","description":"IP address."},"zipCode":{"type":"string","description":"Postal code."},"registrationDate":{"type":"string","description":"Registration date (YYYY-MM-DD hh:mm:ss)."},"lastLoginDate":{"type":"string","description":"Last login date (YYYY-MM-DD hh:mm:ss)."}}},"PwiAddress":{"type":"object","description":"Address information","required":["address","contactName","city","country"],"properties":{"address":{"type":"string","description":"Address."},"contactName":{"type":"string","description":"Contact name."},"city":{"type":"string","description":"City."},"country":{"type":"string","description":"Country."},"zipCode":{"type":"string","description":"Postal code."}}},"PwiBasketItem":{"type":"object","required":["id","price","name","category1","itemType"],"properties":{"id":{"type":"string","description":"Item ID."},"price":{"type":"decimal","description":"Item price."},"name":{"type":"string","description":"Item name."},"category1":{"type":"string","description":"Primary category."},"category2":{"type":"string","description":"Secondary category (optional)."},"itemType":{"type":"string","description":"Item type.","enum":["PHYSICAL","VIRTUAL"]},"subMerchantKey":{"type":"string","description":"Sub-merchant key of the service provider. Not used in the standard business model; required only in marketplace model."},"subMerchantPrice":{"type":"string","description":"Amount to be transferred to the sub-merchant. Not used in the standard business model; required only in marketplace model."}}},"PwiInitializeResponse":{"type":"object","properties":{"status":{"type":"string","description":"Outcome of the request.","enum":["success","failure"]},"locale":{"type":"string","description":"Response language.","enum":["tr","en"]},"systemTime":{"type":"integer","description":"Timestamp (epoch ms)."},"conversationId":{"type":"string","description":"Correlation ID of the request."},"token":{"type":"string","description":"Token generated for Pay with iyzico. Returned per request and required to retrieve the result."},"tokenExpireTime":{"type":"integer","description":"Token validity in seconds; 1800 seconds."},"payWithIyzicoPageUrl":{"type":"string","description":"Payment page URL to redirect to."},"signature":{"type":"string","description":"Response signature (hash)."}}},"ErrorResponse":{"type":"object","properties":{"status":{"type":"string","description":"Success/failure indicator."},"errorCode":{"type":"string","description":"Error code."},"errorMessage":{"type":"string","description":"Error message."},"locale":{"type":"string","description":"Response language.","enum":["tr","en"]},"systemTime":{"type":"integer","description":"Timestamp (epoch ms)."},"conversationId":{"type":"string","description":"Correlation ID of the request."}}}}}}
```

#### Sample Codes

<table data-view="cards"><thead><tr><th></th></tr></thead><tbody><tr><td><a href="https://github.com/iyzico/iyzipay-php/blob/master/samples/initialize_pay_with_iyzico.php">PHP</a></td></tr><tr><td><a href="https://github.com/iyzico/iyzipay-java/blob/master/src/test/java/com/iyzipay/sample/PayWithIyzicoSample.java#L15">Java</a></td></tr><tr><td><a href="https://github.com/iyzico/iyzipay-dotnet/blob/master/Iyzipay.Samples/PayWithIyzicoSample.cs#L13">.Net</a></td></tr><tr><td><a href="https://www.postman.com/iyzico/iyzico/request/0xu3ijm/1-pay-with-iyzico-initialize">Postman</a></td></tr></tbody></table>
