-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* BKM Express Integration * Add BKM Express Integration * update
- Loading branch information
1 parent
731916f
commit 9e808ce
Showing
7 changed files
with
169 additions
and
1 deletion.
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,41 @@ | ||
using System.Threading.Tasks; | ||
using Craftgate.Net; | ||
using Craftgate.Request; | ||
using Craftgate.Request.Common; | ||
using Craftgate.Response; | ||
|
||
namespace Craftgate.Adapter | ||
{ | ||
public class BkmExpressPaymentAdapter : BaseAdapter | ||
{ | ||
public BkmExpressPaymentAdapter(RequestOptions requestOptions) : base(requestOptions) | ||
{ | ||
} | ||
|
||
public InitBkmExpressResponse Init(InitBkmExpressRequest initBkmExpressRequest) | ||
{ | ||
var path = "/payment/v1/bkm-express/init"; | ||
return RestClient.Post<InitBkmExpressResponse>(RequestOptions.BaseUrl + path, | ||
CreateHeaders(initBkmExpressRequest, path, RequestOptions), initBkmExpressRequest); | ||
} | ||
|
||
public PaymentResponse Complete( | ||
CompleteBkmExpressRequest completeBkmExpressPayment) | ||
{ | ||
var path = "/payment/v1/bkm-express/complete"; | ||
return RestClient.Post<PaymentResponse>(RequestOptions.BaseUrl + path, | ||
CreateHeaders(completeBkmExpressPayment, path, RequestOptions), | ||
completeBkmExpressPayment); | ||
} | ||
|
||
public PaymentResponse RetrievePayment( | ||
string ticketId) | ||
{ | ||
var path = "/payment/v1/bkm-express/payments/" + ticketId; | ||
return RestClient.Get<PaymentResponse>(RequestOptions.BaseUrl + path, | ||
CreateHeaders(path, RequestOptions)); | ||
} | ||
|
||
} | ||
|
||
} |
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
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
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,10 @@ | ||
namespace Craftgate.Request | ||
{ | ||
public class CompleteBkmExpressRequest | ||
{ | ||
public bool? Status { get; set; } | ||
public string Message { get; set; } | ||
public string TicketId { get; set; } | ||
|
||
} | ||
} |
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.Collections.Generic; | ||
using Craftgate.Model; | ||
using Craftgate.Request.Dto; | ||
|
||
namespace Craftgate.Request | ||
{ | ||
public class InitBkmExpressRequest | ||
{ | ||
public decimal? Price { get; set; } | ||
public decimal? PaidPrice { get; set; } | ||
public Currency? Currency { get; set; } | ||
public PaymentGroup? PaymentGroup { get; set; } | ||
public string ConversationId { get; set; } | ||
public PaymentPhase PaymentPhase { get; set; } = PaymentPhase.AUTH; | ||
public long? BuyerMemberId { get; set; } | ||
public string BankOrderId { get; set; } | ||
public IList<PaymentItem> Items { get; set; } | ||
public IList<int> EnabledInstallments { get; set; } | ||
} | ||
} |
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,9 @@ | ||
namespace Craftgate.Response | ||
{ | ||
public class InitBkmExpressResponse | ||
{ | ||
public string id { get; set; } | ||
public string path { get; set; } | ||
public string token { get; set; } | ||
} | ||
} |
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,80 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Craftgate; | ||
using Craftgate.Model; | ||
using Craftgate.Request; | ||
using Craftgate.Request.Dto; | ||
using NUnit.Framework; | ||
|
||
namespace Samples | ||
{ | ||
public class BkmExpressSample | ||
{ | ||
private readonly CraftgateClient _craftgateClient = | ||
new CraftgateClient("api-key", "secret-key", "https://sandbox-api.craftgate.io"); | ||
|
||
|
||
[Test] | ||
public void Init_Bkm_Express_Payment() | ||
{ | ||
var request = new InitBkmExpressRequest | ||
{ | ||
Price = new decimal(100.0), | ||
PaidPrice = new decimal(100.0), | ||
ConversationId = "456d1297-908e-4bd6-a13b-4be31a6e47d5", | ||
Currency = Currency.TRY, | ||
PaymentGroup = PaymentGroup.LISTING_OR_SUBSCRIPTION, | ||
Items = new List<PaymentItem> | ||
{ | ||
new PaymentItem | ||
{ | ||
Name = "Item 1", | ||
ExternalId = Guid.NewGuid().ToString(), | ||
Price = new decimal(30.0) | ||
}, | ||
new PaymentItem | ||
{ | ||
Name = "Item 2", | ||
ExternalId = Guid.NewGuid().ToString(), | ||
Price = new decimal(50.0) | ||
}, | ||
new PaymentItem | ||
{ | ||
Name = "Item 3", | ||
ExternalId = Guid.NewGuid().ToString(), | ||
Price = new decimal(20.0) | ||
} | ||
} | ||
}; | ||
|
||
var response = _craftgateClient.BkmExpress().Init(request); | ||
Assert.NotNull(response); | ||
} | ||
|
||
[Test] | ||
public void Complete_Bkm_Express_Payment() | ||
{ | ||
var request = new CompleteBkmExpressRequest() | ||
{ | ||
Status = true, | ||
Message = "İşlem Başarılı", | ||
TicketId = "b9bd7b93-662f-4460-9ef3-8fc735853cf1", | ||
|
||
}; | ||
|
||
|
||
var response = _craftgateClient.BkmExpress().Complete(request); | ||
Assert.NotNull(response.HostReference); | ||
Assert.NotNull(response); | ||
} | ||
|
||
[Test] | ||
public void Retrieve_Payment() | ||
{ | ||
var ticketId = "b9bd7b93-662f-4460-9ef3-8fc735853cf1"; | ||
|
||
var response = _craftgateClient.BkmExpress().RetrievePayment(ticketId); | ||
Assert.NotNull(response); | ||
} | ||
} | ||
} |