I can't seem to get this to work:
I have a parent company called
"XYZ Parent Company"
and a sub company called
"XYZ sub Company"
The Parent company exists in quickbooks already. I need to add the sub company with the parent know. I try this and it does not add the child only makes new customer. I am sure I am missing two things but I can't find what???
include 'blah blah directoty/example_app_ipp_v3/config.php';
// Set up the IPP instance
$IPP = new QuickBooks_IPP($dsn);
// Get our OAuth credentials from the database
$creds = $IntuitAnywhere->load($the_username, $the_tenant);
// Tell the framework to load some data from the OAuth store
$IPP->authMode(
QuickBooks_IPP::AUTHMODE_OAUTH,
$the_username,
$creds);
// Print the credentials we're using
//print_r($creds);
// This is our current realm
$realm = $creds['qb_realm'];
// Load the OAuth information from the database
if ($Context = $IPP->context())
{
// Set the IPP version to v3
$IPP->version(QuickBooks_IPP_IDS::VERSION_3);
$CustomerService = new QuickBooks_IPP_Service_Customer();
$Customer = new QuickBooks_IPP_Object_Customer();
$Customer->setName('99999');
//$Customer->setPhone('860-634-1602');
//$Customer->setEmail('keith#uglyslug.com');
$Customer->setCompanyName('XYZ Sub Company Name');
$Customer->setDisplayName('XYZ Sub Company Name');
$Customer->setFirstName('Bill');
$Customer->setLastName('Gates');
// Set the parent of the customer
$Customer->setParentFullName('XYZ Existing Parent Company Name');
This is incorrect:
// Set the parent of the customer
$Customer->setParentFullName('XYZ Existing Parent Company Name');
Per the QuickBooks API docs (http://developer.intuit.com/) you must specify the parent Id value to add a sub-customer underneath the parent customer. You can not specify the FullName (FullName isn't even a valid field name for the REST APIs, not sure where you got that from...).
You should be specifying:
$Customer->setParentRef(1234);
Where 1234 is the Id of the parent customer.
If you don't know the Id of the parent customer, you can query it like this:
$customers = $CustomerService->query($Context, $realm, "SELECT * FROM Customer WHERE FullyQualifiedName = 'your parent customer name here');
$Id = $customers[0]->getId();
Related
I'm currently using square/connect-php-sdk createOrder to create a Square Order.
$api_config = new SquareConnect\Configuration();
$api_config->setAccessToken($access_token);
$api_config->setHost($host);
$api_client = new SquareConnect\ApiClient($api_config);
$apiInstance = new SquareConnect\Api\OrdersApi($api_client);
$orderRequest = new SquareConnect\Model\CreateOrderRequest();
$orderRequest->setIdempotencyKey(uniqid());
$order = new SquareConnect\Model\Order();
$money = new SquareConnect\Model\Money();
$money->setAmount(intval(500))
->setCurrency("USD");
$line_item = new SquareConnect\Model\OrderLineItem();
$line_item->setCatalogObjectId(<square item id>)
->setQuantity("1")
->setBasePriceMoney($money);
$line_items[] = $line_item;
$order->setLineItems($line_items);
$orderRequest->setOrder($order);
$result = $apiInstance->createOrder($location_id, $orderRequest);
This returns an Order ID (along with other order data) which I store locally.
I then process a credit card using the Square Payment Form: https://developer.squareup.com/docs/payment-form/payment-form-walkthrough
This gives me a nonce which I then send with the Order ID and the price.
$apiInstance = new SquareConnect\Api\PaymentsApi($api_client);
$paymentRequest = new SquareConnect\Model\CreatePaymentRequest();
$paymentRequest->setIdempotencyKey(uniqid());
$paymentRequest->setLocationId($location_id);
$money = new SquareConnect\Model\Money();
$money->setAmount(intval($total_cost))
->setCurrency("USD");
$paymentRequest->setAmountMoney($money);
$paymentRequest->setOrderId($sq_order_id);
$paymentRequest->setSourceId($nonce);
$result = $apiInstance->createPayment($paymentRequest);
This gives me a Payment ID (along with other payment data).
On the Square Dashboard, I am able to see the transaction in the Transactions section, but the Orders section of the dashboard is empty.
My question is How do I get it to show in the Orders section?
In order for the order to show up in your dashboard you need to do two things:
1. Pay for the order (it sounds like you did this part)
2. Include a fulfillments parameter in the CreateOrder request: https://developer.squareup.com/docs/orders-api/order-ahead-usecase#add-fulfillment-information-to-make-a-pickup-order
I cannot figure out how to create a new contact group and assign it to the contact using google people api in php. An error
"person.memberships is a read only field."
occurs at $person->setMemberships():
$contactGroup=new Google_Service_PeopleService_ContactGroup();
//$contactGroup->setGroupType('USER_CONTACT_GROUP');
$contactGroup->setName('Some group');
$contactGroup->create();
$cgm=new Google_Service_PeopleService_ContactGroupMembership();
$cgm->setContactGroupId('groupID');
$membership=new Google_Service_PeopleService_Membership();
$membership->setContactGroupMembership($cgm);
$person=new Google_Service_PeopleService_Person();
$groupMemberships=array(($membership));
$person->setMemberships(array($groupMemberships));//error happens here
Anyone could help with a proper example of creating contact group and assigning it to the contact?
The following code assumes you have instantiated a Google_Client object, and have already created a person and know their ID.
Resource ID example,
$person_id = 'people/1234567890abcde';
Create a contact group,
$peopleService = new Google_Service_PeopleService($client);
$newContactGroup = new Google_Service_PeopleService_ContactGroup;
$newContactGroup->setName('New contact group');
$createContactGroupRequest = new Google_Service_PeopleService_CreateContactGroupRequest;
$createContactGroupRequest->setContactGroup($newContactGroup);
$contactGroup = $peopleService->contactGroups->create($createContactGroupRequest);
$contact_group_id = $contactGroup->getResourceName();
Add a person to contact group,
$peopleService = new Google_Service_PeopleService($googleClient);
$modifyContactGroupMembersRequest = new Google_Service_PeopleService_ModifyContactGroupMembersRequest;
$modifyContactGroupMembersRequest->setResourceNamesToAdd($person_id);
$peopleService->contactGroups_members->modify($contact_group_id, $modifyContactGroupMembersRequest);
You can't set members of the contact group in the creation call. You need to create the contact group in one call, then in a second call add it using members.modify api call.
I'm trying to add company name when I add a new customer, anyone can help?
By the way, where is the documentation for quickboos-php devkit , I can't find it as well.
The below is the code:
$CustomerService = new QuickBooks_IPP_Service_Customer();
//add basic info
$Customer = new QuickBooks_IPP_Object_Customer();
$Customer->setTitle($title);
$Customer->setGivenName($given_name);
$Customer->setMiddleName($middel_name);
$Customer->setFamilyName($family_name);
$Customer->setDisplayName($display_name);
// Phone #
$PrimaryPhone = new QuickBooks_IPP_Object_PrimaryPhone();
$PrimaryPhone->setFreeFormNumber($primary_phone);
$Customer->setPrimaryPhone($PrimaryPhone);
// Mobile #
$Mobile = new QuickBooks_IPP_Object_Mobile();
$Mobile->setFreeFormNumber($mobile);
$Customer->setMobile($Mobile);
// Bill address
$BillAddr = new QuickBooks_IPP_Object_BillAddr();
$BillAddr->setLine1($bill_address);
$BillAddr->setCity($bill_city);
$BillAddr->setCountrySubDivisionCode($bill_state);
$BillAddr->setCountry($bill_country);
$BillAddr->setPostalCode($bill_zip_code);
$Customer->setBillAddr($BillAddr);
// Shipping address
$ShipAddr = new QuickBooks_IPP_Object_ShipAddr();
$ShipAddr->setLine1($address_1);
$ShipAddr->setLine2($address_2);
$ShipAddr->setCity($city);
$ShipAddr->setCountrySubDivisionCode($province);
$ShipAddr->setCountry($country);
$ShipAddr->setPostalCode($postal_code);
$Customer->setShipAddr($ShipAddr);
$customer_id = $CustomerService->add($Context, $realm, $Customer);
The list of available fields for Customer objects is on Intuit's website:
https://developer.intuit.com/docs/api/accounting/customer
You're probably looking for:
CompanyName:
optional
String, maximum of 50 chars, filterable, sortable, default is null
The name of the company associated with the person or organization.
Unsurprisingly, there's a couple of corresponding methods:
$Customer->setCompanyName($v);
$v = $Customer->getCompanyName();
I am using API version 1.3 of mailchimp to create Campaign programmatically in PHP.
I am using MCAPI class method campaignCreate() to create campaign. Campaign is created successfully and it returns campaign id in response which is string.
But i need Web id (integer value of campaign id) so that I can use it to open that campaign using link on my website.
For example: lets say I want to redirect user to this link - https://us8.admin.mailchimp.com/campaigns/show?id=941117 and for that i need id value as 941117 when new campaign is created.For now i am getting it as string like 6ae9ikag when new campaign is created using mailchimp API
Please let me know if anyone knows how to get campaign web id (integer value) using Mailchimp API in PHP
Thanks
I found an answer so wanted to share here.Hope it helps someone
I get campaign id as a string when createCampaign() method of MCAPI class is used.
You need to use below code to get web id (integer value of campaign id)
$filters['campaign_id'] = $campaign_id; // string value of campaign id
$campaign = $api->campaigns($filters);
$web_id = $campaign['data'][0]['web_id'];
This worked for me.
Thanks
<?php
/**
This Example shows how to create a basic campaign via the MCAPI class.
**/
require_once 'inc/MCAPI.class.php';
require_once 'inc/config.inc.php'; //contains apikey
$api = new MCAPI($apikey);
$type = 'regular';
$opts['list_id'] = '5ceacbda08';
$opts['subject'] = 'Test Newsletter Mail';
$opts['from_email'] = 'guna#test.com';
$opts['from_name'] = 'guna';
$opts['tracking']=array('opens' => true, 'html_clicks' => true, 'text_clicks' => false);
$opts['authenticate'] = true;
$opts['analytics'] = array('google'=>'my_google_analytics_key');
$opts['title'] = 'Test Newsletter Title';
$content = array('html'=>'Hello html content message',
'text' => 'text text text *|UNSUB|*'
);
$retval = $api->campaignCreate($type, $opts, $content);
if ($api->errorCode){
echo "Unable to Create New Campaign!";
echo "\n\tCode=".$api->errorCode;
echo "\n\tMsg=".$api->errorMessage."\n";
} else {
echo "New Campaign ID:".$retval."\n";
}
$retval = $api->campaignSendNow($retval);
?>
The web_id is returned by mailchimp when a call is made to the creation end point.
$mcResponce = $mailchimp_api->campaigns->create(...);
$web_id = $mcResponce['web_id'];
See the documentation.
I am working of CIM (Customer information manager) and i have created customer profile using CIM function. But i want to get customer profile using customer id instead of customer profile id.
$cim = new AuthnetCIM('***MASKED***', '***MASKED***', AuthnetCIM::USE_DEVELOPMENT_SERVER);
$cim->setParameter('email', 'fakeemail#example.com');
$cim->setParameter('description', 'Profile for Joe Smith'); // Optional
$cim->setParameter('merchantCustomerId', '7789812');
//create profile function
$ss=$cim->createCustomerProfile();
//and get profile by..
$profile_id = $cim->getProfileID();
You can't. You can only get the profile using the profile ID. This means you'll want to store that ID in your database and associate it with the customer's record so whenever you need to get their profile you know what their Profile ID is.
Actually it is possible if you must, however I would still recommend storing it if possible, but this alternative might be of help.
Authorize.Net defines a unique customer profile by the composite key (Merchant Customer Id, Email, and Description), thus you must ensure this is unique. The CreateCustomerProfile(..) API method will enforce uniqueness and return an error if you attempt to create the same composite key again, as it should. However, the message in this response will contain the conflicting customer profile id, and since your composite key is unique, and Authorize.Net enforces uniqueness of this composite key, then this must be the Authorize.Net customer profile id of your customer.
Code sample in C#
private long customerProfileId = 0;
var customerProfile = new AuthorizeNet.CustomerProfileType()
{
merchantCustomerId = "123456789",
email = "user#domain.com",
description = "John Smith",
};
var cpResponse = authorize.CreateCustomerProfile(merchantAuthentication, customerProfile, ValidationModeEnum.none);
if (cpResponse.resultCode == MessageTypeEnum.Ok)
{
customerProfileId = cpResponse.customerProfileId;
}
else
{
var regex = new Regex("^A duplicate record with ID (?<profileId>[0-9]+) already exists.$", RegexOptions.ExplicitCapture);
Match match = regex.Match(cpResponse.messages[0].text);
if (match.Success)
customerProfileId = long.Parse(match.Groups["profileId"].Value);
else
//Raise error.
}