how to add Customer Name - global-payments-api

$hostedPaymentData = new HostedPaymentData();
$hostedPaymentData->customerEmail = $this->customer_email;
$hostedPaymentData->customerPhoneMobile = $this->customer_mobile_phone;
$hostedPaymentData->addressesMatch = false;
How to add customer name in hosted payment data

The following all work, the comments are the POST variables they populate when requesting the HPP.
// HPP_NAME
$hostedPaymentData->customerName = 'asdf hjkl';
// HPP_CUSTOMER_FIRSTNAME
$hostedPaymentData->customerFirstName = 'asdf';
// HPP_CUSTOMER_LASTNAME
$hostedPaymentData->customerLastName = 'hjkl';

Related

SAP Business One - Add BP (DI Error: (-5002)

I am trying to add new addresses into a BP. If there is an address registered in the BP everything works, but now if it is new addresses return the error -5002 - Error updating BP: [OCRD.State2], 'the linked value' SP 'does not exist'
I test with SAP Business 10 (10.00.140) FP 2011
if (oBP.GetByKey(CardCode))
{
oBP.Addresses.SetCurrentLine(oBP.Addresses.Count - 1);
if (!string.IsNullOrEmpty(oBP.Addresses.AddressName))
{
oBP.Addresses.Add();
}
UF = json.data.endereco_uf;
if (UF.Length > 2)
{
UF = "";
}
oBP.Addresses.SetCurrentLine(oBP.Addresses.Count - 1);
oBP.Addresses.AddressName = "Novo 1";
oBP.Addresses.AddressType = BoAddressType.bo_ShipTo;
oBP.Addresses.Street = json.data.endereco_logradouro;
oBP.Addresses.Block = json.data.endereco_bairro;
oBP.Addresses.ZipCode = json.data.endereco_cep;
oBP.Addresses.City = json.data.endereco_municipio;
oBP.Addresses.State = UF;
oBP.Addresses.County = county;
oBP.Addresses.StreetNo = json.data.endereco_numero;
oBP.Addresses.BuildingFloorRoom = json.data.endereco_complemento;
oBP.Addresses.Add();
oBP.Addresses.SetCurrentLine(oBP.Addresses.Count - 1);
oBP.Addresses.AddressName = "Novo 2";
oBP.Addresses.AddressType = BoAddressType.bo_BillTo;
oBP.Addresses.Street = json.data.endereco_logradouro;
oBP.Addresses.Block = json.data.endereco_bairro;
oBP.Addresses.ZipCode = json.data.endereco_cep;
oBP.Addresses.City = json.data.endereco_municipio;
oBP.Addresses.State = UF;
oBP.Addresses.County = county;
oBP.Addresses.StreetNo = json.data.endereco_numero;
oBP.Addresses.BuildingFloorRoom = json.data.endereco_complemento;
oBP.Addresses.Add();
int iRetVal = oBP.Update();
if (iRetVal != 0)
{
Program.oApplication.StatusBar.SetText("Error updating BP: " + Program.oCompany.GetLastErrorDescription(), BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error);
return false;
}
SAP helped me to solve this issue. The answer follows.
I tried to reproduce this issue in the DemoUK (GB Localization) database and was able to reproduce as well.
After the investigation, it was found that you cannot link a state which does not exist for the specific country.
In your case, the system throws the error because the data is validated based on the following query:
SELECT* FROM OCST WHERE "Code" = 'SP' and "Country" = ''
Similarly, if I will try to set the State as 'Arizona' and Country as 'United Kingdom', it will give me the same error because the correct 'Country' value should be 'USA'.
Therefore, in order to resolve this issue, you need to opt out one of the following:
Set the Country property also in the DI Code (State should belong to the Country which you are trying to set):
oBP.Addresses.Country = "GB"
Remove the State property from the DI Code:
oBP.Addresses.State = "SP"

Salesforce first error: INVALID_CROSS_REFERENCE_KEY, Entity not available

When I am trying to run my test class I am getting the below error.
System.DmlException: Update failed. First exception on row 0 with id 8023B000000ekyaQAA; first error: INVALID_CROSS_REFERENCE_KEY, Entity not available: [PricebookEntryId]
Also in the stack trace of debug log I am getting the below message
Class.OBOrderLineItemCreate.updateObjectMethod: line 367, column 1
I have Created the product and referenced the Standard price book. And have created the Pricebookentry, Order and Order line item. I am not sure why I am getting this error. Can anyone please help me with this and let me know what am I doing wrong? Thanks in advance.
My test class code is as below
Product2 prod = new Product2();
prod.Name = 'Inb Enterprise';
prod.Description = 'Annual subscription,80 topics, 40,000 company locations';
prod.productCode = 'ABC';
prod.Service_Type__c = 'Inb';
prod.OB_Sub_Type_Name__c = 'Inb';
prod.isActive = true;
insert prod;
Pricebook2 standardPricebook = new Pricebook2(
Id = Test.getStandardPricebookId(),
IsActive = true
);
update standardPricebook;
standardPricebook = [SELECT Id, IsStandard FROM Pricebook2 WHERE Id = :standardPricebook.Id];
//Id pricebookId = Test.getStandardPricebookId();
//Test.startTest();
PricebookEntry standardPrice = new PricebookEntry();
standardPrice.Pricebook2Id = standardPricebook.Id;
standardPrice.Product2Id = prod.Id;
standardPrice.UnitPrice = 10000;
standardPrice.IsActive = true;
insert standardPrice;
Order ord = new Order();
ord.Name = 'Test Order';
ord.AccountId = acc.Id;
ord.Pricebook2Id = standardPricebook.Id;
ord.Customer_Success_Manager__c = am.Id;
ord.Agency_Name__c = agc.Id;
ord.OpportunityId = opp.Id;
ord.Purchase_Order__c = '783983';
ord.EffectiveDate = Date.today();
ord.Status = 'Draft';
ord.OBSyncStatus__c = 'Inactive';
ord.End_Date__c = Date.today();
insert ord;
OrderItem oli = new OrderItem();
oli.OrderId = ord.Id;
oli.PricebookEntryId = standardPrice.Id;
oli.Quantity = 5;
oli.UnitPrice = 35;
oli.OBSyncStatus__c = 'Inactive';
oli.Line_Item_Start_Date__c = Date.Today();
oli.Line_Item_End_Date__c = Date.Today();
oli.Bonus_Units__c = 25;
oli.Geography__c = 'US';
oli.Unique_Line_Item_Name__c = 'Inb Order';
insert oli;
You don't need the code of instantiating the Pricebook2 object. Get rid of that code and use the code below.
standardPrice.Pricebook2Id = Test.getStandardPricebookId().
Do the same for ord.Pricebook2Id also.

PRESTASHOP 1.6 Add a category to a product programmatically

In my module clients can add products to the shop, it will pass by a separate database.
When an admin check the products and validate one, i change the information to a prestashop product.
So i have this code :
$object = new Product();
$object->price = 32;
$object->id_tax_rules_group = 0;
$object->name = array((int)Configuration::get('PS_LANG_DEFAULT') => $creation['title']);
$object->id_manufacturer = 0;
$object->id_supplier = 0;
$object->quantity = 1;
$object->minimal_quantity = 1;
$object->additional_shipping_cost = 0;
$object->wholesale_price = 0;
$object->ecotax = 0;
$object->out_of_stock = 0;
$object->available_for_order = 1;
$object->show_price = 1;
$object->on_sale = 1;
$object->online_only = 1;
$object->meta_keywords = $creation['title'];
$object->active = 1;
$object->description_short = array((int)(Configuration::get('PS_LANG_DEFAULT')) => $creation['description']);
$object->link_rewrite = array((int)(Configuration::get('PS_LANG_DEFAULT')) => $creation['title']);
$object->id_category = 2;
$object->id_category_default = 2;
$object->addToCategories(array(2,13));
//SAVE
$object->save()
The product is saved and has the good information BUT it's not associated to any category.
When i go to my page products, where i can see all products, i see my product and the category is there BUT when i enter the details of the product and i go to the category list nothing is check.
i tried to see more in the code what is happenning and i saw this :
if (!in_array($new_id_categ, $current_categories))
$product_cats[] = array(
'id_category' => (int)$new_id_categ,
'id_product' => (int)$this->id,
'position' => (int)$new_categ_pos[$new_id_categ],
);
And after test the "if" is always true and so the product is association is never created.
I have check and this association does not exist.
I don't know what to do next, or if maybe i need to not use addToCategory, and enter maybe the data myself...
So please help thanks.
The method addToCategories() assigns categories to already created product. In other words you need to call the save() method of the Product class before calling addToCategories();

Orchard - Creating Query Programmatically

I am creating a custom module in Orchard. After I enable my module I would like to create a query programmatically.
I do that in my Migrations.cs file thanks to implementation of IDependency interface.
I am able to create the query but I do I programmatically set filters of that query?
var announcementsQuery = _contentManager.Create("Query");
announcementsQuery.As<TitlePart>().Title = "Announcements";
_contentManager.Publish(announcementsQuery);
I found out how to do this:
var announcementsQuery = _contentManager.Create("Query");
announcementsQuery.As<TitlePart>().Title = "Announcements";
announcementsQuery.As<QueryPart>().ContentItem.ContentType = "Announcement";
var filterGroupRecord = new FilterGroupRecord();
var filterRecord = new FilterRecord()
{
Category = "Content",
Type = "ContentTypes",
Description = "Announcement",
Position = 1,
State = "<Form><Description>Announcement</Description><ContentTypes>Announcement</ContentTypes></Form>"
};
filterGroupRecord.Filters.Insert(0, filterRecord);
announcementsQuery.As<QueryPart>().FilterGroups.Insert(0, filterGroupRecord);

Recipe for adding Drupal node records

I am looking for a recipe for adding Drupal node records.
I have identified three tables.
node_revisions
nid=249 - vid + 1?
vid=248 - auto-increment
node:
nid=250 - vid + 1?
vid=249 - auto-increment
content_type_my_content
vid=248 - from node_revisions table?
nid=249 - from node table?
Am I on right track?
Is there some helper functions for this?
If you are looking to programatically create nodes, use the Drupal API.
Start by creating a $node object. Fill in title, type, status, body, plus any CCK fields. At the end, call node_save($node);.
node_save will save your node object and do the necessary database work.
Check this out:
http://api.drupal.org/api/function/node_save/6
http://mediumexposure.com/how-build-node-drupal-programmatically/
The easiest way to see what each type of content type has as fields is to create a node (for example, Page), then use var_dump() to see the node's contents. That will show you every field you will need to use in your node object creation script.
Some folks will say you should create a form array, and call drupal_execute() on it so validation is performed before it's saved to the database. Either way is fine.
Kevin - With your help I have made good progress.
Node and CCK fields are now being populated.
Location (long/lat) is populated but not showing up on View screen.
Checkboxes are not being populated.
global $user;
$newnode = new stdClass();
$newnode->title = 'New node title';
$newnode->body = "this is a new node, created by import function";
$newnode->uid = $user->uid;
$newnode->type = 'items';
$newnode->status = 1;
$newnode->promote = 0;
// CCK fields
$newnode->field_myfield1[0]['value'] = 'test 1';
$newnode->field_myfield2[0]['value'] = 'test 2';
$newnode->field_mycheckbox[0]['value'] = 1;
// longitude, lalitude
// $newnode->locations[0]['lid'] = ?;
$newnode->locations[0]['street'] = 'xx';
$newnode->locations[0]['city'] = 'xx';
$newnode->locations[0]['province'] = 'xx';
$newnode->locations[0]['postal_code'] = 'xx';
$newnode->locations[0]['latitude'] = 0;
$newnode->locations[0]['longitude'] = 0;
$newnode = node_submit($newnode);
node_save($newnode);
content_insert($newnode);
OK. here is the full recipe. Drupal does the rest automagically.
global $user;
// Node fields
$newnode = new stdClass();
$newnode->title = $data[0];
$newnode->body = $data[1];
$newnode->uid = $user->uid;
$newnode->type = 'mytype';
$newnode->status = 1;
$newnode->promote = 0;
// CCK fields
$newnode->field_myfield1[0]['value'] = $something;
$newnode->field_myfield2[0]['value'] = $something;
$newnode->field_my_checkbox[0]['value'] = $something;
// longitude, latitude
$newnode->field_loc_latitude[0]['street'] = $something;
$newnode->field_loc_latitude[0]['city'] = $something;
$newnode->field_loc_latitude[0]['province'] = $something;
$newnode->field_loc_latitude[0]['postal_code'] = $something;
$newnode->field_loc_latitude[0]['latitude'] = '';
$newnode->field_loc_latitude[0]['longitude'] = '';
$newnode = node_submit($newnode);
node_save($newnode);
content_insert($newnode);