I am creating a new address using shippo api using test token and when i give the array of address and click create it gives me 500 error. I am doing everything according to the docs given by shippo here is my code that I am using. The request I am sending is through ajax.
require_once ABSPATH . '/shippo/shippo/lib/Shippo';
Shippo::setApiKey("test_token");
$address = Shippo_Address::
create(
array(
'object_purpose' => 'QUOTE',
'name' => 'John Smith',
'company' => 'Initech',
'street1' => '6512 Greene Rd.',
'city' => 'Woodridge',
'state' => 'IL',
'zip' => '60517',
'country' => 'US',
'phone' => '773 353 2345',
'email' => 'jmercouris#iit.com',
'metadata' => 'Customer ID 23424'
));
var_dump($address);
I am confuse that what is it that I am doing wrong or missing?
Related
The entirety of this code works on other machines with PHP v 7.3 but my production machine is 7.4. Every time i go to print out the order creation data it just comes up blank. Trying to insert anything into the array using short syntax is just not working at all any ideas why. This little chunk is the offender in question and when printing out order creation data I don't get anything.
$order_creation_data = array(
'order' => array(
'email' => $email,
'fulfillment_status' => $shopify_fufillment_status,
'financial_status' => 'paid',
)
);
$shopify_address_build_array = array(
'first_name' => $shopify_customer_default_address['first_name'],
'last_name' => $shopify_customer_default_address['last_name'],
'address1' => $shopify_customer_default_address['address1'],
'address2' => $shopify_customer_default_address['address2'],
'phone' => $shopify_customer_default_address['phone'],
'city' => $shopify_customer_default_address['city'],
'province' => $shopify_customer_default_address['province'],
'country_code' => $shopify_customer_default_address['country_code'],
'zip' => $shopify_customer_default_address['zip'],
);
$order_creation_data['order']['billing_address'] = $shopify_address_build_array;
$order_creation_data['order']['shipping_address'] = $shopify_address_build_array;
I am trying to send the custom field to mailchimp but not sure how to do this.
If you see below, I am trying to send company information to one of my Audiences but it's not sending through.
Here is the pasted code as well:
// member information
$json = json_encode([
'email_address' => $user_row['email'],
'status' => 'subscribed',
'COMPANY' => $company_info['name'],
'merge_fields' => [
'FNAME' => $user_row['first_name'],
'LNAME' => $user_row['last_name']
]
]);
I have created the custom field inside the mailchimp under targeted audiences. As you can see here:
So anyone can please help me that what I am doing wrong that company information is not syncing.
On Audiences I am receiving blank company name.
'COMPANY' => $company_info['name'],
The above line should be inside the 'merge_fields' like this
$json = json_encode([
'email_address' => $user_row['email'],
'status' => 'subscribed',
'merge_fields' => [
'FNAME' => $user_row['first_name'],
'LNAME' => $user_row['last_name'],
'COMPANY' => $company_info['name']
]
]);
I'm using https://github.com/Garethp/php-ews/ library to access to my public contact folder on Exchange server.
This is how i create a contact.
$api = API::withUsernameAndPassword($server, $user, $pass);
$folder = $api->getFolderByDisplayName('Public', Enumeration\DistinguishedFolderIdNameType::PUBLICFOLDERSROOT);
$contattiTotali = $api->getFolderByDisplayName('Contacts', $folder->getFolderId());
$id=$contattiTotali->getFolderId()->getId();
$api->setFolderId($contattiTotali->getFolderId());
$api->createContacts(array(
'GivenName' => 'Homer',
'Surname' => 'Simpson',
'EmailAddresses' => array(
'Entry' => array('Key' => Enumeration\EmailAddressKeyType::EMAIL_ADDRESS_1, '_value' => 'h.simpson#gmail.com')
),
//Creating multiple entries
'PhoneNumbers' => array(
'Entry' => array(
array('Key' => Enumeration\PhoneNumberKeyType::HOME_PHONE, '_value' => '000'),
array('Key' => Enumeration\PhoneNumberKeyType::BUSINESS_PHONE, '_value' => '111'),
)
),
'PhysicalAddresses' => array(
'Entry' => array(
'Key' => Enumeration\PhysicalAddressKeyType::HOME,
'street' => '123 Street',
'city' => '123 City',
'state' => '123 State',
'countryOrRegion' => '123 Country',
'postalCode' => '12345',
)
),
));
The code, actually, works fine, but if i execute it several times, it duplicates the contact.
Is there a way to check if the contact (email address is good enough) already exists before creating a new one?
The easiest way to telling if a contact already exists with a particular email address is to use the ResolveName operation eg
$request = new EWSType_ResolveNamesType();
$request->UnresolvedEntry = "address#domain.com";
$request->ReturnFullContactData = true;
$return = $ews->ResolveNames($request);
if ($return->ResponseMessages->ResolveNamesResponseMessage->ResponseCode == "NoError") {
return $return->ResponseMessages->ResolveNamesResponseMessage->ResolutionSet->Resolution->Mailbox->EmailAddress;
}
Here is my code which is the example I used from here
$createcustomer_api = new \SquareConnect\Api\CustomersApi();
$createcustomer_result = $createcustomer_api->createCustomer(array(
'given_name' => 'Amelia',
'family_name' => 'Earhart',
'email_address' => 'Amelia.Earhart#example.com',
'address' => array(
'address_line_1' => '500 Electric Ave',
'address_line_2' => 'Suite 600',
'locality' => 'New York',
'administrative_district_level_1' => 'NY',
'postal_code' => '10003',
'country' => 'US'
),
'phone_number' => '1-555-555-0122',
'reference_id' => 'YOUR_REFERENCE_ID',
'note' => 'a customer'
));
If I print out the results I get
SquareConnect\Model\CreateCustomerResponse Object
(
[errors:protected] =>
[customer:protected] => SquareConnect\Model\Customer Object
(
[id:protected] => CBASEHtp6YVU8AirkMv1lrVMyoIgAQ
[created_at:protected] => 2017-09-27T23:19:44.62Z
[updated_at:protected] => 2017-09-27T23:19:44.62Z
[cards:protected] =>
[given_name:protected] => Amelia
[family_name:protected] => Earhart
[nickname:protected] =>
[company_name:protected] =>
[email_address:protected] => Amelia.Earhart#example.com
[address:protected] => SquareConnect\Model\Address Object
(
[address_line_1:protected] => 500 Electric Ave
[address_line_2:protected] => Suite 600
[address_line_3:protected] =>
[locality:protected] => New York
[sublocality:protected] =>
[sublocality_2:protected] =>
[sublocality_3:protected] =>
[administrative_district_level_1:protected] => NY
[administrative_district_level_2:protected] =>
[administrative_district_level_3:protected] =>
[postal_code:protected] => 10003
[country:protected] => US
[first_name:protected] =>
[last_name:protected] =>
[organization:protected] =>
)
[phone_number:protected] => 1-555-555-0122
[reference_id:protected] => YOUR_REFERENCE_ID
[note:protected] => a customer
[preferences:protected] => SquareConnect\Model\CustomerPreferences Object
(
[email_unsubscribed:protected] =>
)
[groups:protected] =>
)
)
Now I need to create the customer card to associate with the customer for future recurring payments.
$createcard_api = new \SquareConnect\Api\CustomersApi();
$createcard_result = $createcard_api->createCustomerCard($createcustomer_result->getId(), array(
'card_nonce' => $nonce,
'billing_address' => array(
'address_line_1' => '1455 Market St',
'address_line_2' => 'Suite 600',
'locality' => 'San Francisco',
'administrative_district_level_1' => 'CA',
'postal_code' => '94103',
'country' => 'US'
),
'cardholder_name' => 'Amelia Earhart'
));
From what I understand there is a built-in function with the square SDK that is getId() which according to this is called like $customer->getId(), but according to this I need to just add ->getId() to my createCustomer object.
So I am trying to call the getId() function as
$createcustomer_result->getId()
but in my code I am getting the error
Fatal error: Call to undefined method SquareConnect\Model\CreateCustomerResponse::getId()
How do I properly get the customer id from the createCustomer?
You've only got the response object from the API, a communication device. You need to first extract the created object from the response, then you can query it for the ID.
$customer = $createcustomer_result->getCustomer();
That should get you the actual customer object, then you can:
$customer_id = $customer->getId();
This is pretty common for API libraries. You can also query the response object for errors if they occur. When using these kinds of libraries, have a look inside the various classes and read through the functions, you can get a better idea of how you use them that way.
So I've made a template called 'Basic' within Mandrill. I did a test send and it looks great. I put Mandrill into test mode and used the test API key in my code. I'm just trying to get the php to send out a test transactional email, but no email gets sent. Here is the printed response I get:
Array ( [0] => Array ( [email] => amiecrutchley02#gmail.com [status] => sent [_id] => 89bfab4c3938486eb9e36564f79a3e9f [reject_reason] => ) )
So I'm really not sure why I'm not receiving anything.
Here is my code:
<?php
require_once('includes/mandrill/Mandrill.php');
$mandrill = new Mandrill('my_api_key');
$message = array(
'subject' => 'Thank You For Your Purchase',
'from_email' => 'no-reply#acq.com',
'from_name' => 'ACQ',
'to' => array(array('email' => 'amiecrutchley02#gmail.com', 'name' => 'Amie')),
'merge_vars' => array(array(
'rcpt' => 'amiecrutchley02#gmail.com',
'vars' =>
array(
array(
'name' => 'FIRSTNAME',
'content' => 'Amie'),
array(
'name' => 'LASTNAME',
'content' => 'Crutchley')
))));
$template_name = 'Basic';
$template_content = array(
array(
'name' => 'main',
'content' => 'Hi *|FIRSTNAME|* *|LASTNAME|*, your profile has been updated!'),
array(
'name' => 'footer',
'content' => 'ACQ, Copyright 2014')
);
$response = $mandrill->messages->sendTemplate($template_name, $template_content, $message);
print_r($response);
?>
a test API key is specifically designed to not send email. It's designed so you can mimic sending email, but doesn't actually send. You're also not charged for sending tests. Here's the Mandrill KB about what test mode is, and how it works: Does Mandrill have a test mode or sandbox?
Well, weird, but my test API was the problem. I tried the public API and boom! It works!