-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds checkoutform loyalty inquire (#124)
- Loading branch information
Showing
7 changed files
with
276 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using Iyzipay.Model; | ||
using Iyzipay.Request; | ||
using NUnit.Framework; | ||
using System.Collections.Generic; | ||
|
||
namespace Iyzipay.Samples | ||
{ | ||
public class LoyaltyInquirySample : Sample | ||
{ | ||
[Test] | ||
public void Should_Inquire_Loyalty() | ||
{ | ||
LoyaltyInquiryRequest request = new LoyaltyInquiryRequest(); | ||
LoyaltyPaymentCard loyaltyPaymentCard = new LoyaltyPaymentCard(); | ||
loyaltyPaymentCard.CardHolderName = "John Doe"; | ||
loyaltyPaymentCard.CardNumber = "5528790000000008"; | ||
loyaltyPaymentCard.ExpireYear = "2030"; | ||
loyaltyPaymentCard.ExpireMonth = "12"; | ||
loyaltyPaymentCard.Cvc = "123"; | ||
loyaltyPaymentCard.CardUserKey = "card user key"; | ||
loyaltyPaymentCard.CardToken = "card token"; | ||
|
||
request.ConversationId = "123456789"; | ||
request.PaymentCard = loyaltyPaymentCard; | ||
request.Currency = "TRY"; | ||
|
||
LoyaltyInquiry loyaltyInquiry = LoyaltyInquiry.Create(request, options); | ||
|
||
PrintResponse<LoyaltyInquiry>(loyaltyInquiry); | ||
|
||
Assert.AreEqual(Status.SUCCESS.ToString(), loyaltyInquiry.Status); | ||
Assert.AreEqual(Locale.TR.ToString(), loyaltyInquiry.Locale); | ||
Assert.AreEqual("123456789", loyaltyInquiry.ConversationId); | ||
Assert.IsNotNull(loyaltyInquiry.SystemTime); | ||
Assert.IsNull(loyaltyInquiry.ErrorCode); | ||
Assert.IsNull(loyaltyInquiry.ErrorMessage); | ||
Assert.IsNull(loyaltyInquiry.ErrorGroup); | ||
} | ||
} | ||
} |
92 changes: 92 additions & 0 deletions
92
Iyzipay.Tests/Functional/Builder/LoyaltyPaymentCardBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
using Iyzipay.Model; | ||
|
||
namespace Iyzipay.Tests.Functional.Builder | ||
{ | ||
public sealed class LoyaltyPaymentCardBuilder | ||
{ | ||
private string _cardHolderName; | ||
private string _cardNumber; | ||
private string _expireYear; | ||
private string _expireMonth; | ||
private string _cvc; | ||
private string _cardToken; | ||
private string _cardUserKey; | ||
|
||
private LoyaltyPaymentCardBuilder() | ||
{ | ||
} | ||
|
||
public static LoyaltyPaymentCardBuilder Create() | ||
{ | ||
return new LoyaltyPaymentCardBuilder(); | ||
} | ||
|
||
public LoyaltyPaymentCardBuilder CardHolderName(string cardHolderName) | ||
{ | ||
_cardHolderName = cardHolderName; | ||
return this; | ||
} | ||
|
||
public LoyaltyPaymentCardBuilder CardNumber(string cardNumber) | ||
{ | ||
_cardNumber = cardNumber; | ||
return this; | ||
} | ||
|
||
public LoyaltyPaymentCardBuilder ExpireYear(string expireYear) | ||
{ | ||
_expireYear = expireYear; | ||
return this; | ||
} | ||
|
||
public LoyaltyPaymentCardBuilder ExpireMonth(string expireMonth) | ||
{ | ||
_expireMonth = expireMonth; | ||
return this; | ||
} | ||
|
||
public LoyaltyPaymentCardBuilder Cvc(string cvc) | ||
{ | ||
_cvc = cvc; | ||
return this; | ||
} | ||
|
||
|
||
public LoyaltyPaymentCardBuilder CardToken(string cardToken) | ||
{ | ||
_cardToken = cardToken; | ||
return this; | ||
} | ||
|
||
public LoyaltyPaymentCardBuilder CardUserKey(string cardUserKey) | ||
{ | ||
_cardUserKey = cardUserKey; | ||
return this; | ||
} | ||
|
||
public LoyaltyPaymentCard Build() | ||
{ | ||
LoyaltyPaymentCard paymentCard = new LoyaltyPaymentCard(); | ||
paymentCard.CardHolderName = _cardHolderName; | ||
paymentCard.CardNumber = _cardNumber; | ||
paymentCard.ExpireYear = _expireYear; | ||
paymentCard.ExpireMonth = _expireMonth; | ||
paymentCard.Cvc = _cvc; | ||
paymentCard.CardToken = _cardToken; | ||
paymentCard.CardUserKey = _cardUserKey; | ||
return paymentCard; | ||
} | ||
|
||
public LoyaltyPaymentCardBuilder BuildWithCardCredentials() | ||
{ | ||
_cardHolderName = "John Doe"; | ||
_cardNumber = "5451030000000000"; | ||
_expireYear = "2023"; | ||
_expireMonth = "09"; | ||
_cvc = "123"; | ||
//_cardUserKey = "card user key"; | ||
//_cardToken = "card token"; | ||
return this; | ||
} | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
Iyzipay.Tests/Functional/Builder/Request/LoyaltyInquiryRequestBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Iyzipay.Model; | ||
using Iyzipay.Request; | ||
using Iyzipay.Tests.Functional.Util; | ||
|
||
namespace Iyzipay.Tests.Functional.Builder.Request | ||
{ | ||
public sealed class LoyaltyInquiryRequestBuilder : BaseRequestBuilder | ||
{ | ||
private LoyaltyPaymentCard _loyaltyPaymentCard = LoyaltyPaymentCardBuilder.Create().BuildWithCardCredentials().Build(); | ||
private string _currency; | ||
|
||
private LoyaltyInquiryRequestBuilder() | ||
{ | ||
} | ||
|
||
public static LoyaltyInquiryRequestBuilder Create() | ||
{ | ||
return new LoyaltyInquiryRequestBuilder(); | ||
} | ||
|
||
public LoyaltyInquiryRequestBuilder Currency(string currency) | ||
{ | ||
this._currency = currency; | ||
return this; | ||
} | ||
|
||
public LoyaltyInquiryRequest Build() | ||
{ | ||
LoyaltyInquiryRequest loyaltyInquiryRequest = new LoyaltyInquiryRequest(); | ||
loyaltyInquiryRequest.Locale = _locale; | ||
loyaltyInquiryRequest.ConversationId = _conversationId; | ||
loyaltyInquiryRequest.PaymentCard = _loyaltyPaymentCard; | ||
loyaltyInquiryRequest.Currency = _currency; | ||
return loyaltyInquiryRequest; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using Iyzipay.Model; | ||
using Iyzipay.Request; | ||
using Iyzipay.Tests.Functional.Builder; | ||
using Iyzipay.Tests.Functional.Builder.Request; | ||
using NUnit.Framework; | ||
|
||
namespace Iyzipay.Tests.Functional | ||
{ | ||
public class LoyaltyInquireTest : BaseTest | ||
{ | ||
[Test] | ||
public void Should_Inquire_Loyalty() | ||
{ | ||
LoyaltyInquiryRequest request = LoyaltyInquiryRequestBuilder.Create() | ||
.Currency("TRY") | ||
.Build(); | ||
|
||
LoyaltyInquiry loyaltyInquiry = LoyaltyInquiry.Create(request, _options); | ||
|
||
PrintResponse<LoyaltyInquiry>(loyaltyInquiry); | ||
|
||
Assert.AreEqual(Status.SUCCESS.ToString(), loyaltyInquiry.Status); | ||
Assert.AreEqual(Locale.TR.ToString(), loyaltyInquiry.Locale); | ||
Assert.AreEqual("123456789", loyaltyInquiry.ConversationId); | ||
Assert.IsNotNull(loyaltyInquiry.SystemTime); | ||
Assert.IsNotNull(loyaltyInquiry.Points); | ||
Assert.IsNotNull(loyaltyInquiry.Amount); | ||
Assert.IsNotNull(loyaltyInquiry.CardBank); | ||
Assert.IsNotNull(loyaltyInquiry.CardFamily); | ||
Assert.IsNotNull(loyaltyInquiry.Currency); | ||
Assert.IsNull(loyaltyInquiry.ErrorCode); | ||
Assert.IsNull(loyaltyInquiry.ErrorMessage); | ||
Assert.IsNull(loyaltyInquiry.ErrorGroup); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Iyzipay.Request; | ||
using System; | ||
|
||
namespace Iyzipay.Model | ||
{ | ||
public class LoyaltyInquiry : IyzipayResource | ||
{ | ||
public string Points { get; set; } | ||
public string Amount { get; set; } | ||
public string CardBank { get; set; } | ||
public string CardFamily { get; set; } | ||
public string Currency { get; set; } | ||
|
||
public static LoyaltyInquiry Create(LoyaltyInquiryRequest request, Options options) | ||
{ | ||
return RestHttpClient.Create().Post<LoyaltyInquiry>(options.BaseUrl + "/payment/loyalty/inquire", GetHttpHeaders(request, options), request); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System; | ||
|
||
namespace Iyzipay.Model | ||
{ | ||
public class LoyaltyPaymentCard : RequestStringConvertible | ||
{ | ||
public string CardHolderName { set; get; } | ||
public string CardNumber { set; get; } | ||
public string ExpireYear { set; get; } | ||
public string ExpireMonth { set; get; } | ||
public string Cvc { set; get; } | ||
public string CardUserKey { set; get; } | ||
public string CardToken { set; get; } | ||
|
||
public string ToPKIRequestString() | ||
{ | ||
return ToStringRequestBuilder.NewInstance() | ||
.Append("cardHolderName", CardHolderName) | ||
.Append("cardNumber", CardNumber) | ||
.Append("expireYear", ExpireYear) | ||
.Append("expireMonth", ExpireMonth) | ||
.Append("cvc", Cvc) | ||
.Append("cardToken", CardToken) | ||
.Append("cardUserKey", CardUserKey) | ||
.GetRequestString(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System; | ||
using Iyzipay.Model; | ||
|
||
namespace Iyzipay.Request | ||
{ | ||
public class LoyaltyInquiryRequest : BaseRequest | ||
{ | ||
public LoyaltyPaymentCard PaymentCard { set; get; } | ||
public string Currency { set; get; } | ||
|
||
public override String ToPKIRequestString() | ||
{ | ||
return ToStringRequestBuilder.NewInstance() | ||
.AppendSuper(base.ToPKIRequestString()) | ||
.Append("paymentCard", PaymentCard.ToPKIRequestString()) | ||
.Append("currency", Currency) | ||
.GetRequestString(); | ||
} | ||
} | ||
} |