I’m trying to make a purchase request to a Simulator end point (https://test.sagepay.com/Simulator/VSPDirectGateway.asp), with the following data:
array(35) {
["VPSProtocol"]=>
string(4) "2.23"
["TxType"]=>
string(7) "PAYMENT"
["Vendor"]=>
string(9) "MY VENDOR NAME"
["AccountType"]=>
string(1) "E"
["Description"]=>
string(13) "My Test Order"
["Amount"]=>
string(4) "1.50"
["Currency"]=>
string(3) "GBP"
["VendorTxCode"]=>
string(1) "3"
["ClientIPAddress"]=>
NULL
["ApplyAVSCV2"]=>
int(0)
["Apply3DSecure"]=>
int(0)
["BillingFirstnames"]=>
string(3) "Sam"
["BillingSurname"]=>
string(4) "King"
["BillingAddress1"]=>
string(1) "1"
["BillingAddress2"]=>
string(1) "2"
["BillingCity"]=>
string(8) "Brighton"
["BillingPostCode"]=>
string(3) "BN1"
["BillingState"]=>
string(0) ""
["BillingCountry"]=>
string(2) "GB"
["BillingPhone"]=>
NULL
["DeliveryFirstnames"]=>
NULL
["DeliverySurname"]=>
NULL
["DeliveryAddress1"]=>
NULL
["DeliveryAddress2"]=>
NULL
["DeliveryCity"]=>
NULL
["DeliveryPostCode"]=>
NULL
["DeliveryState"]=>
string(0) ""
["DeliveryCountry"]=>
NULL
["DeliveryPhone"]=>
NULL
["CustomerEMail"]=>
NULL
["CardHolder"]=>
string(8) "Sam King"
["CardNumber"]=>
string(16) "4012888888881881"
["CV2"]=>
string(3) "123"
["ExpiryDate"]=>
string(4) "0215"
["CardType"]=>
string(4) "visa"
}
However, all I repeatedly keep getting back from Sagepay is a validation error:
"The CardHolder field should be between 1 and 50 characters long.”
However, as you can see in the above data array, I’m sending a CardHolder value of ‘Sam King’, which is clearly between 1 and 50 characters long.
For reference, I'm using the Omnipay (https://github.com/thephpleague/omnipay) library to make requests.
Any idea what I could be doing wrong here?
Related
I try to extract and to show on the page with echo product code field in K2store cart page (store extension for K2 for Joomla) but without success. The right value is "product_code" or "code" (is the same value): 26910.
Both "echo $item->product_name" and "echo $item->product_id" works, but "echo $item->code" and "echo $item->product_code" return NULL.
var_dump($item) show me this:
object(stdClass)#381 (13) {
["key"]=>
int(9928417)
["product_id"]=>
string(7) "9928417"
["product_name"]=>
string(71) "some title"
["product_model"]=>
NULL
["product_total"]=>
int(1)
["product_options"]=>
object(stdClass)#382 (0) {
}
["quantity"]=>
int(1)
["stock"]=>
object(JObject)#378 (18) {
["_errors":protected]=>
array(0) {
}
["item_enabled"]=>
string(1) "1"
["item_sku"]=>
NULL
["item_price"]=>
NULL
["special_price"]=>
NULL
["item_tax_id"]=>
NULL
["item_shipping"]=>
NULL
["item_qty"]=>
NULL
["item_cart_text"]=>
NULL
["product_id"]=>
string(7) "9928417"
["product_name"]=>
string(71) "some title"
["product_code"]=>
string(5) "26910"
["price"]=>
NULL
["product_sku"]=>
NULL
["tax_profile_id"]=>
NULL
["item_minimum"]=>
string(1) "1"
["stock"]=>
*RECURSION*
["product"]=>
object(stdClass)#354 (38) {
["id"]=>
string(7) "9928417"
["code"]=>
string(5) "26910"
["title"]=>
string(71) "some title"
["alias"]=>
string(71) "some title"
["catid"]=>
string(3) "694"
["published"]=>
string(1) "1"
["introtext"]=>
string(0) ""
["fulltext"]=>
string(0) ""
["video"]=>
NULL
["gallery"]=>
NULL
["extra_fields"]=>
string(29) "[{"id":"1","value":"25\/40"}]"
["extra_fields_search"]=>
string(6) "25/40 "
["created"]=>
string(19) "2012-09-14 10:20:09"
["created_by"]=>
string(2) "52"
["created_by_alias"]=>
string(0) ""
["checked_out"]=>
string(1) "0"
["checked_out_time"]=>
string(19) "0000-00-00 00:00:00"
["modified"]=>
string(19) "2012-09-14 10:30:46"
["modified_by"]=>
string(2) "52"
["publish_up"]=>
string(19) "2012-09-14 10:20:09"
["publish_down"]=>
string(19) "0000-00-00 00:00:00"
["trash"]=>
string(1) "0"
["access"]=>
string(1) "1"
["ordering"]=>
string(1) "1"
["featured"]=>
string(1) "0"
["featured_ordering"]=>
string(1) "0"
["image_caption"]=>
string(0) ""
["image_credits"]=>
string(0) ""
["video_caption"]=>
string(0) ""
["video_credits"]=>
string(0) ""
["hits"]=>
string(5) "17852"
["params"]=>
string(1190) "catItemTitle=
catItemTitleLinked=
catItemFeaturedNotice=
catItemAuthor=
catItemDateCreated=
catItemRating=
catItemImage=
catItemIntroText=
catItemExtraFields=
catItemHits=
catItemCategory=
catItemTags=
catItemAttachments=
catItemAttachmentsCounter=
catItemVideo=
catItemVideoWidth=
catItemVideoHeight=
catItemVideoAutoPlay=
catItemImageGallery=
catItemDateModified=
catItemReadMore=
catItemCommentsAnchor=
catItemK2Plugins=
itemDateCreated=
itemTitle=
itemFeaturedNotice=
itemAuthor=
itemFontResizer=
itemPrintButton=
itemEmailButton=
itemSocialButton=
itemVideoAnchor=
itemImageGalleryAnchor=
itemCommentsAnchor=
itemRating=
itemImage=
itemImgSize=
itemImageMainCaption=
itemImageMainCredits=
itemIntroText=
itemFullText=
itemExtraFields=
itemDateModified=
itemHits=
itemTwitterLink=
itemCategory=
itemTags=
itemShareLinks=
itemAttachments=
itemAttachmentsCounter=
itemRelated=
itemRelatedLimit=
itemVideo=
itemVideoWidth=
itemVideoHeight=
itemVideoAutoPlay=
itemVideoCaption=
itemVideoCredits=
itemImageGallery=
itemNavigation=
itemComments=
itemAuthorBlock=
itemAuthorImage=
itemAuthorDescription=
itemAuthorURL=
itemAuthorEmail=
itemAuthorLatest=
itemAuthorLatestLimit=
itemK2Plugins=
"
["metadesc"]=>
string(0) ""
["metadata"]=>
string(15) "robots=
author="
["metakey"]=>
string(0) ""
["plugins"]=>
string(27) "{"k2storeitem_enabled":"1"}"
["code_search"]=>
string(0) ""
["language"]=>
string(0) ""
}
}
["tax_amount"]=>
int(0)
["price"]=>
int(0)
["price_without_tax"]=>
int(0)
["total"]=>
int(0)
["total_without_tax"]=>
int(0)
}
The solution is: $item->stock->product_code
object(Zend_Paginator)#88 (11) {
["_cacheEnabled":protected]=>
bool(true)
["_adapter":protected]=>
object(Zend_Paginator_Adapter_Array)#89 (2) {
["_array":protected]=>
array(150) {
[0]=>
array(19) {
["location"]=>
string(15) "New York"
["id"]=>
string(3) "186"
["user_id"]=>
string(1) "2"
["date"]=>
string(10) "1367893034"
["attachment"]=>
string(1) "0"
["content"]=>
string(4) "nhzu"
["first_name"]=>
string(6) "John"
["last_name"]=>
string(6) "Doe"
["thumb_id"]=>
NULL
["thumb_user_id"]=>
NULL
["file_name"]=>
NULL
["folder_name"]=>
NULL
["server_key"]=>
NULL
["type"]=>
NULL
["photo_file_name"]=>
NULL
["photo_folder_name"]=>
NULL
["photo_server_key"]=>
NULL
["photo_id"]=>
NULL
["count_total"]=>
NULL
}
[1]=>
How do I acces the conectent of id without a foreach, I need only the first one 0 ? any ideas?
$item = $paginator->getItem(1);
See http://framework.zend.com/svn/framework/standard/tags/release-1.12.3/library/Zend/Paginator.php the public function getItem function definition
here is the obj :
array(2) {
[0]=> object(stdClass)#538 (9)
{
["term_id"]=> string(3) "152"
["name"]=> string(19) "Éducation physique"
["slug"]=> string(18) "education-physique"
["term_group"]=> string(1) "0"
["term_taxonomy_id"]=> string(3) "159"
["taxonomy"]=> string(11) "product_cat"
["description"]=> string(0) ""
["parent"]=> string(3) "123"
["count"]=> string(1) "3"
}
[1]=> object(stdClass)#540 (9)
{
["term_id"]=> string(3) "123"
["name"]=> string(5) "Sport"
["slug"]=> string(5) "sport"
["term_group"]=> string(1) "0"
["term_taxonomy_id"]=> string(3) "123"
["taxonomy"]=> string(11) "product_cat"
["description"]=> string(0) ""
["parent"]=> string(1) "0"
["count"]=> string(2) "49"
}
}
mam :
i try to get the value : [term_id] of 152. what i need it the "152" value in a variable. i try : $product_category->term_id it return "nothing"
and i try : $product_category['term_id'] it return "nothing"
How is the "proper" way to retreive value from object
thanks in advance !
If I'm reading you right, and $product_category is the entire variable, you have two objects in an array. So you'll need to tell PHP which array item you're after before trying to access the object.
Something like $product_category[0]->term_id should work.
Here is another solution :
Convert this object to an array using json_decode, then get the values from array
$array = json_decode($json_string, true);
$term_id = $array[0]['term_id'];
OR to get both values :
foreach($array as $val){
echo $val['term_id'];
}
I tried using Kohana/ORM on my localhost xampp and i get the following error
ErrorException [ Notice ]: Array to string conversion
MODPATH\orm\classes\kohana\orm.php [ 980 ]
975 }
976 else
977 {
978 // List columns and mirror for performance
979 $this->_table_columns = $this->list_columns();
980 $this->_table_columns = array_combine($this->_table_columns, $this->_table_columns);
981
982 // Load column cache
983 ORM::$_column_cache[$this->_object_name] = $this->_table_columns;
984 }
985 }
It seems to be a common error appearing in different Frameworks/PHP Applications, but I have not found any clue to fix it.
The Model is just the basic ORM
class Model_Product extends ORM {
}
The Mysql Table (InnoDB - UTF-8) has two fields
id - primary int
name - varchar 50
no voodoo anywhere, help is very appreciated
thanks in advance!
edit: the requested vardump
array(2) {
["id"]=>
array(13) {
["type"]=>
string(3) "int"
["min"]=>
string(11) "-2147483648"
["max"]=>
string(10) "2147483647"
["column_name"]=>
string(2) "id"
["column_default"]=>
NULL
["data_type"]=>
string(3) "int"
["is_nullable"]=>
bool(false)
["ordinal_position"]=>
int(1)
["display"]=>
string(2) "11"
["comment"]=>
string(0) ""
["extra"]=>
string(14) "auto_increment"
["key"]=>
string(3) "PRI"
["privileges"]=>
string(31) "select,insert,update,references"
}
["name"]=>
array(12) {
["type"]=>
string(6) "string"
["column_name"]=>
string(4) "name"
["column_default"]=>
NULL
["data_type"]=>
string(7) "varchar"
["is_nullable"]=>
bool(false)
["ordinal_position"]=>
int(2)
["character_maximum_length"]=>
string(2) "50"
["collation_name"]=>
string(15) "utf8_general_ci"
["comment"]=>
string(0) ""
["extra"]=>
string(0) ""
["key"]=>
string(0) ""
["privileges"]=>
string(31) "select,insert,update,references"
}
}
Line 980:
980 $this->_table_columns = array_combine($this->_table_columns, $this->_table_columns);
looks superfluous taken the previous line 979 into account:
979 $this->_table_columns = $this->list_columns();
Merging two times the same array is useless, especially as the array is this:
array(2) {
["id"]=>
array(13) {
["type"]=>
string(3) "int"
["min"]=>
string(11) "-2147483648"
["max"]=>
string(10) "2147483647"
["column_name"]=>
string(2) "id"
["column_default"]=>
NULL
["data_type"]=>
string(3) "int"
["is_nullable"]=>
bool(false)
["ordinal_position"]=>
int(1)
["display"]=>
string(2) "11"
["comment"]=>
string(0) ""
["extra"]=>
string(14) "auto_increment"
["key"]=>
string(3) "PRI"
["privileges"]=>
string(31) "select,insert,update,references"
}
["name"]=>
array(12) {
["type"]=>
string(6) "string"
["column_name"]=>
string(4) "name"
["column_default"]=>
NULL
["data_type"]=>
string(7) "varchar"
["is_nullable"]=>
bool(false)
["ordinal_position"]=>
int(2)
["character_maximum_length"]=>
string(2) "50"
["collation_name"]=>
string(15) "utf8_general_ci"
["comment"]=>
string(0) ""
["extra"]=>
string(0) ""
["key"]=>
string(0) ""
["privileges"]=>
string(31) "select,insert,update,references"
}
}
It only contains string keys. You should open a bug report with the kohana framework.
Comment line 980 until this get's fixed.
I found a way to resolve this error, just declare the table colums in the model.
protected $_table_columns = array(
'column' => NULL,
'names' => NULL,
'go' => NULL,
'here' => NULL,
......
);
this will ged rid of the problem and increase performance as well.
How do you point to the cid and get the value?
$item->?
array(1) {
[0]=>
object(__PHP_Incomplete_Class)#4 (4) {
["__PHP_Incomplete_Class_Name"]=>
string(7) "Product"
["_param:protected"]=>
array(40) {
["pid"]=>
string(3) "540"
["cid"]=>
string(2) "22"
["sid"]=>
string(1) "1"
["tid"]=>
string(1) "9"
["sales_volume"]=>
string(1) "0"
["preorder_volume"]=>
string(1) "0"
["viewed"]=>
string(1) "0"
["weight"]=>
string(4) "0.00"
["delivery_type"]=>
string(6) "postal"
["cash_price"]=>
string(4) "0.00"
["coupon_price"]=>
string(4) "0.00"
["coupon_require"]=>
NULL
["member_price"]=>
NULL
["discount_code"]=>
NULL
["special_offer"]=>
string(1) "0"
["lan"]=>
string(13) "eng,tchi,schi"
["special_offer_price"]=>
string(4) "0.00"
["special_offer_begin"]=>
string(19) "2010-09-06 11:25:05"
["special_offer_end"]=>
string(19) "2010-09-06 11:25:05"
["bonus_point"]=>
string(1) "0"
["tax"]=>
string(4) "0.00"
["release_date"]=>
string(19) "2010-09-06 11:25:05"
["begin_datetime"]=>
string(19) "2010-07-13 14:41:26"
["end_datetime"]=>
NULL
["delivery_status"]=>
string(4) "24hr"
["stock"]=>
string(1) "0"
["status"]=>
NULL
["discon"]=>
string(1) "0"
["product_desc"]=>
string(0) ""
["model_num"]=>
string(8) "ATH-BT03"
["rating"]=>
string(0) ""
["recycle_id"]=>
array(2) {
[0]=>
string(1) "5"
[1]=>
string(2) "20"
}
}
}
["doc:private"]=>
object(DOMDocument)#5 (0) {
}
}
}
Class property _param is protected and you can't get access to this one from outside.
Try to use reflection. You can find how to make private/protected property is public here http://mark-story.com/posts/view/using-the-php-reflection-api-for-fun-and-profit. May be it helps.
Looks like a pretty weirdly mixed object.
If I'm following correctly, it's an array that contains an object that has a property named _param that is an array with the key cid.
$item[0]->_param['cid']
The _param member is declared as protected, and can only be accessed from within the class itself, or from parent or inherited classes. The way to access this variable from outside of the class is to create and call a "getter" method, which would look like:
function getCid() {
return $this->_param['cid'];
}