Skip to content

Commit

Permalink
Adds Paymob and EGP Currency (#198)
Browse files Browse the repository at this point in the history
* Adds Paymob and EGP Currency

* Add Payment Provider
  • Loading branch information
reywyn authored Oct 15, 2024
1 parent 6a5e50f commit 0bb88dd
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 1 deletion.
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
}
}
41 changes: 41 additions & 0 deletions Samples/PaymentSample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1180,6 +1180,47 @@ 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, string>();
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()
{
Expand Down

0 comments on commit 0bb88dd

Please sign in to comment.