Skip to content

Commit

Permalink
v1 header düzenlemeleri
Browse files Browse the repository at this point in the history
  • Loading branch information
eyupbasefy committed Aug 28, 2024
1 parent 9cf7bd3 commit 334da15
Show file tree
Hide file tree
Showing 39 changed files with 468 additions and 15 deletions.
18 changes: 13 additions & 5 deletions Iyzipay/BaseRequestV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,17 @@

namespace Iyzipay
{
public class BaseRequestV2
{
public String Locale { get; set; }
public String ConversationId { get; set; }
}
public class BaseRequestV2 : RequestStringConvertible
{
public string Locale { get; set; }
public string ConversationId { get; set; }

public virtual string ToPKIRequestString()
{
return ToStringRequestBuilder.NewInstance()
.Append("locale", Locale)
.Append("conversationId", ConversationId)
.GetRequestString();
}
}
}
7 changes: 7 additions & 0 deletions Iyzipay/HashGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,12 @@ public static String GenerateHash(String apiKey, String secretKey, String random
byte[] computeHash = algorithm.ComputeHash(Encoding.UTF8.GetBytes(hashStr));
return Convert.ToBase64String(computeHash);
}
public static String GenerateHash(String apiKey, String secretKey, String randomString, BaseRequestV2 request)
{
HashAlgorithm algorithm = new SHA1Managed();
string hashStr = apiKey + randomString + secretKey + request.ToPKIRequestString();
byte[] computeHash = algorithm.ComputeHash(Encoding.UTF8.GetBytes(hashStr));
return Convert.ToBase64String(computeHash);
}
}
}
20 changes: 13 additions & 7 deletions Iyzipay/IyzipayResourceV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ namespace Iyzipay
{
public class IyzipayResourceV2
{
private static readonly String AUTHORIZATION = "Authorization";
private static readonly String AUTHORIZATION_FALLBACK_HEADER = "AUTHORIZATION_FALLBACK_HEADER";
private static readonly String CONVERSATION_ID_HEADER_NAME = "x-conversation-id";
private static readonly String CLIENT_VERSION_HEADER_NAME = "x-iyzi-client-version";
private static readonly String IYZIWS_V2_HEADER_NAME = "IYZWSv2 ";
private static readonly string AUTHORIZATION = "Authorization";
private static readonly string AUTHORIZATION_FALLBACK_HEADER = "AUTHORIZATION_FALLBACK_HEADER";
private static readonly string CONVERSATION_ID_HEADER_NAME = "x-conversation-id";
private static readonly string CLIENT_VERSION_HEADER_NAME = "x-iyzi-client-version";
private static readonly string IYZIWS_V2_HEADER_NAME = "IYZWSv2 ";
private static readonly string IYZIWS_HEADER_NAME = "IYZWS ";
private static readonly string COLON = ":";

public String Status { get; set; }
public int StatusCode { get; set; }
Expand Down Expand Up @@ -43,7 +45,7 @@ protected static Dictionary<string, string> GetHttpHeadersWithRequestBody(BaseRe
{
Dictionary<string, string> headers = GetCommonHttpHeaders(request, url, options);
headers.Add(AUTHORIZATION, PrepareAuthorizationStringWithRequestBody(request, url, options));
headers.Add(AUTHORIZATION_FALLBACK_HEADER, PrepareAuthorizationStringWithRequestBody(request, url, options));
headers.Add(AUTHORIZATION_FALLBACK_HEADER, PrepareAuthorizationString(request, url, options));
return headers;
}

Expand Down Expand Up @@ -83,7 +85,11 @@ private static String PrepareAuthorizationStringWithUrlParam(BaseRequestV2 reque
String hash = HashGeneratorV2.GenerateHash(options.ApiKey, options.SecretKey, randomKey, dataToEncrypt);
return IYZIWS_V2_HEADER_NAME + hash;
}

private static string PrepareAuthorizationString(BaseRequestV2 request, string randomString, Options options)
{
string hash = HashGenerator.GenerateHash(options.ApiKey, options.SecretKey, randomString, request);
return IYZIWS_HEADER_NAME + options.ApiKey + COLON + hash;
}
private static String GenerateRandomKey()
{
return DateTime.Now.ToString("ddMMyyyyhhmmssffff");
Expand Down
10 changes: 10 additions & 0 deletions Iyzipay/Request/CreateAmountBasedRefundRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,15 @@ public class CreateAmountBasedRefundRequest : BaseRequestV2
public string PaymentId { get; set; }
public string Price { get; set; }
public string Ip { get; set; }

public override string ToPKIRequestString()
{
return ToStringRequestBuilder.NewInstance()
.AppendSuper(base.ToPKIRequestString())
.Append("paymentId", PaymentId)
.AppendPrice("price", Price)
.Append("ip", Ip)
.GetRequestString();
}
}
}
25 changes: 25 additions & 0 deletions Iyzipay/Request/CreateApmInitializeRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,30 @@ public class CreateApmInitializeRequest : BaseRequestV2
public Address ShippingAddress { get; set; }
public Address BillingAddress { get; set; }
public List<BasketItem> BasketItems { get; set; }

public override string ToPKIRequestString()
{
return ToStringRequestBuilder.NewInstance()
.AppendSuper(base.ToPKIRequestString())
.AppendPrice("price", Price)
.AppendPrice("paidPrice", PaidPrice)
.Append("paymentChannel", PaymentChannel)
.Append("paymentGroup", PaymentGroup)
.Append("paymentSource", PaymentSource)
.Append("currency", Currency)
.Append("merchantOrderId", MerchantOrderId)
.Append("countryCode", CountryCode)
.Append("accountHolderName", AccountHolderName)
.Append("merchantCallbackUrl", MerchantCallbackUrl)
.Append("merchantErrorUrl", MerchantErrorUrl)
.Append("merchantNotificationUrl", MerchantNotificationUrl)
.Append("apmType", ApmType)
.Append("basketId", BasketId)
.Append("buyer", Buyer)
.Append("shippingAddress", ShippingAddress)
.Append("billingAddress", BillingAddress)
.AppendList("basketItems", BasketItems)
.GetRequestString();
}
}
}
8 changes: 8 additions & 0 deletions Iyzipay/Request/CreateApprovalRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,13 @@ namespace Iyzipay.Request
public class CreateApprovalRequest : BaseRequestV2
{
public string PaymentTransactionId { get; set; }

public override string ToPKIRequestString()
{
return ToStringRequestBuilder.NewInstance()
.AppendSuper(base.ToPKIRequestString())
.Append("paymentTransactionId", PaymentTransactionId)
.GetRequestString();
}
}
}
17 changes: 16 additions & 1 deletion Iyzipay/Request/CreateBasicBkmInitializeRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,21 @@ public class CreateBasicBkmInitializeRequest : BaseRequestV2
public string BuyerIp { get; set; }
public string PosOrderId { get; set; }
public List<BkmInstallment> InstallmentDetails { get; set; }



public override string ToPKIRequestString()
{
return ToStringRequestBuilder.NewInstance()
.AppendSuper(base.ToPKIRequestString())
.Append("connectorName", ConnectorName)
.AppendPrice("price", Price)
.Append("callbackUrl", CallbackUrl)
.Append("buyerEmail", BuyerEmail)
.Append("buyerId", BuyerId)
.Append("buyerIp", BuyerIp)
.Append("posOrderId", PosOrderId)
.AppendList("installmentDetails", InstallmentDetails)
.GetRequestString();
}
}
}
18 changes: 18 additions & 0 deletions Iyzipay/Request/CreateBasicPaymentRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,23 @@ public CreateBasicPaymentRequest()
{
this.Installment = SINGLE_INSTALLMENT;
}

public override string ToPKIRequestString()
{
return ToStringRequestBuilder.NewInstance()
.AppendSuper(base.ToPKIRequestString())
.AppendPrice("price", Price)
.AppendPrice("paidPrice", PaidPrice)
.Append("installment", Installment)
.Append("buyerEmail", BuyerEmail)
.Append("buyerId", BuyerId)
.Append("buyerIp", BuyerIp)
.Append("posOrderId", PosOrderId)
.Append("paymentCard", PaymentCard)
.Append("currency", Currency)
.Append("connectorName", ConnectorName)
.Append("callbackUrl", CallbackUrl)
.GetRequestString();
}
}
}
17 changes: 17 additions & 0 deletions Iyzipay/Request/CreateBkmInitializeRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,22 @@ public class CreateBkmInitializeRequest : BaseRequestV2
public List<BasketItem> BasketItems { get; set; }
public string CallbackUrl { get; set; }
public List<int> EnabledInstallments { get; set; }

public override string ToPKIRequestString()
{
return ToStringRequestBuilder.NewInstance()
.AppendSuper(base.ToPKIRequestString())
.AppendPrice("price", Price)
.Append("basketId", BasketId)
.Append("paymentGroup", PaymentGroup)
.Append("buyer", Buyer)
.Append("shippingAddress", ShippingAddress)
.Append("billingAddress", BillingAddress)
.AppendList("basketItems", BasketItems)
.Append("callbackUrl", CallbackUrl)
.Append("paymentSource", PaymentSource)
.AppendList("enabledInstallments", EnabledInstallments)
.GetRequestString();
}
}
}
11 changes: 11 additions & 0 deletions Iyzipay/Request/CreateCancelRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,16 @@ public class CreateCancelRequest : BaseRequestV2
public string Reason { get; set; }
public string Description { get; set; }


public override string ToPKIRequestString()
{
return ToStringRequestBuilder.NewInstance()
.AppendSuper(base.ToPKIRequestString())
.Append("paymentId", PaymentId)
.Append("ip", Ip)
.Append("reason", Reason)
.Append("description", Description)
.GetRequestString();
}
}
}
9 changes: 9 additions & 0 deletions Iyzipay/Request/CreateCardBlacklistRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,14 @@ public class CreateCardBlacklistRequest : BaseRequestV2
{
public string CardToken { get; set; }
public string CardUserKey { get; set; }

public override string ToPKIRequestString()
{
return ToStringRequestBuilder.NewInstance()
.AppendSuper(base.ToPKIRequestString())
.Append("cardToken", CardToken)
.Append("cardUserKey", CardUserKey)
.GetRequestString();
}
}
}
14 changes: 14 additions & 0 deletions Iyzipay/Request/CreateCardManagementPageInitializeRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,19 @@ public class CreateCardManagementPageInitializeRequest : BaseRequestV2
public string CardUserKey { get; set; }
public string CallbackUrl { get; set; }
public bool DebitCardAllowed { get; set; }

public override string ToPKIRequestString()
{
return ToStringRequestBuilder.NewInstance()
.AppendSuper(base.ToPKIRequestString())
.Append("addNewCardEnabled", AddNewCardEnabled.ToString().ToLower())
.Append("validateNewCard", ValidateNewCard.ToString().ToLower())
.Append("externalId", ExternalId)
.Append("email", Email)
.Append("cardUserKey", CardUserKey)
.Append("callbackUrl", CallbackUrl)
.Append("debitCardAllowed", DebitCardAllowed.ToString().ToLower())
.GetRequestString();
}
}
}
11 changes: 11 additions & 0 deletions Iyzipay/Request/CreateCardRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,16 @@ public class CreateCardRequest : BaseRequestV2
public string Email { get; set; }
public string CardUserKey { get; set; }
public CardInformation Card { get; set; }

public override string ToPKIRequestString()
{
return ToStringRequestBuilder.NewInstance()
.AppendSuper(base.ToPKIRequestString())
.Append("externalId", ExternalId)
.Append("email", Email)
.Append("cardUserKey", CardUserKey)
.Append("card", Card)
.GetRequestString();
}
}
}
22 changes: 22 additions & 0 deletions Iyzipay/Request/CreateCheckoutFormInitializeRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,27 @@ public class CreateCheckoutFormInitializeRequest : BaseRequestV2
public string CardUserKey { get; set; }
public string PosOrderId { get; set; }
public List<int> EnabledInstallments { get; set; }

public override string ToPKIRequestString()
{
return ToStringRequestBuilder.NewInstance()
.AppendSuper(base.ToPKIRequestString())
.AppendPrice("price", Price)
.Append("basketId", BasketId)
.Append("paymentGroup", PaymentGroup)
.Append("buyer", Buyer)
.Append("shippingAddress", ShippingAddress)
.Append("billingAddress", BillingAddress)
.AppendList("basketItems", BasketItems)
.Append("callbackUrl", CallbackUrl)
.Append("paymentSource", PaymentSource)
.Append("currency", Currency)
.Append("posOrderId", PosOrderId)
.AppendPrice("paidPrice", PaidPrice)
.Append("forceThreeDS", ForceThreeDS)
.Append("cardUserKey", CardUserKey)
.AppendList("enabledInstallments", EnabledInstallments)
.GetRequestString();
}
}
}
11 changes: 11 additions & 0 deletions Iyzipay/Request/CreateCrossBookingRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,16 @@ public class CreateCrossBookingRequest : BaseRequestV2
public string Price { get; set; }
public string Reason { get; set; }
public string Currency { get; set; }

public override string ToPKIRequestString()
{
return ToStringRequestBuilder.NewInstance()
.AppendSuper(base.ToPKIRequestString())
.Append("subMerchantKey", SubMerchantKey)
.AppendPrice("price", Price)
.Append("reason", Reason)
.Append("currency", Currency)
.GetRequestString();
}
}
}
22 changes: 22 additions & 0 deletions Iyzipay/Request/CreatePayWithIyzicoInitializeRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,27 @@ public class CreatePayWithIyzicoInitializeRequest : BaseRequestV2
public string CardUserKey { get; set; }
public string PosOrderId { get; set; }
public List<int> EnabledInstallments { get; set; }

public override string ToPKIRequestString()
{
return ToStringRequestBuilder.NewInstance()
.AppendSuper(base.ToPKIRequestString())
.AppendPrice("price", Price)
.Append("basketId", BasketId)
.Append("paymentGroup", PaymentGroup)
.Append("buyer", Buyer)
.Append("shippingAddress", ShippingAddress)
.Append("billingAddress", BillingAddress)
.AppendList("basketItems", BasketItems)
.Append("callbackUrl", CallbackUrl)
.Append("paymentSource", PaymentSource)
.Append("currency", Currency)
.Append("posOrderId", PosOrderId)
.AppendPrice("paidPrice", PaidPrice)
.Append("forceThreeDS", ForceThreeDS)
.Append("cardUserKey", CardUserKey)
.AppendList("enabledInstallments", EnabledInstallments)
.GetRequestString();
}
}
}
12 changes: 12 additions & 0 deletions Iyzipay/Request/CreatePaymentPostAuthRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,17 @@ public class CreatePaymentPostAuthRequest : BaseRequestV2
public string PaidPrice { get; set; }
public string Ip { get; set; }
public string Currency { get; set; }


public override string ToPKIRequestString()
{
return ToStringRequestBuilder.NewInstance()
.AppendSuper(base.ToPKIRequestString())
.Append("paymentId", PaymentId)
.Append("ip", Ip)
.AppendPrice("paidPrice", PaidPrice)
.Append("currency", Currency)
.GetRequestString();
}
}
}
24 changes: 24 additions & 0 deletions Iyzipay/Request/CreatePaymentRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,29 @@ public class CreatePaymentRequest : BaseRequestV2
public LoyaltyReward Reward { get; set; }
public string GsmNumber { get; set; }


public override string ToPKIRequestString()
{
return ToStringRequestBuilder.NewInstance()
.AppendSuper(base.ToPKIRequestString())
.AppendPrice("price", Price)
.AppendPrice("paidPrice", PaidPrice)
.Append("installment", Installment)
.Append("paymentChannel", PaymentChannel)
.Append("basketId", BasketId)
.Append("paymentGroup", PaymentGroup)
.Append("paymentCard", PaymentCard)
.Append("buyer", Buyer)
.Append("shippingAddress", ShippingAddress)
.Append("billingAddress", BillingAddress)
.AppendList("basketItems", BasketItems)
.Append("paymentSource", PaymentSource)
.Append("currency", Currency)
.Append("posOrderId", PosOrderId)
.Append("connectorName", ConnectorName)
.Append("callbackUrl", CallbackUrl)
.Append("gsmNumber", GsmNumber)
.GetRequestString();
}
}
}
Loading

0 comments on commit 334da15

Please sign in to comment.