customise attribute/multiple tax on paypal order summary? - c#

I am not sure whether i am asking an obvious question here. but i couldn't find any suitable variable for following case in HTML Variables for Paypal Payments Standard documentation.
1) How to configure extra attribute with own defined label to be shown on order summary page. Let say i would like to have: number of person: 2 Extra description: abcsd.
2) How to configure multiple tax of different label? The default i found is label with tax and only 1 tax?
GST: 10% Service Tax: 6%
Both of above seems to be a simple implementation to me, but i just couldn't find the solution using the documentation.

1) You can use the "custom" parameter to include any custom data you need to pass in the request. The field is literally called custom, and you can send up to 256 characters in this field.
2) Payments Standard only supports passing a single tax amount (that you calculate yourself) or a tax rate that would be calculated against the order amount. If you need to separate different tax rates/rules, you'll have to do that in your own shopping cart / order system.

Related

How is the correct format for a PUT querystring?

I need to build a PUT method which will receive a insurance policy number and a star date of the relevant period. This method will update the start relevant period, so since there's an update, the method was defined as a PUT verb.
What would be the correct format for my method? I'm confused over two ways of possible correct formats:
http://<url>:<port>/api/valuation/<policy number>/<start date>
or
http://<url>:<port>/api/valuation/<policy number>
and receive the date from body?
In both cases, how do I declare the Route (I'm using .net framework 4.5)
For the option #1
[Route("UpdatePeriod/{numPolicy}/{startDate}")]
public IHttpActionResult UpdatePeriod(string numPolicy, string startDate)
For the option #2
[Route("UpdatePeriod/{numPolicy}")]
public IHttpActionResult UpdatePeriod(string numPolicy, [fromBody] string startDate)
Can someone give me a hint? I'm a little lost about this.
Thanks in advance.
It may come down to preference but what I would add is that it's really about organizing the URL in a logical way that makes sense using nouns and actions. So really it's about the most intuitive and reasonable representation of how your data works while following best practices and conventions.
So let us look at your examples.
http://<url>:<port>/api/valuation/<policy number>/<start date>
When I look at this it appears to me that this represents the data such that multiple insurance policies with the same policy number exist and you want to filter that down to one with the start date provided. I'm not sure how your data looks or if there should always be one valid insurance policy given a policy number but this wouldn't make much sense to me.
http://<url>:<port>/api/valuation/<policy number>
This suggests to me that there is one insurance policy given the policy number. This seems like the more likely scenario so I'll start with this one as scenario 1.
Scenario 1
If you know that you'll be acting upon one insurance policy that is valid given a policy number then it would not make sense to have the start date in the URL. You'll want it in the POST data you get through the body because you'll be acting upon that one insurance policy. #2 is your bet in this case and you'll want to make "valuation" plural.
Your URL's would look something like this:
# returns all insurance policies`
GET "http://<url>:<port>/api/valuations"
# returns one insurance policy with given policy number
GET "http://<url>:<port>/api/valuations/<policy number>"
# acts upon the insurance policy with that number, very broad
PUT "http://<url>:<port>/api/valuations/<policy number>"
# acts upon the insurance policy with number but in a more specific way with a dedicated method
# start date would be in your post that you would then bind to a view model
PUT "http://<url>:<port>/api/valuations/<policy number>/startdate"
Scenario 2
If you know that you'll be fetching more than one insurance policy given an insurance policy number and want to filter that by the start date then it would make sense to have it in the URL. The URL would look something like this:
PUT http://<url>:<port>/api/valuations/<policy number>/startdate/<start date>
Why? Because you're acting on one insurance policy from a list of insurance policies with the same insurance policy number with differing start dates.
So your URL's would look something like this:
# returns all valuations insurance policies`
GET "http://<url>:<port>/api/valuations"
# returns list of insurance policies with the same policy number
GET "http://<url>:<port>/api/valuations/<policy number>"
# return one insurance policy with the policy number and start date
GET "http://<url>:<port>/api/valuations/<policy number>/startdate/<start date>"
# updating information for that ONE policy with policy number and start date
PUT "http://<url>:<port>/api/valuations/<policy number>/startdate/<start date>"
I am basing my answer off noun based API urls and not verb based.
For more on this: Confusion Between Noun vs. Verb in Rest URLs
If you're passing start date as a POST parameter you should probably have that bound to a view model:
class ValuationPolicyStartDateViewModel
{
public DateTime? StartDate { get; set; }
}
// then in your controller
// PUT StartDate = "01/22/2018" will then be bound to your view model
public IHttpActionResult UpdatePolicyByStartDate(string policyNumber, [FromBody] ValuationPolicyStartDateViewModel viewModel)
{
... code that validates etc ...
}
TL;DR
If /api/valuation/<policy number> returns 1 insurance policy, go with option 2 in your examples and make "valuation" plural.
If /api/valuation/<policy number> returns more than 1 insurance policy then you should do a couple things: change valuation to valuations and add startdate as a filter variable.

How do I add decimals in Xamarin Forms Entries using C#

For starters I'm very very new to writing code! :)
What I have so far...
So far I've used Xamarin.Forms to create a user interface for a sort of specialized calculator. I'm using a Grid Layout containing: a first column of Labels, a second column of Entries (that I have named in Xaml), and a third column of Steppers (so I can change the entries by typing or using the stepper). These 3 views on each row repeat for several rows with different label text on each row and at the bottom of the Grid Layout I have an Entry for the output.
The problem...
Basically, I want to buy a certain product at different weights and prices...among other criteria....and I want to quickly figure out how much money I'll make at a future possible sale price. Simply put... I'm trying to add/subtract/multiply/divide using Xamarin.Forms Entries. I've looked everywhere and can't seem find anyone giving an example of how to do this. I've tried different methods and usually end with an error of not being able to convert the Xamarin.Forms entry to a string...So I'm back to zero. Can I get an example of a Method where I would be able to add/subtract/multiply/divide 2 Xamarin.Forms Entry views together in the C# code behind? This seems very simple to me...what am I missing??? Is there a thread/article/video somewhere that I haven't found that covers this?? And like I said, I'm very new so the answer is probably very simple.
Thanks in advance!
Steven
Entries deal with strings, not numeric values, so you need to convert them before doing calculations.
var amount = Decimal.Parse(EntryA.Text);
var price = Decimal.Parse(EntryB.Text);
var total = amount * price;
// you can use a format string as an argument to ToString()
// to control the output - ie, how many decimals, commas, etc
LabelTotal.Text = total.ToString();
In a real app you will want to validate the input in case the user enters text instead of a value number (the Parse method will throw an exception if the input is bad);

Getting the latest pair value with Kraken API

I am trying to get the latest value/rate for a given pair using the Kraken API, but I cannot really figure it out.
Is there anyone that knows how to do it?
I am using the C# code provided on Git (https://github.com/trenki2/KrakenApi) and thought using the following function was the way to go:
client.GetRecentTrades("XETHZEUR",ID)
I however don't want to use an ID, which seems to be optional according to Kraken Website.
I just want to know what is the current value, nothing more.
I have also used GetTicker to get the last trade, but this does not come with a Time stamp and will not give the actual currency pair value.
Cheers
Both GetTicker and GetRecentTrades will give you the value of the last trade. You can use either depending on what other data you need. I guess there could be some difference because most likely Kraken caches the results.
Of the two methods above only GetRecentTrades will provide a timestamp.
Alternatively instead of getting the last trade you can call GetOrderBook and calculate the average between the lowest Ask price and highest Bid price.

MDB protocol (multidrop bus) - C# serialport communication

I am in the process of developing a MDB software in C# as a payment reader media that communicates with a vending machine through MDB protocol. Currently everything works OK and i am able to communicate with the vending machine. The communication is like expected after reading the MDB protocol but i am having trouble understanding some commands/respones...
I just have one question regarding a response i should send back to the vending machine that may be really stupid, but i really don't understand how it should be sent.
As shown in the MDB protocol, when i get a POLL from the MDB machine and the state of the reader (my computer) is "Session Idle", i can then send a "Begin Session" command to the vending machine. The commands are sent in bytes over serial port and are shown as HEX or Binary in the MDB protocoll. The BEGIN SESSION command should contain the following:
Z1 Begin Session
Z2-Z3 Funds Available
Z4-Z7 Payment media ID
Z8 Payment Type
Z9-Z10 Payment Data
I understand Z1-Z7 because of good examples in the MDB protocol, but i am having trouble understanding Z8-Z10 (payment type and payment data).. The examples are not self explained in my head..
The MDB protocol says the following:
""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Z8 : Type of payment:
00xxxxxxb = normal vend card (refer EVA-DTS Standard, Appendix A.1.1 Definitions)
x1xxxxxxb = test media
1xxxxxxxb = free vend card
xx000000b -0 VMC default prices
xx000001b -1 User Group (Z9 = EVA-DTS Element DA701)
Price list number (Z10 = EVA-DTS Element LA101)*
xx000010b
-2 User Group (Z9 = EVA-DTS Element DA701)
Discount group index (Z10 = EVA-DTS Element MA403)
xx000011b
-3 Discount percentage factor (Z9=00, Z10 = 0 to 100**,
report as positive value in EVA-DTS Element MA404)
xx000100b
-4 Surcharge percentage factor (Z9=00, Z10 = 0 to 100**,
report as negative value in EVA-DTS Element MA404)
* User Group is a segmentation of all authorized users.
It allows selective cost allocation.
A User Group usually has no direct relation to a price list.
Price Lists are tables of prices.
Each Price List contains an individual price for each product.
Discount Group indicates the Price List on which the Percentage Factor will be applied.
If the User Group, the Price List or Discount Group is unknown by the VMC,
the normal prices are used (Z8 is defaulted to 00h).
Minimum value for Z9 and Z10 is 0.
** Percentages are expressed in binary (00 to 64h)
Note: These functions may NOT be supported by all VMCs.
Z9-Z10 : Payment data as defined above
""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Can somebody please tell me how Z8 and Z9-Z10 should be sent to the vending machine. Now i have been sending (in hex): "0x02 (Z8), 0x10 (Z9) and 0x10 (Z10)" which is just a wild guess and it is working. Don't really know why but its probably not correct.
How should Z8 and Z9-Z10 be sent?
The EVA-DTS standard is its own separate standard.
MDB-ICP is a communication protocol.
EVA-DTS is a data format standard.
MDB optionally (keyword optionally) uses/integrates EVA-DTS data, which is what its asking for here.
EVA-DTS data is human readable values in ascii text/numbers separated by asterixes in a defined order and length. Each unit of data between an asterisk, is called a data element.
Z9 in options 1&2, refers to data element DA701, where if you look in Appendix A of the EVA-DTS-6.2.2 standard, the DA701 has the element name "Cashless1 user group number", which is of data type N0 meaning a number without any implied decimal points, a minimum length of 1 digit and a maximum of 13. In MDB, isn't sent as an ASCII string of characters like "15", instead, you use hexadeximal numerical representations, so usergroup 15 would be 0x0F. The usergroup if not using it,you can just put 0x01 for everyone. Its used to group people, with different price tables, giving different prices to different people. Not sure if thats a MDB feature, but any VMC could implement it if not. All optional.
Z9 you can look up yourself
Z8, First two Most Significant bits are used to indicate if it was a vend card paying (as in credit card, or any real form of cashless payment). the rest of the digits it depends on the vend. you use one of the 4 options (read appendix A section 1.1 of the DTS standard to get definitions of what they mean and which ones are appropriate in that situations. Depending on the option used (1, 2, 3, or 4) that decides what Z9 & Z10 are, like option 3 says z9 would be 0x00 and Z10 would become a percentage (since z8 would describe a percentage discount given), while if u pick option one, Z10 instead contains the value of DTS element LA101.
Hope that's not too wordy or incoherent. good luck too, we're competitors.

Parameter that depends on a Decision in MSF

In Microsoft Solver Foundation, I'd like to know if it's possible to add a parameter who's value depends on a decision value.
I.e. I want something to the TSP model, but it should also take in account traffic from one point to the other. Please note: traffic depends on the time when the sales man travels on that route.
Here is the model:
I have a matrix of all possible combinations between the cities.
The Decision variable is the Order of the sales man's route. 0 is the first, 1 second,...
I have a property timeToTravel which is bound to a property that calculates the time when the route will take place from the Order value and it returns the travel time including traffic for that time of the day.
It seems to me that the parameter values are read once and cached when the Solve function is called, am I correct? If yes, does anybody have any recommendations to solve this problem?
Originally I asked this question on the MSF forum but I thought it would get more attention on Stack Overflow. Also I'm open to different solvers other than MSF but I'd prefer to stay in the .NET environment.
There is a good article on solving the "static" Traveling Salesman Problem using Solver Foundation here. If you do not already have your own implementation, maybe you can base your solution on that code.
This is the goal formulation from the mentioned article:
// Goal: minimize the length of the tour.
Goal goal = model.AddGoal("TourLength", GoalKind.Minimize,
Model.Sum(Model.ForEach(city, i =>
Model.ForEachWhere(city,
j => dist[i, j] * assign[i, j], j => i != j))));
If I understand correctly, in your problem the time to travel between two cities is dependent on the time-of-the-day?
I do not believe you can dynamically update the dist[,] double array during the optimization. However, using the building blocks of the Model class it should be possible to reformulate the dist[,] array as a set of functions that are dependent on the total distance/time already traveled.
For completeness, here is another interesting article on TSP formulation using OML.

Categories

Resources