Skip to content

Commit

Permalink
Merge branch 'master' into update-fraud-params
Browse files Browse the repository at this point in the history
  • Loading branch information
deryacakmak authored Nov 15, 2024
2 parents 5be3f84 + 86f99d8 commit 1b268a3
Show file tree
Hide file tree
Showing 12 changed files with 63 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Craftgate/Adapter/BaseAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ RequestOptions options
headers.Add(ApiKeyHeaderName, options.ApiKey);
headers.Add(RandomHeaderName, randomString);
headers.Add(AuthVersionHeaderName, ApiVersionHeaderValue);
headers.Add(ClientVersionHeaderName, ClientVersionHeaderValue + ":1.0.66");
headers.Add(ClientVersionHeaderName, ClientVersionHeaderValue + ":1.0.68");
headers.Add(SignatureHeaderName, PrepareAuthorizationString(request, path, randomString, options));
if (options.Language != null)
{
Expand Down
1 change: 1 addition & 0 deletions Craftgate/Model/ApmType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public enum ApmType
[EnumMember(Value = "MULTINET_GIFT")] MULTINET_GIFT,
[EnumMember(Value = "ISPAY")] ISPAY,
[EnumMember(Value = "CHIPPIN")] CHIPPIN,
[EnumMember(Value = "PAYMOB")] PAYMOB,
[EnumMember(Value = "FUND_TRANSFER")] FUND_TRANSFER,
[EnumMember(Value = "CASH_ON_DELIVERY")] CASH_ON_DELIVERY
}
Expand Down
3 changes: 2 additions & 1 deletion Craftgate/Model/Currency.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public enum Currency
[EnumMember(Value = "SAR")] SAR,
[EnumMember(Value = "BHD")] BHD,
[EnumMember(Value = "RUB")] RUB,
[EnumMember(Value = "JPY")] JPY
[EnumMember(Value = "JPY")] JPY,
[EnumMember(Value = "EGP")] EGP
}
}
2 changes: 2 additions & 0 deletions Craftgate/Model/PaymentProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public enum PaymentProvider
[EnumMember(Value = "HASO")] HASO,
[EnumMember(Value = "MULTINET")] MULTINET,
[EnumMember(Value = "ISPAY")] ISPAY,
[EnumMember(Value = "CHIPPIN")] CHIPPIN,
[EnumMember(Value = "PAYMOB")] PAYMOB,
[EnumMember(Value = "OFFLINE")] OFFLINE
}
}
4 changes: 3 additions & 1 deletion Craftgate/Model/WebhookEventType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public enum WebhookEventType
[EnumMember(Value = "WALLET_CREATED")] WALLET_CREATED,
[EnumMember(Value = "WALLET_TX_CREATED")] WALLET_TX_CREATED,
[EnumMember(Value = "BNPL_NOTIFICATION")] BNPL_NOTIFICATION,
[EnumMember(Value = "BANK_ACCOUNT_TRACKING_RECORD")] BANK_ACCOUNT_TRACKING_RECORD
[EnumMember(Value = "BANK_ACCOUNT_TRACKING_RECORD")] BANK_ACCOUNT_TRACKING_RECORD,
[EnumMember(Value = "BKM_EXPRESS_PAYMENT_NOTIFICATION")] BKM_EXPRESS_PAYMENT_NOTIFICATION,
[EnumMember(Value = "MULTI_PAYMENT_COMPLETED")] MULTI_PAYMENT_COMPLETED
}
}
2 changes: 1 addition & 1 deletion Craftgate/Request/CompleteApmPaymentRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ namespace Craftgate.Request
public class CompleteApmPaymentRequest
{
public long PaymentId { get; set; }
public Dictionary<string, string> AdditionalParams { get; set; }
public Dictionary<string, object> AdditionalParams { get; set; }
}
}
2 changes: 1 addition & 1 deletion Craftgate/Request/InitApmDepositPaymentRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class InitApmDepositPaymentRequest
public string CallbackUrl { get; set; }
public string ApmOrderId { get; set; }
public string ApmUserIdentity { get; set; }
public Dictionary<string, string> AdditionalParams { get; set; }
public Dictionary<string, object> AdditionalParams { get; set; }
public string ClientIp { get; set; }
}
}
2 changes: 1 addition & 1 deletion Craftgate/Request/InitApmPaymentRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class InitApmPaymentRequest
public string CallbackUrl { get; set; }
public string ApmOrderId { get; set; }
public string ApmUserIdentity { get; set; }
public Dictionary<string, string> AdditionalParams { get; set; }
public Dictionary<string, object> AdditionalParams { get; set; }
public string ClientIp { get; set; }
public IList<PaymentItem> Items { get; set; }
}
Expand Down
1 change: 1 addition & 0 deletions Craftgate/Request/InitGarantiPayPaymentRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ public class InitGarantiPayPaymentRequest
public string BankOrderId { get; set; }
public IList<PaymentItem> Items { get; set; }
public List<GarantiPayInstallment> Installments { get; set; }
public IList<int> EnabledInstallments { get; set; }
}
}
2 changes: 1 addition & 1 deletion Samples/InstantTransferPaymentSample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void Init_Instant_Transfer_Apm_Payment()
ExternalId = "optional-ExternalId",
CallbackUrl = "https://www.your-website.com/craftgate-apm-callback",
ApmUserIdentity = "5555555555",
AdditionalParams = new Dictionary<string, string>
AdditionalParams = new Dictionary<string, object>
{
{"bankCode", "0"}
},
Expand Down
56 changes: 49 additions & 7 deletions Samples/PaymentSample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,7 @@ public void Init_GarantiPay_Payment()
Currency = Currency.TRY,
PaymentGroup = PaymentGroup.LISTING_OR_SUBSCRIPTION,
CallbackUrl = "https://www.your-website.com/craftgate-garantipay-callback",
EnabledInstallments = new List<int> {2, 3},
Items = new List<PaymentItem>
{
new PaymentItem
Expand Down Expand Up @@ -995,7 +996,7 @@ public void Init_Sodexo_Apm_Payment()
ExternalId = "optional-ExternalId",
CallbackUrl = "https://www.your-website.com/craftgate-apm-callback",
ApmUserIdentity = "5555555555",
AdditionalParams = new Dictionary<string, string>
AdditionalParams = new Dictionary<string, object>
{
{ "sodexoCode", "843195" }
},
Expand Down Expand Up @@ -1107,7 +1108,7 @@ public void Init_Kaspi_Apm_Payment()
[Test]
public void Init_Tompay_Apm_Payment()
{
var additionalParams = new Dictionary<string, string>();
var additionalParams = new Dictionary<string, object>();
additionalParams.Add("channel", "channel");
additionalParams.Add("phone", "phone");

Expand Down Expand Up @@ -1186,13 +1187,54 @@ public void Init_Chippin_Apm_Payment()
Assert.AreEqual(response.AdditionalAction, ApmAdditionalAction.WAIT_FOR_WEBHOOK);
}

[Test]
public void Init_Paymob_Apm_Payment()
{
var additionalParams = new Dictionary<string, object>();
additionalParams.Add("integrationId", "11223344");

var request = new InitApmPaymentRequest
{
ApmType = ApmType.PAYMOB,
Price = new decimal(1.0),
PaidPrice = new decimal(1.0),
Currency = Currency.EGP,
PaymentGroup = PaymentGroup.LISTING_OR_SUBSCRIPTION,
ConversationId = "conversationId",
ExternalId = "externalId",
CallbackUrl = "https://www.your-website.com/craftgate-apm-callback",
Items = new List<PaymentItem>
{
new PaymentItem
{
Name = "Item 1",
ExternalId = Guid.NewGuid().ToString(),
Price = new decimal(0.40)
},

new PaymentItem
{
Name = "Item 2",
ExternalId = Guid.NewGuid().ToString(),
Price = new decimal(0.60)
}
},
};

var response = _craftgateClient.Payment().InitApmPayment(request);
Assert.NotNull(response);
Assert.NotNull(response.PaymentId);
Assert.AreEqual(response.PaymentStatus, PaymentStatus.WAITING);
Assert.AreEqual(response.AdditionalAction, ApmAdditionalAction.REDIRECT_TO_URL);
}

[Test]
public void Complete_Edenred_Apm_Payment()
{
var request = new CompleteApmPaymentRequest
{
PaymentId = 1,
AdditionalParams = new Dictionary<string, string>
AdditionalParams = new Dictionary<string, object>
{
{ "otpCode", "784294" }
},
Expand All @@ -1207,7 +1249,7 @@ public void Complete_Edenred_Apm_Payment()
[Test]
public void Init_Metropol_Apm_Payment()
{
var additionalParams = new Dictionary<string, string>();
var additionalParams = new Dictionary<string, object>();
additionalParams.Add("cardNumber", "6375780115068760");

var request = new InitApmPaymentRequest
Expand Down Expand Up @@ -1246,7 +1288,7 @@ public void Init_Metropol_Apm_Payment()

public void Complete_Metropol_Apm_Payment()
{
var additionalParams = new Dictionary<string, string>();
var additionalParams = new Dictionary<string, object>();
additionalParams.Add("otpCode", "00000");
additionalParams.Add("productId", "1");
additionalParams.Add("walletId", "1");
Expand Down Expand Up @@ -1305,7 +1347,7 @@ public void Init_PayPal_APM_Payment()
[Test]
public void Init_Klarna_APM_Payment()
{
var additionalParams = new Dictionary<string, string>();
var additionalParams = new Dictionary<string, object>();
additionalParams.Add("country", "de");
additionalParams.Add("locale", "en-DE");

Expand Down Expand Up @@ -2082,7 +2124,7 @@ public void Init_Bnpl_Payment()
[Test]
public void Init_TomFinance_Bnpl_Payment()
{
var additionalParams = new Dictionary<string, string>();
var additionalParams = new Dictionary<string, object>();
additionalParams.Add("buyerName", "John Doe");
additionalParams.Add("buyerPhoneNumber", "5554443322");

Expand Down

0 comments on commit 1b268a3

Please sign in to comment.