Skip to content

Commit 938808b

Browse files
Merge branch 'master' into task/#99_logrotation
2 parents 4869e7d + e14155c commit 938808b

File tree

3 files changed

+28
-844
lines changed

3 files changed

+28
-844
lines changed

TransactionProcessor.BusinessLogic/OperatorInterfaces/SafaricomPinless/SafaricomPinlessProxy.cs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,16 @@ public async Task<OperatorResponse> ProcessSaleMessage(Guid transactionId,
8484
throw new Exception("CustomerAccountNumber is a required field for this transaction type");
8585
}
8686

87-
String requestUrl = this.BuildRequest(transactionDateTime, transactionReference, customerMsisdn, transactionAmount);
87+
// Multiply amount before sending
88+
// Covert the transaction amount to Decimal and remove decimal places
89+
if (Decimal.TryParse(transactionAmount, out Decimal amountAsDecimal) == false)
90+
{
91+
throw new Exception("Transaction Amount is not a valid decimal value");
92+
}
93+
94+
Decimal operatorTransactionAmount = amountAsDecimal * 100;
95+
96+
String requestUrl = this.BuildRequest(transactionDateTime, transactionReference, customerMsisdn, operatorTransactionAmount);
8897

8998
// Concatenate the request message
9099
HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Get, new Uri(requestUrl));
@@ -115,18 +124,12 @@ public async Task<OperatorResponse> ProcessSaleMessage(Guid transactionId,
115124
private String BuildRequest(DateTime transactionDateTime,
116125
String externalReference,
117126
String customerMsisdn,
118-
String transactionAmount)
127+
Decimal transactionAmount)
119128
{
120129
String requestUrl = $"{this.SafaricomConfiguration.Url}?VENDOR={this.SafaricomConfiguration.LoginId}&REQTYPE=EXRCTRFREQ&DATA=";
121130

122131
StringBuilder xmlData = new StringBuilder();
123-
124-
// Covert the transaction amount to Decimal and remove decimal places
125-
if (Decimal.TryParse(transactionAmount, out Decimal amountAsDecimal) == false)
126-
{
127-
throw new Exception("Transaction Amount is not a valid decimal value");
128-
}
129-
132+
130133
// Now build up the XML part of the message
131134
xmlData.Append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
132135
xmlData.Append("<ns0:COMMAND xmlns:ns0=\"http://safaricom.co.ke/Pinless/keyaccounts/\">");
@@ -140,7 +143,7 @@ private String BuildRequest(DateTime transactionDateTime,
140143
xmlData.Append($"<ns0:EXTCODE>{this.SafaricomConfiguration.ExtCode}</ns0:EXTCODE>");
141144
xmlData.Append($"<ns0:EXTREFNUM>{externalReference}</ns0:EXTREFNUM>");
142145
xmlData.Append($"<ns0:MSISDN2>{customerMsisdn}</ns0:MSISDN2>");
143-
xmlData.Append($"<ns0:AMOUNT>{amountAsDecimal:G0}</ns0:AMOUNT>");
146+
xmlData.Append($"<ns0:AMOUNT>{transactionAmount:G0}</ns0:AMOUNT>");
144147
xmlData.Append("<ns0:LANGUAGE1>0</ns0:LANGUAGE1>");
145148
xmlData.Append("<ns0:LANGUAGE2>0</ns0:LANGUAGE2>");
146149
xmlData.Append("<ns0:SELECTOR>0</ns0:SELECTOR>");

TransactionProcessor.IntegrationTests/SaleTransaction/SaleTransactionFeature.feature

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,19 @@ Background:
6161

6262
Given I make the following manual merchant deposits
6363
| Reference | Amount | DateTime | MerchantName | EstateName |
64-
| Deposit1 | 2000.00 | Today | Test Merchant 1 | Test Estate 1 |
65-
| Deposit1 | 1000.00 | Today | Test Merchant 2 | Test Estate 1 |
66-
| Deposit1 | 1000.00 | Today | Test Merchant 3 | Test Estate 2 |
64+
| Deposit1 | 200.00 | Today | Test Merchant 1 | Test Estate 1 |
65+
| Deposit1 | 100.00 | Today | Test Merchant 2 | Test Estate 1 |
66+
| Deposit1 | 100.00 | Today | Test Merchant 3 | Test Estate 2 |
6767

6868
@PRTest
6969
Scenario: Sale Transactions
7070

7171
When I perform the following transactions
7272
| DateTime | TransactionNumber | TransactionType | MerchantName | DeviceIdentifier | EstateName | OperatorName | TransactionAmount | CustomerAccountNumber | CustomerEmailAddress | ContractDescription | ProductName |
73-
| Today | 1 | Sale | Test Merchant 1 | 123456780 | Test Estate 1 | Safaricom | 1000.00 | 123456789 | | Safaricom Contract | Variable Topup |
74-
| Today | 2 | Sale | Test Merchant 2 | 123456781 | Test Estate 1 | Safaricom | 1000.00 | 123456789 | | Safaricom Contract | Variable Topup |
75-
| Today | 3 | Sale | Test Merchant 3 | 123456782 | Test Estate 2 | Safaricom | 1000.00 | 123456789 | | Safaricom Contract | Variable Topup |
76-
| Today | 4 | Sale | Test Merchant 1 | 123456780 | Test Estate 1 | Safaricom | 1000.00 | 123456789 | testcustomer@customer.co.uk | Safaricom Contract | Variable Topup |
73+
| Today | 1 | Sale | Test Merchant 1 | 123456780 | Test Estate 1 | Safaricom | 100.00 | 123456789 | | Safaricom Contract | Variable Topup |
74+
| Today | 2 | Sale | Test Merchant 2 | 123456781 | Test Estate 1 | Safaricom | 100.00 | 123456789 | | Safaricom Contract | Variable Topup |
75+
| Today | 3 | Sale | Test Merchant 3 | 123456782 | Test Estate 2 | Safaricom | 100.00 | 123456789 | | Safaricom Contract | Variable Topup |
76+
| Today | 4 | Sale | Test Merchant 1 | 123456780 | Test Estate 1 | Safaricom | 100.00 | 123456789 | testcustomer@customer.co.uk | Safaricom Contract | Variable Topup |
7777

7878
Then transaction response should contain the following information
7979
| EstateName | MerchantName | TransactionNumber | ResponseCode | ResponseMessage |
@@ -87,7 +87,7 @@ Scenario: Sale Transaction with Invalid Device
8787

8888
When I perform the following transactions
8989
| DateTime | TransactionNumber | TransactionType | MerchantName | DeviceIdentifier | EstateName | OperatorName | TransactionAmount | CustomerAccountNumber | CustomerEmailAddress | ContractDescription | ProductName |
90-
| Today | 1 | Sale | Test Merchant 1 | 123456781 | Test Estate 1 | Safaricom | 1000.00 | 123456789 | testcustomer@customer.co.uk | Safaricom Contract | Variable Topup |
90+
| Today | 1 | Sale | Test Merchant 1 | 123456781 | Test Estate 1 | Safaricom | 100.00 | 123456789 | testcustomer@customer.co.uk | Safaricom Contract | Variable Topup |
9191

9292
Then transaction response should contain the following information
9393
| EstateName | MerchantName | TransactionNumber | ResponseCode | ResponseMessage |
@@ -97,7 +97,7 @@ Scenario: Sale Transaction with Invalid Estate
9797

9898
When I perform the following transactions
9999
| DateTime | TransactionNumber | TransactionType | MerchantName | DeviceIdentifier | EstateName | OperatorName | TransactionAmount | CustomerAccountNumber | CustomerEmailAddress | ContractDescription | ProductName |
100-
| Today | 1 | Sale | Test Merchant 1 | 123456780 | InvalidEstate | Safaricom | 1000.00 | 123456789 | testcustomer@customer.co.uk | Safaricom Contract | Variable Topup |
100+
| Today | 1 | Sale | Test Merchant 1 | 123456780 | InvalidEstate | Safaricom | 100.00 | 123456789 | testcustomer@customer.co.uk | Safaricom Contract | Variable Topup |
101101

102102
Then transaction response should contain the following information
103103
| EstateName | MerchantName | TransactionNumber | ResponseCode | ResponseMessage |
@@ -107,7 +107,7 @@ Scenario: Sale Transaction with Invalid Merchant
107107

108108
When I perform the following transactions
109109
| DateTime | TransactionNumber | TransactionType | MerchantName | DeviceIdentifier | EstateName | OperatorName | TransactionAmount | CustomerAccountNumber | CustomerEmailAddress | ContractDescription | ProductName |
110-
| Today | 1 | Sale | InvalidMerchant | 123456780 | Test Estate 1 | Safaricom | 1000.00 | 123456789 | testcustomer@customer.co.uk | Safaricom Contract | Variable Topup |
110+
| Today | 1 | Sale | InvalidMerchant | 123456780 | Test Estate 1 | Safaricom | 100.00 | 123456789 | testcustomer@customer.co.uk | Safaricom Contract | Variable Topup |
111111

112112
Then transaction response should contain the following information
113113
| EstateName | MerchantName | TransactionNumber | ResponseCode | ResponseMessage |
@@ -118,9 +118,9 @@ Scenario: Sale Transaction with Not Enough Credit Available
118118

119119
When I perform the following transactions
120120
| DateTime | TransactionNumber | TransactionType | MerchantName | DeviceIdentifier | EstateName | OperatorName | TransactionAmount | CustomerAccountNumber | CustomerEmailAddress | ContractDescription | ProductName |
121-
| Today | 1 | Sale | Test Merchant 1 | 123456780 | Test Estate 1 | Safaricom | 3000.00 | 123456789 | testcustomer@customer.co.uk | Safaricom Contract | Variable Topup |
121+
| Today | 1 | Sale | Test Merchant 1 | 123456780 | Test Estate 1 | Safaricom | 300.00 | 123456789 | testcustomer@customer.co.uk | Safaricom Contract | Variable Topup |
122122

123123

124124
Then transaction response should contain the following information
125125
| EstateName | MerchantName | TransactionNumber | ResponseCode | ResponseMessage |
126-
| Test Estate 1 | Test Merchant 1 | 1 | 1009 | Merchant [Test Merchant 1] does not have enough credit available [2000.0] to perform transaction amount [3000.00] |
126+
| Test Estate 1 | Test Merchant 1 | 1 | 1009 | Merchant [Test Merchant 1] does not have enough credit available [200.0] to perform transaction amount [300.00] |

0 commit comments

Comments
 (0)