Set Different Amounts for Different Currencies in Flutterwave - asp.net

Hi I am using the flutterwave api gateway to create a payment form which will have different preset amounts in different currencies. for example
USD -10
KES-100
UGX-1000
My thoughts were to put a select box and you choose the currency and then enter your details and press pay.
Would This be possible in asp.net ? Anyone done something close to this? How to pass the values to the api?

Its Posible...
I have a working
prototype... of sorts.
I created the values in a select box and made the currency and amounts separately. Then pooled the values and passed them to the api with the preset values currency and amount. The flutterwave api gets this info and serves up the right payment method for that particular currency.
<form method="POST" class="payment-form-africa" action="https://checkout.flutterwave.com/v3/hosted/pay">
<input name="customer[email]" asp-for="email" />
<input name="customer[name]" asp-for="name"/>
<input name="tx_ref" asp-for="tx_ref"/>
<input name="amount" asp-for="amount"/>
<input name="currency" asp-for="currency"/>
<button type="submit">Pay</button>
Thanks everyone.

Related

Connecting a dictionary and datalist

I am trying to make a stock trading webapp using ASP.Net Core MVC One of the things I am trying to implement is auto-complete search box where you can type the name of a stock and it would be suggested to the user. I tried to use a datalist. I want to use a dictionary where the name of the stock is the key and the value would be the symbol. example key- Apple value-AAPL. When the name is selected, I am trying to use the symbol to call other data from an API elsewhere in the app.
The 2 things I am trying to figure out is
A. Can I implement a dictionary with a datalist to accomplish this?
B. Is there a way to use a database to accomplish this? There are several thousand Stocks and Stock symbols and hard coding them would be very cumbersome and time consuming and would be easier to copy and paste stock names and corresponding symbols into a database.
Thanks in advance. This is my first time posting.
Here is what I have so far. Not sure how to proceed or if this is possible.
<form>
<label for="stock">Choose a Stock:</label>
<input list="stock" name="stock" id="stock">
<datalist id="stock">
<option value="Tesla"/>
<option value="IBM"/>
<option value="Microsoft"/>
<option value="Apple"/>
<option value="Amazon"/>
</datalist>
<input type="submit">
</form>

Symfony2 - Array of data

This is the last problem I am facing with Symfony2. So, I am using a normal form, not the form builder.
I have one table called alert which has the standard fields. I have a second table called booking_class which has an alert key in it which is linked to the alert table. Its a one to many relationship. In my form, I have something like
<input type="text" name="na_booking_class[]">
<input type="text" name="na_booking_class[]">
So this input is placed into an array. Now in my controller, I presume that this will give me my array of data
$alert->setBookingClass($request->get('na_booking_class'));
However, setBookingClass only accepts a String. So I need to somehow loop this array and pass the String values to setBookingClass.
How would this be achieved?
Thanks
If you get an array from this $request->get('na_booking_class'); then you can use:
$arrBooking = $request->get('na_booking_class');
foreach($arrBooking as $booking) {
$alert->setBookingClass($booking);
}
Try with this.

best method for saving data from multiple check boxes in asp master page to sqlserver [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
what is the best way to save data from multiple checkboxes ?? if i have 50 , 60 checkboxes
Is it reasonable to set up a column of 50 or 60 checkboxes for ٍsaving value for each question separately ?
and presumably there are questions that have not responded what should i do ??
<div class="form-group">
<div class="form-group">
<label class="control-label">
Moderate
</label>
<asp:CheckBox ID="CheckBox2" runat="server" class="form-control" />
</div>
<div class="form-group">
<label class="control-label">
Heavy
</label>
<asp:CheckBox ID="CheckBox3" runat="server" class="form-control" />
</div>
<div class="form-group">
<label class="control-label">
Y
</label>
<asp:CheckBox ID="CheckBox4"runat="server" class="form-control" />
</div>
<div class="form-group">
<label class="control-label">
N
</label>
<asp:CheckBox ID="CheckBox5" runat="server" class="form-control" />
</div>
and so on ...
I would set up my checkboxes with either a CheckBoxList as thesentiment said, or if you need more control over layout, you could use your same markup inside something like a Repeater that you could bind to a list of questions/answers stored in the database. I would avoid saving each answer separately, as you don't want to make a separate call to the database for each question, but rather you should make one call in which you pass back all your answers at once. Basically on the save, you loop through the CheckBoxList or Repeater Items (they should be collections in the control itself) and get the value of the checked answer.
It is hard to say what your save methodology should be without knowing your db design. I think what I'd try to do is pass back a QuestionID and an AnswerID per question to the database, or something akin to that. There are a lot of fun methods to accomplish this. A relatively easy one is to form xml in your save loop and pass this to SQL Server, and then parse this xml into a CTE using a custom table-valued function. I'm a little rusty on this one, but I believe you could also set up a user-defined table type in SQL Server with the QuestionID and AnswerID as the columns. Then in the save loop, you basically create a table to pass along. I believe you can do this with a DataSet. Again, I'm not as familiar with that way. Whatever method you choose, the main idea is to have one table/list of records or key-value pairs to save.
In SQL Server, then you just need to create an Update statement from this table or CTE.
If you need to clear out answers that have no selection, there are also several ways to do this. If you only pass back QuestionIDs that have an answer, you can use a not exists where clause to set the AnswerID to null or delete it altogether where that QuestionID is in the db table for that user but not in your passed in table or CTE. Or in your save loop, you could set the AnswerID to 0 or -1 or something like that when there's no selection for a quesiton, and in your Update use a Case statement to set the AnswerID to null when that value is present.
You can adjust this accordingly for your own setup, but I hope that helps get you started!

Formatting th:field in Thymeleaf

I have a form input field in Thymeleaf. The field (bookingEntry.datefrom in the code snippet below) is type Date. I use a datepicker to allow the user to select and format the required date to enter the field. This is all fine.
However, I want the initial value of the date (which I have set to the current date) to be displayed in the format that I choose. So, how do I format the date initially shown in a th:field. th:value is ignored (Thymeleaf is getting the value from the backing object, as it should) and I can't seem to apply a format to the th:field.
Thymeleaf code is:
<input type="text" class="form-control getdate"
th:field="*{datefrom}" placeholder="Date From"
th:value="${#dates.format(bookingEntry.datefrom, 'dd-MMM-yyyy')}"/>
I'm sure that I could use a String which is initialise in any format that I choose, rather than a Date type, but I wondered if there was a way to format initial values in a th:field?
Many thanks
I missed the simple answer, simply because of my limited knowledge of Spring. I'm adding it here incase it helps any other novices like me.
The #DateTimeFormat annotation on the element in the object being passed to the form does the job. It ensures that the Date object is formatted in the way that you wish (irrespective of whether you are using Thymeleaf or not).
In the example above, within the bookingEntry object
#Temporal(DATE)
#DateTimeFormat (pattern="dd-MMM-YYYY")
private Date datefrom;
In case your date is null, it will give you error. We have to check the value before we parse the date.
<input type="text" name="date"
th:value="${user.dateOfBirth}?${#dates.format(user.dateOfBirth, 'dd-MM-yyyy')}:''"
placeholder="dd-mm-yyyy" id="pickyDate"/>

Product Cart - > Moneris: two currency

We are attemption to customize the script to allow Canadian clients to process orders in CND dollars and all other clients to process orders in USD; however, we cannot authenticate with Moneris. Why is this script not authenticating?
we have modified 1 file.
gwMoneris2.asp - there we do the switch between gateway accounts depending of shipping country and display USD or CAD. The account info is hardcoded in that file as it was before update. Also we added there separate storeid/key for testing mode.
added code
gwMoneris2.asp
'// Set gateway specific variables - modified by egr-se
' Select account depending on Shipping country
if pcShippingCountryCode <> "CA" then
pcPay_Moneris_StoreId="245ZGD2111"
pcPay_Moneris_Key="dpQ87CRAVGP5"
else
pcPay_Moneris_StoreId="AXVRQ47259"
pcPay_Moneris_Key="dpNLNKHNYK6N"
end if
pcPay_Moneris_TransType=1
pcPay_Moneris_Lang="en-ca"
pcPay_Moneris_Testmode=0
pcv_CVV=0
pcPay_Moneris_Meth = 1
pcPay_Moneris_Interac =0
' Test mode id and key
if pcPay_Moneris_Testmode = 1 then
pcPay_Moneris_StoreId="HBHTA8ore1"
pcPay_Moneris_Key="dp1YDH2GJQR2"
end if
and line
<td><p><%=money(pcBillingTotal)%> <%if pcShippingCountryCode = "CA"
then%>CAD<%else%>USD<%end if%>$</p></td>
Based on this part of your code (the key starts with dp), it looks like your trying to setup a DirectPost integration:
pcPay_Moneris_StoreId="AXVRQ47259"
pcPay_Moneris_Key="dpNLNKHNYK6N"
In order to add support for USD currency the actual steps will vary based on the merchant account type (Canada merchant account vs. USA merchant account). The type of merchant account you have depends on where your bank account is located: bank accounts based in Canada will use the Canadian payment gateway (it supports both CDN and USD currencies) and bank accounts located in the US will use the USA payment gateway (it supports USD currency).
To recap here, are the possibilities:
Canadian bank account- CDN currency account (merchant account number will start with 003)
Canadian bank account- USD currency account (merchant account number will start with 003)
USA bank account- USD currency account (merchant account number will start with 295)
If you have a working integration with a Canada CDN account then setting up a Canada USD account is a piece of cake, you just login to your Canada USD merchant account, create your DirectPost config and copy and paste the credentials into your program (like in your example above).
However:
If you have a USA USD merchant account then the above steps won't work since the USA gateway has slightly different integration than the Canada gateway. You'll need to download the USA DirectPost Integration Guide from developer.moneris.com and use that to create another integration for the USA gateway.
For example:
Here's how you send a DirectPost purchase to the Canada Gateway (CDN and USD):
<FORM METHOD=”POST” ACTION=https://esqa.moneris.com/HPPDP/index.php>
<INPUT TYPE=”HIDDEN” NAME=”ps_store_id” VALUE=”AF4Fs1024”>
<INPUT TYPE=”HIDDEN” NAME=”hpp_key” VALUE=”dpHsjh4GSr4g”>
<INPUT TYPE=”HIDDEN” NAME=”charge_total” VALUE=”1.00”>
Credit Card:<INPUT TYPE=”text” NAME=”cc_num” VALUE=”4242424242424242”><br>
Exp Month:<INPUT TYPE=”text” NAME=”expMonth” VALUE=”04”><br>
Exp Year:<INPUT TYPE=”text” NAME=”expYear” VALUE=”07”><br>
<INPUT TYPE=”SUBMIT” NAME=”SUBMIT” VALUE=”Clickto process transaction”>
</FORM>
Here's how you send a DirectPost purchase to the USA Gateway (USD):
<FORM METHOD="POST" ACTION="https://esplusqa.moneris.com/DPHPP/index.php" >
<INPUT TYPE="HIDDEN" NAME="dp_id" VALUE="DNVRTqa002"><br>
<INPUT TYPE="HIDDEN" NAME="dp_key" VALUE="dp4IJ78RD5BM"><br><br>
<INPUT TYPE="TEXT" NAME="amount" VALUE="1.00"><br><br>
<INPUT TYPE="HIDDEN" NAME="order_no" VALUE ="oid43333">
Card Number:<input type="text" name=cc_num value="4242424242424242"><br>
Expiry Month:<input type="text" name=exp_month value="06">
Expiry Year:<input type="text" name=exp_year value="07"><br><br>
<input type="hidden" name=crypt_type value="7">
<!--MORE OPTIONAL VARIABLES CAN BE DEFINED HERE -->
<INPUT TYPE="SUBMIT" NAME="SUBMIT" VALUE="Click to process transaction">
</FORM>
You can see from above that the fields are the same but their names are slightly different depending on which gateway your using.

Resources