Docusign bulk send using php client - php

I have implemented bulk send using docusign php client. I'm getting following error message
{ "errorCode": "UNSPECIFIED_ERROR", "message": "Value cannot be
null. Parameter name: stream" }
when I run below source code.
$templateId = 'd756f973-...';
$apiClient = $this->getDocuSignClient();
// Get Template
$templatesApi = new TemplatesApi($apiClient);
$templateDetails = $templatesApi->get($this->getAccountId(), $templateId);
// Set documents
...
// Receipient
$signer = new Signer();
$signer->setIsBulkRecipient('true');
$signer->setRecipientId('1');
$recipients = new Recipients();
$recipients->setSigners([$signer]);
// Create draft template
$envelopDefinition = new EnvelopeDefinition();
$envelopDefinition->setStatus('created');
$envelopDefinition->setDocuments($documents);
$envelopDefinition->setRecipients($recipients);
$envelopDefinition->setEmailSubject('Sign bulk send');
$envelopeApi = new EnvelopesApi($apiClient);
$envelopSummary = $envelopeApi->createEnvelope($this->getAccountId(), $envelopDefinition);
// Update bulk recipients
$clients = Client::all();
$bulkRecipients = [];
foreach ($clients as $client) {
$bulkRecipient = new BulkRecipient();
$bulkRecipient->setEmail($client->email);
$bulkRecipient->setName($client->first_name);
$bulkRecipients[] = $bulkRecipient;
}
$bulkRequest = new BulkRecipientsRequest();
$bulkRequest->setBulkRecipients($bulkRecipients);
$bulkEnvelopesApi = new BulkEnvelopesApi($apiClient);
$bulkEnvelopesApi->updateRecipients($this->getAccountId(), $envelopSummary['envelope_id'], '1', $bulkRequest);
// ---------- the error message throws on above line ----------
Any help appreciated. Thanks in advance

can you please try to update to version 4 (https://github.com/docusign/docusign-php-client/releases/tag/v4.0.0) of the PHP client. This supports our new v2.1 API which has a much improved bulk send support https://developers.docusign.com/esign-rest-api/reference/BulkEnvelopes/BulkEnvelopes/

Related

how do i authenticate against cybersource soap toolkit api on php

I have the following code on my index.php
<?php
// This sample demonstrates how to run a sale request, which combines an
// authorization with a capture in one request.
// Using Composer-generated autoload file.
require __DIR__ . '/vendor/autoload.php';
// Or, uncomment the line below if you're not using Composer autoloader.
//require_once(__DIR__ . '/lib/CybsSoapClient.php');
// Before using this example, you can use your own reference code for the transaction.
$referenceCode = 'holla';
$client = new CybsSoapClient();
$request = $client->createRequest($referenceCode);
// Build a sale request (combining an auth and capture). In this example only
// the amount is provided for the purchase total.
$ccAuthService = new stdClass();
$ccAuthService->run = 'true';
$request->ccAuthService = $ccAuthService;
$ccCaptureService = new stdClass();
$ccCaptureService->run = 'true';
$request->ccCaptureService = $ccCaptureService;
$billTo = new stdClass();
$billTo->firstName = 'John';
$billTo->lastName = 'Doe';
$billTo->street1 = '1295 Charleston Road';
$billTo->city = 'Mountain View';
$billTo->state = 'CA';
$billTo->postalCode = '94043';
$billTo->country = 'US';
$billTo->email = 'null#cybersource.com';
$billTo->ipAddress = '10.7.111.111';
$request->billTo = $billTo;
$card = new stdClass();
$card->accountNumber = '4111111111111111';
$card->expirationMonth = '12';
$card->expirationYear = '2020';
$request->card = $card;
$purchaseTotals = new stdClass();
$purchaseTotals->currency = 'USD';
$purchaseTotals->grandTotalAmount = '90.01';
$request->purchaseTotals = $purchaseTotals;
$reply = $client->runTransaction($request);
// This section will show all the reply fields.
print("\nRESPONSE: " . print_r($reply, true));
and the cybs.ini is like
merchant_id = "firefy"
transaction_key = "5430494897960177107046"
; Modify the URL to point to either a live or test WSDL file with the desired API version.
wsdl = "https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor/CyberSourceTransaction_1.109.wsdl"
when i run the code on my local machine i get the following error messaage.
Fatal error: Uncaught SoapFault exception: [wsse:FailedCheck] Security Data : UsernameToken authentication failed. in C:\xampp\htdocs\cybersourceTest\index.php:50 Stack trace: #0 C:\xampp\htdocs\cybersourceTest\index.php(50): SoapClient->__call('runTransaction', Array) #1 {main} thrown in C:\xampp\htdocs\cybersourceTest\index.php on line 50
How do i know what caused the error above and how can i solve the above error.
I am trying to add payout api to my app and this is giving a headache right now.
Please guys help me out if anyone can.
The error “authentication failed” is saying your merchant_id and transaction_key are not correct.
Assuming that your merchant_id is correct your transaction_key is not the correct format. You can get a transaction_key by going to the business center at https://ebctest.cybersource.com then go to Account Management-> Transaction Security Keys -> Security Keys for the SOAP Toolkit API. Generate a key there.
I found out that i the url that i was pointing to was not valid or something but i fixed it by changing the endpoint of the wsdl from
wsdl="https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor/CyberSourceTransaction_1.109.wsdl"
to
wsdl="https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor/CyberSourceTransaction_1.151.wsdl"
That took care of everything that was wrong with the error that was popping up.

PHP-EWS "Soap client returned status of 404"

So, I'm using php-ews library to connect to my Microsoft Office 365 Exchange Email account to read emails. I've connected successfully to it and I have managed to retrieve a list of emails that I need.
Now the problem is that I cannot get message body. Reading documentation about Exchange Web Services it says that body cannot be fetched with FindItem(), only with GetItem(), and that's okay.
Now the problem I'm seeing is following:
I tried all possible examples I could find about this, and the code doesn't have any errors, it just says "Soap client returned status of 404".
If anyone has any idea where to look for the solution, please tell me.
EDIT:
$ews = new Client('outlook.office365.com/EWS/OData/Me/Inbox/Messages', '###', '###', ClientEWS::VERSION_2010_SP2);
$request = new FindItemType();
$request->ItemShape = new ItemResponseShapeType();
$request->ItemShape->BaseShape = DefaultShapeNamesType::DEFAULT_PROPERTIES;
$request->ItemShape->BodyType = BodyTypeResponseType::BEST;
$request->Traversal = ItemQueryTraversalType::SHALLOW;
$request->ParentFolderIds = new NonEmptyArrayOfBaseFolderIdsType();
$request->ParentFolderIds->DistinguishedFolderId = new DistinguishedFolderIdType();
$request->ParentFolderIds->DistinguishedFolderId->Id = DistinguishedFolderIdNameType::INBOX;
// sort order
$request->SortOrder = new NonEmptyArrayOfFieldOrdersType();
$request->SortOrder->FieldOrder = array();
$order = new FieldOrderType();
// sorts mails so that oldest appear first
// more field uri definitions can be found from types.xsd (look for UnindexedFieldURIType)
$order->FieldURI = new PathToUnindexedFieldType();
$order->FieldURI->FieldURI = 'item:DateTimeReceived';
$order->Order = 'Ascending';
$request->SortOrder->FieldOrder[] = $order;
try{
//getting list of all emails - works perfectly
$result = $ews->FindItem($request);
if ($result->ResponseMessages->FindItemResponseMessage->ResponseCode == 'NoError' && $result->ResponseMessages->FindItemResponseMessage->ResponseClass == 'Success') {
$count = $result->ResponseMessages->FindItemResponseMessage->RootFolder->TotalItemsInView;
$request = new GetItemType();
$request->ItemShape = new ItemResponseShapeType();
$request->ItemShape->BaseShape = DefaultShapeNamesType::ALL_PROPERTIES;
for ($i = 0; $i < $count; $i++){
$message_id = $result->ResponseMessages->FindItemResponseMessage->RootFolder->Items->Message[$i]->ItemId->Id;
$messageItem = new ItemIdType();
$messageItem->Id = $message_id;
$request->ItemIds->ItemId[] = $messageItem;
}
// Here is your response
// It throws an error here with the message "Soap client returned status of 404"
$response = $ews->GetItem($request);
print_r($response);
}
//print_r($result);
} catch(\Exception $e) {
echo $e->getMessage();
}
It looks like your trying to use the new REST endpoint for Office365
'outlook.office365.com/EWS/OData/Me/Inbox/Messages'
But your trying to make and EWS SOAP Request, the endpoint you should be using for EWS SOAP is
https://outlook.office365.com/EWS/Exchange.asmx
You might want to consider using the new REST interface as an alternative to EWS/SOAP but you then need to use a REST library.ouauth etc as per https://dev.outlook.com/restapi.
I'd suggest you use a newer version of this library that's maintained much more and has more features (In this case, it support OAuth logins for Office 365), garethp/php-ews. When using it, you can either use the endpoint provided by Glen Scales, or just use outlook.office365.com.

Quickbooks Online sdk add invoice exception

I am integrating my application with with Quickbook Online Sandbox account using php sdk version 3. I am able to connect and fetch/add data like customers without a problem. But I am unable to create an invoice using the sdk. Here is my code:
$invoiceObj = new IPPInvoice();
$Line = new IPPline();
$Line->Amount = 15;
$Line->DetailType = 'SalesItemLineDetail';
$saleItemLineDetail = new IPPSalesItemLineDetail();
$saleItemLineDetail->ItemRef = 1;
$saleItemLineDetail->UnitPrice = 15;
$saleItemLineDetail->Qty = 2;
$Line->SalesItemLineDetail = $saleItemLineDetail;
$invoiceObj->Line = $Line;
$invoiceObj->DocNumber = '23713';
$invoiceObj->TxnDate = 2015-10-11;
$invoiceObj->CustomerRef = 67;
try{
$resultingInvoiceObj = $connect->Add($invoiceObj);
} catch (Exception $e){
echo $e->getMessage();
}
I am writing this in a function which takes the connection object as parameter. I am able to add customer using this connection object in the same function.
The response i'm getting is
2015-04-22 06:46:15 - E:\wamp\www\test\application\libraries\QuickBooksOnline\DataService\DataService.php - 340 - CheckNullResponseAndThrowException - Response Null or Empty
I got stuck here. Please point out where i am doing wrong. Any help in this regard is highly appreciated.
Try this once to pass customerRef
$customerRef2 = new IPPReferenceType();
$customerRef2->value = "67";
$invoiceObj->CustomerRef = $customerRef2;

PHP Exchange Web Services - get message body

I'm using a PHP EWS library, and took this example to get a list of messages, which works perfectly.
It pulls through details such as the sender, receiver, subject, time etc. I tried looking through all the library, but I can't workout how to pull through the message body and attachments.
Any ideas?
It is well described in PHP EWS wiki, right here: https://github.com/jamesiarmes/php-ews/wiki/Email-:-Retrieve-All-Email-Attachments
Edit: use whole example linked above to fetch email attachments and just part of it to get the message:
$message_id = ''; // Id of the email message
$ews = new ExchangeWebServices($host, $user, $password);
$request = new EWSType_GetItemType();
$request->ItemShape = new EWSType_ItemResponseShapeType();
$request->ItemShape->BaseShape = EWSType_DefaultShapeNamesType::ALL_PROPERTIES;
$request->ItemIds = new EWSType_NonEmptyArrayOfBaseItemIdsType();
$request->ItemIds->ItemId = new EWSType_ItemIdType();
$request->ItemIds->ItemId->Id = $message_id;
$response = $ews->GetItem($request);
if( $response->ResponseMessages->GetItemResponseMessage->ResponseCode == 'NoError' &&
$response->ResponseMessages->GetItemResponseMessage->ResponseClass == 'Success' ) {
$message = $response->ResponseMessages->GetItemResponseMessage->Items->Message;
}
At this point you have the $message. To access body use $message->body - it's an object with bodyType etc - to actually read the message body content use $message->body->_

Dialogflow V2 API - How to pass context and/or payload [PHP]

I am trying to send context and payload to the Dialogflow V2 API. I am able to successfully send a queryString and get a response from my agent. However, I need to pass context and payload parameters with this query and I cannot seem to find ANY help on this for PHP. Please see my code below. I am able to create the context object and the payload object (atleast I think its created), but how do I pass it to the API?
Any help would be appreciated as I am very new to dialogflow and have been struggling with this for a few days now.
function detect_intent_texts($projectId, $text, $sessionId, $context, $parameters, $languageCode = 'en-US') {
// new session
$test = array('credentials' => 'client-secret.json');
$sessionsClient = new SessionsClient($test);
$session = $sessionsClient->sessionName($projectId, $sessionId ?: uniqid());
//printf('Session path: %s' . PHP_EOL, $session);
// create text input
$textInput = new TextInput();
$textInput->setText($text);
$textInput->setLanguageCode($languageCode);
$contextStruct = new Struct();
$contextStruct->setFields($context['parameters']);
$paramStruct = new Struct();
$paramStruct->setFields($parameters['parameters']);
$contextInput = new Context();
$contextInput->setLifespanCount($context['lifespan']);
$contextInput->setName($context['name']);
$contextInput->setParameters($contextStruct);
$queryParams = new QueryParameters();
$queryParams->setPayload($paramStruct);
// create query input
$queryInput = new QueryInput();
$queryInput->setText($textInput);
// get response and relevant info
$response = $sessionsClient->detectIntent($session, $queryInput); // Here I don't know how to send the context and payload
$responseId = $response->getResponseId();
$queryResult = $response->getQueryResult();
$queryText = $queryResult->getQueryText();
$intent = $queryResult->getIntent();
$displayName = $intent->getDisplayName();
$confidence = $queryResult->getIntentDetectionConfidence();
$fulfilmentText = $queryResult->getFulfillmentText();
$returnResponse = array(
'responseId' => $responseId,
'fulfillmentText' => $fulfilmentText
);
$sessionsClient->close();
return $returnResponse;
}
Just as it happens, the moment I post my question, I get a result.
Thanks to this post How to set query parameters dialogflow php sdk.
I added the following to my code and it worked.
Added
$optionalsParams = ['queryParams' => $queryParams];
Changed
$response = $sessionsClient->detectIntent($session, $queryInput, $optionalsParams);

Categories