diff --git a/iyzipay.postman_collection b/iyzipay.postman_collection index 2cc8d1a..d71eafd 100644 --- a/iyzipay.postman_collection +++ b/iyzipay.postman_collection @@ -12496,6 +12496,575 @@ "description": "https://sandbox-api.iyzipay.com/reporting/settlement/bounced" }, "response": [] + }, + { + "name": "Pre Auth (Authorization)", + "event": [ + { + "listen": "prerequest", + "script": { + "id": "cde588a9-38cc-4dba-9195-f6d252c798a5", + "exec": [ + "var apiKey = globals.apiKey", + "var secretKey = globals.secretKey", + "", + "// //import crypto-js sha1", + "// $.getScript(\"https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/sha1.min.js\",", + "// function()", + "// {});", + "// //import crypto-js base64", + "// $.getScript(\"https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/enc-base64.min.js\",", + "// function()", + "// {});", + "", + "var approval = {", + " locale: null,", + " conversationId: null,", + " paymentTransactionId: null", + "};", + "", + "var subMerchant = {", + " locale: null,", + " conversationId: null,", + " name: null,", + " email: null,", + " gsmNumber: null,", + " address: null,", + " iban: null,", + " taxOffice: null,", + " contactName: null,", + " contactSurname: null,", + " legalCompanyTitle: null,", + " swiftCode: null,", + " currency: null,", + " subMerchantKey: null,", + " subMerchantExternalId: null,", + " identityNumber: null,", + " taxNumber: null,", + " subMerchantType: null,", + " ", + "};", + "", + "var binNumber = {", + " locale:null,", + " conversationId:null,", + " binNumber:null,", + "};", + "", + "var cancel = {", + " locale: null,", + " conversationId: null,", + " paymentId: null,", + " ip: null", + "};", + "", + "var refund = {", + " locale: null,", + " conversationId: null,", + " paymentTransactionId: null,", + " price: null,", + " ip: null,", + " currency: null", + "};", + "", + "var installment = {", + " locale:null,", + " conversationId:null,", + " binNumber:null,", + "};", + "", + "var paymentResult = {", + " locale:null,", + " conversationId:null,", + " paymentId: null,", + " paymentConversationId:null", + "};", + "", + "var createThreeds = {", + " locale:null,", + " conversationId:null,", + " paymentId: null,", + " ConversationData:null", + "};", + "", + "var paymentCard = {", + " cardHolderName: null,", + " cardNumber: null,", + " expireYear: null,", + " expireMonth: null,", + " cvc: null,", + " registerCard: null,", + " cardAlias: null,", + " cardToken: null,", + " cardUserKey: null", + "};", + "", + "var cardInformation = {", + " cardAlias: null,", + " cardNumber: null,", + " expireYear: null,", + " expireMonth: null,", + "};", + "", + "var buyer = {", + " id: null,", + " name: null,", + " surname: null,", + " identityNumber: null,", + " email: null,", + " gsmNumber: null,", + " registrationDate: null,", + " lastLoginDate: null,", + " registrationAddress: null,", + " city: null,", + " country: null,", + " zipCode: null,", + " ip: null", + "};", + "", + "var shippingAddress = {", + " address: null,", + " zipCode: null,", + " contactName: null,", + " city: null,", + " country: null", + "};", + "", + "var billingAddress = {", + " address: null,", + " zipCode: null,", + " contactName: null,", + " city: null,", + " country: null", + "};", + "", + "var basketItem = {", + " id: null,", + " price: null,", + " name: null,", + " category1: null,", + " category2: null,", + " itemType: null,", + " subMerchantKey:null,", + " subMerchantPrice: null", + "};", + "", + "function BasketItem() {", + " this.id= null;", + " this.price= null;", + " this.name=null;", + " this.category1= null;", + " this.category2= null;", + " this.itemType=null,", + " this.subMerchantKey=null;", + " this.subMerchantPrice= null;", + "}", + "", + "var basketItems = [];", + "var enabledInstallments = [];", + "", + "var payment = {", + " locale: null,", + " conversationId: null,", + " price: null,", + " paidPrice: null,", + " installment: null,", + " paymentChannel: null,", + " basketId: null,", + " paymentGroup: null,", + " paymentCard: paymentCard,", + " buyer: buyer,", + " shippingAddress: shippingAddress,", + " billingAddress: billingAddress,", + " basketItems: basketItems,", + " currency: null,", + " ", + "};", + "", + "var initializeBkm = {", + " locale: null,", + " conversationId: null,", + " price: null,", + " basketId: null,", + " paymentGroup: null,", + " buyer: buyer,", + " shippingAddress: shippingAddress,", + " billingAddress: billingAddress,", + " basketItems: basketItems,", + " callbackUrl:null,", + " paymentSource:null,", + " enabledInstallments:enabledInstallments", + " ", + "};", + "", + "var initializeCheckout = {", + " locale: null,", + " conversationId: null,", + " price: null,", + " installment: null,", + " paymentChannel: null,", + " basketId: null,", + " paymentGroup: null,", + " paymentCard: paymentCard,", + " buyer: buyer,", + " shippingAddress: shippingAddress,", + " billingAddress: billingAddress,", + " basketItems: basketItems,", + " callbackUrl:null,", + " paymentSource:null,", + " currency: null,", + " paidPrice: null,", + " forceThreeDS:null,", + " cardUserKey: null,", + " enabledInstallments:enabledInstallments", + "};", + "", + "var checkoutForm = {", + " locale: null,", + " conversationId: null,", + " token: null,", + "};", + "", + "var bkm = {", + " locale: null,", + " conversationId: null,", + " token: null,", + "};", + "", + "var card = {", + " locale:null,", + " conversationId:null,", + " externalId: null,", + " email: null,", + " cardUserKey: null,", + " card: cardInformation", + "};", + "", + "function nullClear(obj){", + " for (var member in obj) {", + " ", + " if(obj[member] === null) { ", + " delete obj[member];", + " }", + " else if (typeof obj[member] === 'object'){", + " obj[member]=nullClear(obj[member]);", + " if(Object.keys(obj[member]).length===0){", + " delete obj[member];", + " }", + " }", + " }", + " ", + " return obj;", + "}", + "", + "//Set json string to model", + "function jsonToObj(jsonString, obj) {", + " var parsedJsonString = JSON.parse(jsonString)", + " for(var key in parsedJsonString) {", + " if(parsedJsonString.hasOwnProperty(key)) {", + " if (typeof parsedJsonString[key] === 'object') {", + " if(Array.isArray(parsedJsonString[key])){", + " for(var i = 0; i < parsedJsonString[key].length; i++){", + " if(key ==\"basketItems\"){", + " obj[key].push(new BasketItem());", + " obj[key][i]=jsonToObj(JSON.stringify(parsedJsonString[key][i]), obj[key][i])", + " }else {", + " obj[key][i] = parsedJsonString[key][i];", + " }", + " }", + " }else{", + " obj[key] = jsonToObj(JSON.stringify(parsedJsonString[key]), obj[key])", + " }", + " }else{", + " obj[key] = parsedJsonString[key];", + " }", + " ", + " }", + " }", + " obj = nullClear(obj);", + " ", + " return obj;", + "}", + "", + "//generate pki string of object", + "function generateRequestString(obj) {", + " var isArray = Array.isArray(obj);", + " ", + " var requestString = '[';", + " for (var i in obj) {", + " var val = obj[i];", + " if (!isArray) {", + " requestString += i + '=';", + " }", + " if (typeof val === 'object') {", + " requestString += generateRequestString(val);", + " } else {", + " requestString += val;", + " }", + " requestString += isArray ? ', ' : ',';", + " }", + " requestString = requestString.slice(0, (isArray ? -2 : -1));", + " requestString += ']';", + " return requestString;", + " ", + "} ", + "", + "//generate authorization string", + "function generateAuthorizationString(obj) {", + " var requestString = generateRequestString(obj);", + " var hashSha1 = CryptoJS.SHA1(apiKey+request.headers[\"x-iyzi-rnd\"]+secretKey+requestString);", + " var hashInBase64 = CryptoJS.enc.Base64.stringify(hashSha1);", + " var authorization = \"IYZWS\"+\" \"+apiKey+\":\"+hashInBase64;", + " console.log(requestString);", + " postman.setGlobalVariable(\"pkiString\", apiKey+request.headers[\"x-iyzi-rnd\"]+secretKey+requestString);", + " return authorization", + "}", + "", + "var requestModel = payment;", + "requestModel = jsonToObj(request.data, requestModel);", + "var authorization = generateAuthorizationString(requestModel)", + "postman.setGlobalVariable(\"authorization\", authorization);", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "test", + "script": { + "id": "d06366fd-94da-4523-a51b-b1f05d57d3fd", + "exec": [ + "var jsonData = JSON.parse(responseBody);", + "tests[\"response status \" + jsonData.status ] = jsonData.status === \"success\"", + "", + "tests[\"pki string: \" + globals.pkiString ] = true", + "tests[\"authorization: \" + globals.authorization ] = true", + "tests[\"json: \" + request.data ] = true", + "", + "", + "", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Authorization", + "value": "{{authorization}}", + "type": "text" + }, + { + "key": "x-iyzi-rnd", + "value": "123456789", + "type": "text" + }, + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"locale\": \"en\",\n \"conversationId\": \"123456789\",\n \"price\": \"1.0\",\n \"paidPrice\": \"1.1\",\n \"installment\": 1,\n \"paymentChannel\": \"WEB\",\n \"basketId\": \"B67832\",\n \"paymentGroup\": \"PRODUCT\",\n \"paymentCard\": {\n \"cardHolderName\": \"John Doe\",\n \"cardNumber\": \"5311570000000005\",\n \"expireYear\": \"2030\",\n \"expireMonth\": \"12\",\n \"cvc\": \"123\",\n \"registerCard\": 0\n },\n \"buyer\": {\n \"id\": \"BY789\",\n \"name\": \"John\",\n \"surname\": \"Doe\",\n \"identityNumber\": \"74300864791\",\n \"email\": \"email@email.com\",\n \"gsmNumber\": \"+905350000000\",\n \"registrationDate\": \"2013-04-21 15:12:09\",\n \"lastLoginDate\": \"2015-10-05 12:43:35\",\n \"registrationAddress\": \"Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1\",\n \"city\": \"Istanbul\",\n \"country\": \"Turkey\",\n \"zipCode\": \"34732\",\n \"ip\": \"85.34.78.112\"\n },\n \"shippingAddress\": {\n \"address\": \"Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1\",\n \"zipCode\": \"34742\",\n \"contactName\": \"Jane Doe\",\n \"city\": \"Istanbul\",\n \"country\": \"Turkey\"\n },\n \"billingAddress\": {\n \"address\": \"Nidakule Göztepe, Merdivenköy Mah. Bora Sok. No:1\",\n \n \"contactName\": \"Jane Doe\",\n \"city\": \"Istanbul\",\n \"country\": \"Turkey\"\n },\n \"basketItems\": [\n {\n \"id\": \"BI101\",\n \"price\": \"0.3\",\n \"name\": \"Binocular\",\n \"category1\": \"Collectibles\",\n \"category2\": \"Accessories\",\n \"itemType\": \"PHYSICAL\"\n },\n {\n \"id\": \"BI102\",\n \"price\": \"0.5\",\n \"name\": \"Game code\",\n \"category1\": \"Game\",\n \"category2\": \"Online Game Items\",\n \"itemType\": \"VIRTUAL\"\n },\n {\n \"id\": \"BI103\",\n \"price\": \"0.2\",\n \"name\": \"Usb\",\n \"category1\": \"Electronics\",\n \"category2\": \"Usb / Cable\",\n \"itemType\": \"PHYSICAL\"\n }\n ],\n \"currency\": \"TRY\"\n}" + }, + "url": { + "raw": "https://sandbox-api.iyzipay.com/payment/preauth", + "protocol": "https", + "host": [ + "sandbox-api", + "iyzipay", + "com" + ], + "path": [ + "payment", + "preauth" + ] + } + }, + "response": [] + }, + { + "name": "Post Auth (Capture)", + "event": [ + { + "listen": "prerequest", + "script": { + "id": "523728b7-593b-4498-b66b-2ccf2ee3d13c", + "exec": [ + "var apiKey = globals.apiKey", + "var secretKey = globals.secretKey", + "", + "// //import crypto-js sha1", + "// $.getScript(\"https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/sha1.min.js\",", + "// function()", + "// {});", + "// //import crypto-js base64", + "// $.getScript(\"https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/enc-base64.min.js\",", + "// function()", + "// {});", + "", + "var postAuth = {", + " locale:null,", + " conversationId:null,", + " paymentId:null, ", + " ip: null,", + " paidPrice: null,", + " currency:null", + "}", + "", + "function nullClear(obj){", + " for (var member in obj) {", + " ", + " if(obj[member] === null) { ", + " delete obj[member];", + " }", + " else if (typeof obj[member] === 'object'){", + " obj[member]=nullClear(obj[member]);", + " if(Object.keys(obj[member]).length===0){", + " delete obj[member];", + " }", + " }", + " }", + " ", + " return obj;", + "}", + "", + "//Set json string to model", + "function jsonToObj(jsonString, obj) {", + " var parsedJsonString = JSON.parse(jsonString)", + " for(var key in parsedJsonString) {", + " if(parsedJsonString.hasOwnProperty(key)) {", + " if (typeof parsedJsonString[key] === 'object') {", + " if(Array.isArray(parsedJsonString[key])){", + " for(var i = 0; i < parsedJsonString[key].length; i++){", + " if(key ==\"basketItems\"){", + " obj[key].push(new BasketItem());", + " obj[key][i]=jsonToObj(JSON.stringify(parsedJsonString[key][i]), obj[key][i])", + " }else {", + " obj[key][i] = parsedJsonString[key][i];", + " }", + " }", + " }else{", + " obj[key] = jsonToObj(JSON.stringify(parsedJsonString[key]), obj[key])", + " }", + " }else{", + " obj[key] = parsedJsonString[key];", + " }", + " ", + " }", + " }", + " obj = nullClear(obj);", + " ", + " return obj;", + "}", + "", + "//generate pki string of object", + "function generateRequestString(obj) {", + " var isArray = Array.isArray(obj);", + " ", + " var requestString = '[';", + " for (var i in obj) {", + " var val = obj[i];", + " if (!isArray) {", + " requestString += i + '=';", + " }", + " if (typeof val === 'object') {", + " requestString += generateRequestString(val);", + " } else {", + " requestString += val;", + " }", + " requestString += isArray ? ', ' : ',';", + " }", + " requestString = requestString.slice(0, (isArray ? -2 : -1));", + " requestString += ']';", + " return requestString;", + " ", + "} ", + "", + "//generate authorization string", + "function generateAuthorizationString(obj) {", + " var requestString = generateRequestString(obj);", + " var hashSha1 = CryptoJS.SHA1(apiKey+request.headers[\"x-iyzi-rnd\"]+secretKey+requestString);", + " var hashInBase64 = CryptoJS.enc.Base64.stringify(hashSha1);", + " var authorization = \"IYZWS\"+\" \"+apiKey+\":\"+hashInBase64;", + " console.log(requestString);", + " postman.setGlobalVariable(\"pkiString\", apiKey+request.headers[\"x-iyzi-rnd\"]+secretKey+requestString);", + " return authorization", + "}", + "", + "var requestModel = postAuth;", + "requestModel = jsonToObj(request.data, requestModel);", + "var authorization = generateAuthorizationString(requestModel)", + "postman.setGlobalVariable(\"authorization\", authorization);", + "" + ], + "type": "text/javascript" + } + }, + { + "listen": "test", + "script": { + "id": "bacb1c30-2b40-4040-8ce5-477aae0d11b0", + "exec": [ + "var jsonData = JSON.parse(responseBody);", + "tests[\"response status \" + jsonData.status ] = jsonData.status === \"success\"", + "", + "tests[\"pki string: \" + globals.pkiString ] = true", + "tests[\"authorization: \" + globals.authorization ] = true", + "tests[\"json: \" + request.data ] = true", + "", + "", + "", + "" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Authorization", + "value": "{{authorization}}", + "type": "text" + }, + { + "key": "x-iyzi-rnd", + "value": "123456789", + "type": "text" + }, + { + "key": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"locale\": \"en\",\n \"conversationId\": \"1234567891\",\n \"paymentId\": \"12356932\",\n \"ip\": \"212.64.200.32\",\n \"paidPrice\": \"5.0\",\n \"currency\": \"TRY\"\n}" + }, + "url": { + "raw": "https://sandbox-api.iyzipay.com//payment/postauth", + "protocol": "https", + "host": [ + "sandbox-api", + "iyzipay", + "com" + ], + "path": [ + "", + "payment", + "postauth" + ] + } + }, + "response": [] } ] }