Sagepay - The Basket format is invalid - opayo

I am trying to submit a payment to sagepay (form version 2.2) but keep getting the following error. Can anyone point me in the right direction?
Status Detail: 3021 : The Basket format is invalid.
The basket string is:
Nike Dri Fit Jersey Turtle Neck 2:3:£96.00:£0.00:£96.00:£288.00
regards

v2.22 below.
You need to include the 'Number of lines of detail in the basket field:'
Note - the 'Number of lines of detail in the basket field' is not the total number of items ordered but the total number of rows of basket information.
The shopping basket contect can be passed in a single, colon-delimited field and results in looking like your example * however you need to include the 'Number of lines of detail in the basket field' so should look like **
Your example *
Nike Dri Fit Jersey Turtle Neck 2:3:£96.00:£0.00:£96.00:£288.00
Corrected example **
1:Nike Dri Fit Jersey Turtle Neck 2:3:£96.00:£0.00:£96.00:£288.00
You should send example below -
Number of lines of detail in the basket field: 1
Item 1 Description: Nike Dri Fit Jersey Turtle Neck 2
Quantity of item 1: 3
Unit cost item 1 without tax: £96.00
Tax applied to item 1: £0.00
Cost of Item 1 including tax: £96.00
Total cost of item 1 (Quantity x cost including tax): £288.00
Multiple lines can be sent as the below and notice the 4 at the start of the example shows there would be 4 lines within the basket.
4:Pioneer NSDV99 DVD-Surround Sound System:1:£424.68:£74.32:£499.00: £499.00:Donnie Darko Director’s Cut:3:£11.91:£2.08:£13.99:£41.97: Finding Nemo:2:£11.05:£1.94:£12.99:£25.98: Delivery:---:---:---:
---:£4.99
Sage Pay now run on v3.00 where the £ symbol is not confirmed in the Basket field.
1:Nike Dri Fit Jersey Turtle Neck 2:3:96.00:0.00:96.00:288.00
If you wish to migrate/upgrade to v3.00, how to instructions is available on Sage Pay website.

Related

Magento 1.9 Set an Attribute value calling another value (weight)

So, right now i have 2 shipping options, and since shipping is by weight and my site is B2B, customers want to know the exact final price they are paying, without reaching to cart, for every single product.
So, on the additional information block, i have the weight to display, and i want to add another 2 attributes, one for each shipping cost, the thing is that on each of this attributes, i need to multiply the weight value to a cost per lb...
Example:
Regular shipping cost costs $5 per lb and Express $8 per lb
I have product A that weights 0.34 lbs
So what i need is that when i go into the product page, in the additional info, to see this 2 attributes:
Regular Shipping: (Value would be 0.34 * 5) $1.70
Express Shipping: (Value 0.34 * 8) $2.72
is this possible?
short answer: yes.
it is for sure is possible.
Should't there be more calculation logic? Like minimal shipping cost/weight per carrier?
If you want to re-use magento logic, then a quote object has to be created. Which means putting this product into cart. But since you dont want this simply implement your own logic in a custom block and add it to additional info or whereever you need it.

How to Remove Trailing Zeros in XPath?

I have some not very clean 3rd party data that included numbers like:
PRICE
118.0000
99.0000
etc etc
normally would just use:
{price[1]}
but I just get price like $18,000,000.00 where it should be $118
I tried this (just guessing) ...
number{('price[1]')}
but nothing showed up for the price.
I also tried
format-number{(., 'price[1]')}
but that did not work.
Then I read I can use
translate(#Price, ',.', '.')
I tried that as
translate(#price, ',.', '.')
but no price showed
I then tried several variations using the [1] part , I'm only guessing as I'm not really a coder:
{translate(#price[1], ',.', '.')}
{translate(#price[1],',.','.')} ( I clean the spaces out)
then this one
translate(#price[1], ',.', '.')
and it finally showed a price but only as $1.00 where it should have been $1055 or another one should have been $1145 but they all showed $1.00
What can I do, it must be all on one line as it goes in my web based form to be submitted to import the data?
UPDATED:
Here is what I tried to write in the comments:
I tried these below and this is the results.I used your exact examples including the price as in the first 2 examples, then I tried with the "price" code but that is producing a $1 price again.
substring-before(118.00, '.') $11,800.00
substring-before('118.00','.')$11,800.00
substring-before('price[1]','.')$1.00
substring-before(price[1], '.')$1.00
I also tried using the brackets as I would normaly but that produces no price...
{substring-before(price[1], '.')}
{substring-before('price[1]','.')}
{substring-before('118.00','.')}
{substring-before(118.00, '.')}
I have tried to upload a much smaller copy of some of the input document and just changed some private details with "privatedomain" but I have no permission to include the links so they were deleted.
PROGRAMNAME PROGRAMURL CATALOGNAME LASTUPDATED NAME KEYWORDS DESCRIPTION SKU MANUFACTURER MANUFACTURERID UPC ISBN CURRENCY SALEPRICE PRICE RETAILPRICE FROMPRICE BUYURL IMPRESSIONURL IMAGEURL ADVERTISERCATEGORY THIRDPARTYID THIRDPARTYCATEGORY AUTHOR ARTIST TITLE PUBLISHER LABEL FORMAT SPECIAL GIFT PROMOTIONALTEXT STARTDATE ENDDATE OFFLINE ONLINE INSTOCK CONDITION WARRANTY STANDARDSHIPPINGCOST
PrivateName (deleted link) PrivateName - Product Catalog 2015-03-21 23:06:21.558 Ainsley Cuff, Gold $100-$299, cuff, gold, Open Cuff Captivatingly colorful, Kendra Scott’s collection will spruce up a basic sweater and can simultaneously fancy up a dressier cocktail frock. Her pieces have a southern influence, which brings fun, festivity, and charm to the collection’s aesthetic. 14k Gold Plated 2 Inches Wide Malleable kens-00005B Kendra Scott USD 120.0000 (deleted link) (deleted link)/jpeg_1.jpg Bracelets All Jewelry ,Designers,Shop All,All Jewelry,A-Z Designers,Shop by Occasion,Best of PrivateName,Kendra Scott,Office,Everyday,Vacation,Classic,Casual,Byzantine,Black and White,Gold,Cuff,Destination: Morocco,Back in Stock,Kendra Scott,Bracelets yes
PrivateName (deleted link) PrivateName - Product Catalog 2015-03-21 23:06:21.559 Crystal Deco Brooch $100-$299, crystal "Part of the Ben-Amun Evening Collection. Antique silver-plated over brass Clear Swarovski crystals Length 2.5"" NOTES: This product is made-to-order. Please allow up to 2-3 weeks for delivery. Expedited shipping is not available." BAMU-00037P Ben-Amun Bridal USD 195.0000 (deleted link) (deleted link)/jpg_2.jpg Brooches Collections,Shop By,Designers,Brooches,All Jewelry,Bridal,A-Z Designers,Jewelry Trends,Evening,Bridal,Deco,Crystal,Estate,Ben-Amun Bridal,Shop All yes
PrivateName (deleted link) PrivateName - Product Catalog 2015-03-21 23:06:21.559 Gold Teardrop Cutout Earrings $0-$100, gold "Wendy Mink’s jewelry mixes aspects of traditional Eastern jewelry with classic European design principles. Her pieces are carefully handmade with simple yet unexpected combinations of colors, materials, and shapes. Her collection draws inspiration from textiles created by women in India, Nepal, and Tibet—three regions she spent a great deal of time in while holding a position at the World Bank prior to reinventing herself as a jewelry designer. Gold-plated, 18kt Length 2.5"" Width 1.75"" French wire hook NOTES: This item is made to order and may take up to 3 weeks for delivery." wndm-00107E Wendy Mink USD 73.0000
Please let me know if you need anything else:
If you are using XPATH 1.0 you might be able to use substring-before(xpath, expression)
substring-before(118.00, '.')
should give 118 if I'm not mistaking.

Joomla K2 content sort by number of votes

I'm using Joomla 2.5 and K2 2.5.7. I have a category with posts with a different number of votes. In the front end, I need to sort the items of this category by number of votes.
I re-configured standard stars rating systems to simple "Give one vote" system.
I need this for a ranking order page, so it will have items with the largest number of votes on the top.
What I have
I have my MVC template for K2 category. I was wondering, if sorting $this->leading in category.php is the right to go for.
If it is, how can I do it? With var_dump there is variable numOfVotes which carry real number of votes. How can I sort this object by this var?
Thank you very much!
This K2 forum post seems to answer your question. You need to use the mod_content k2 module and use the "sort by" parameter and select highest rating.
If you go to 'modules/mod_k2_content/helper.php' in the ftp, you'll see on line 98, that there it says
$query .= ", (r.rating_sum/r.rating_count) AS rating";
This sorts the data by the highest rating. Now generally this would sort it by the number of votes divided by the number of people who have voted giving a result between 1 and 5. However as everyone in your case gets a vote of 5 - then your average result will always be 5 by that calculation!, I think that you'll have to replace that line with:
$query .= ", r.rating_count AS rating";
i.e. just sorting by the number of people who have voted (N.B. This assumes you're not using a vote down system as well! You haven't mentioned it so I'm assuming not)
Then you should just be able to use the module (selecting the parameter that you desire as normal)
For using the component category option etc. Then the same line of code can be found in 'components/com_k2/models/itemlist.php' on Line 39 which again would need to be edited. Then you could just use the built in parameters as usual!

Magento Option Question

This seems simple enough in theory but I haven't found anything on it. I need it for a client. Please see this page as an example: http://www.customsportsteamuniforms.com/index.php/test-shirt.html
On that page, you will find the first option that says "What kind of Screen Printing do you want?" If you select 1 color and you also happen to want more than 1 quantity (let's say 5), you will end up with this formula for the product cost:
$5 (cost) x $25 (option) x 5 quantity = total.
I DO NOT want it to do that. The option should be a one time fee in this case. The formula should read:
$5 (cost) x 5 quantity = sub-total + $25 (option) = total
How do I do this?
Magento's additional fees are all calculated on a per-product basis. If you want to add a fee to the entire order, you'll need to add some custom code to add this as a sort of handling fee for the order. The semantics for this are up to you (for instance, what about 2 different shirts both with 1-color screen printing options).
I found a plugin that does this:
http://www.absolutepricing.com/
Although, in my opinion, this should have been part of the system to begin with, but that's neither here nor there...

Algorithms or Patterns for reading text

My company has a client that tracks prices for products from different companies at different locations. This information goes into a database.
These companies email the prices to our client each day, and of course the emails are all formatted differently. It is impossible to have any of the companies change their format - they will not do it.
Some look sort of like this:
This is example text that could be many lines long...
Location 1
Product 1 Product 2 Product 3
$20.99 $21.99 $33.79
Location 2
Product 1 Product 2 Product 3
$24.99 $22.88 $35.59
Others look sort of like this:
PRODUCT       PRICE   + / -
------------  -------- -------
Location 1
1             2007.30 +048.20
2             2022.50 +048.20
Maybe some multiline text here about a holiday or something...
Location 2
1             2017.30 +048.20
2             2032.50 +048.20
Currently we have individual parsers written for each company's email format. But these formats change slightly pretty frequently. We can't count on the prices being on the same row or column each time.
It's trivial for us to look at the emails and determine which price goes with which product at which location. But not so much for our code. So I'm trying to find a more flexible solution and would like your suggestions about what approaches to take. I'm open to anything from regex to neural networks - I'll learn what I need to to make this work, I just don't know what I need to learn. Is this a lex/parsing problem? More similar to OCR?
The code doesn't have to figure out the formats all on its own. The emails fall into a few main 'styles' like the ones above. We really need the code to just be flexible enough that a new product line or whitespace or something doesn't make the file unparsable.
Thanks for any suggestions about where to start.
I think this problem would be suitable for proper parser generator. Regular expressions are too difficult to test and debug if they go wrong. However, I would go for a parser generator that is simple to use as if it was part of a language.
For these type of tasks I would go with pyparsing as its got the power of a full lr parser but without a difficult grammer to define and very good helper functions. The code is easy to read too.
from pyparsing import *
aaa =""" This is example text that could be many lines long...
another line
Location 1
Product 1 Product 2 Product 3
$20.99 $21.99 $33.79
stuff in here you want to ignore
Location 2
Product 1 Product 2 Product 3
$24.99 $22.88 $35.59 """
result = SkipTo("Location").suppress() \
# in place of "location" could be any type of match like a re.
+ OneOrMore(Word(alphas) + Word(nums)) \
+ OneOrMore(Word(nums+"$.")) \
all_results = OneOrMore(Group(result))
parsed = all_results.parseString(aaa)
for block in parsed:
print block
This returns a list of lists.
['Location', '1', 'Product', '1', 'Product', '2', 'Product', '3', '$20.99', '$21.99', '$33.79']
['Location', '2', 'Product', '1', 'Product', '2', 'Product', '3', '$24.99', '$22.88', '$35.59']
You can group things as you want but for simplicity I have just returned lists. Whitespace is ignored by default which makes things a lot simpler.
I do not know if there are equivalents in other languages.
You have given two pattern samples for text files.
I think these can be handled with scripting.
Something like: AWK, sed, grep with bash scripting.
One pattern in the first sample,
Section starts with keyword Location [Number]
second line of section has columns describing product names
third line of section has columns with prices for the products
There can be variable number of products per section.
There can be variable number of sections per file.
Products and prices are always on their designated lines of a section.
Whitespace separation identifies the (product,price) column-association.
Number of products in a section matches the number of prices in that section.
The collected data would probably be assimilated in a database.
The one thing I know I would use here is regular expressions. Three or four expressions could drive the parse logic for each e-mail format.
Trying to write the parse engine more generally than that would, I think, be skirting the edge of overprogramming it.

Resources