Google Calendar API marking new events as "cancelled" - php

I am trying to create events in my calendar via the calendar API.
Below is the object I am pushing to the API:
Google_Event Object
(
[__creatorType:protected] => Google_EventCreator
[__creatorDataType:protected] =>
[creator] => Google_EventCreator Object
(
[self] => 1
[displayName] =>
[email] => gcalevent#golden-hook-134443.iam.gserviceaccount.com
[id] =>
)
[__organizerType:protected] => Google_EventOrganizer
[__organizerDataType:protected] =>
[organizer] => Google_EventOrganizer Object
(
[self] => 1
[displayName] =>
[email] => gcalevent#golden-hook-134443.iam.gserviceaccount.com
[id] =>
)
[summary] => Hair: Elliot Test
[id] => 421a880v7dqb97p5voqsp198ac
[__attendeesType:protected] => Google_EventAttendee
[__attendeesDataType:protected] => array
[attendees] => Array
(
[0] => Google_EventAttendee Object
(
[comment] =>
[displayName] => Elliot Test
[responseStatus] => accepted
[self] =>
[id] =>
[additionalGuests] =>
[resource] =>
[organizer] =>
[optional] =>
[email] => hello#elliot.co.uk
)
)
[htmlLink] => https://www.google.com/calendar/event?eid=NDIxYTg4MHY3ZHFiOTdwNXZvcXNwMTk4YWMgZ2NhbGV2ZW50QGdvbGRlbi1ob29rLTE2NDQyMS5pYW0uZ3NlcnZpY2VhY2NvdW50LmNvbQ
[recurrence] =>
[__startType:protected] => Google_EventDateTime
[__startDataType:protected] =>
[start] => Google_EventDateTime Object
(
[date] =>
[timeZone] =>
[dateTime] => 2019-09-10T15:00:00Z
)
[etag] => "3136239546092000"
[location] =>
[recurringEventId] =>
[__gadgetType:protected] => Google_EventGadget
[__gadgetDataType:protected] =>
[gadget] =>
[status] => confirmed
[updated] => 2019-09-10T12:49:33.046Z
[description] => Price: £10.00
Services: Testing
[iCalUID] => 421a880v7dqb97p5voqsp198ac#google.com
[__extendedPropertiesType:protected] => Google_EventExtendedProperties
[__extendedPropertiesDataType:protected] =>
[extendedProperties] =>
[endTimeUnspecified] =>
[sequence] => 0
[visibility] =>
[guestsCanModify] =>
[__endType:protected] => Google_EventDateTime
[__endDataType:protected] =>
[end] => Google_EventDateTime Object
(
[date] =>
[timeZone] =>
[dateTime] => 2019-09-10T16:00:00Z
)
[attendeesOmitted] =>
[kind] => calendar#event
[locked] =>
[created] => 2019-09-10T12:49:33.000Z
[colorId] =>
[anyoneCanAddSelf] =>
[__remindersType:protected] => Google_EventReminders
[__remindersDataType:protected] =>
[reminders] => Google_EventReminders Object
(
[__overridesType:protected] => Google_EventReminder
[__overridesDataType:protected] => array
[overrides] =>
[useDefault] => 1
)
[guestsCanSeeOtherGuests] =>
[__originalStartTimeType:protected] => Google_EventDateTime
[__originalStartTimeDataType:protected] =>
[originalStartTime] =>
[guestsCanInviteOthers] =>
[transparency] =>
[privateCopy] =>
)
Which appears to be work fine, however when I go to retrieve that event using the ID: 421a880v7dqb97p5voqsp198ac it shows all the above details but the status is marked as "cancelled" and therefore it isn't showing in my calendar:
{
"kind": "calendar#event",
"etag": "\"3136239559346000\"",
"id": "421a880v7dqb97p5voqsp198ac",
"status": "cancelled",
"htmlLink": "https://www.google.com/calendar/event?eid=NDIxYTg4MHY3ZHFiOTdwNXZvcXNwMTk4YWMgaGVsbG9AZWxsaW90cmVldmUuY28udWs",
"created": "2019-09-10T12:49:33.000Z",
"updated": "2019-09-10T12:49:39.673Z",
"summary": "Hair: Elliot Test",
"description": "Price: £10.00\nSerivices: Testing",
"creator": {
"email": "gcalevent#golden-hook-134443.iam.gserviceaccount.com"
},
"organizer": {
"email": "gcalevent#golden-hook-134443.iam.gserviceaccount.com"
},
"start": {
"dateTime": "2019-09-10T16:00:00+01:00"
},
"end": {
"dateTime": "2019-09-10T17:00:00+01:00"
},
"iCalUID": "421a880v7dqb97p5voqsp198ac#google.com",
"sequence": 0,
"attendees": [
{
"email": "hello#elliot.co.uk",
"displayName": "Elliot Test",
"self": true,
"responseStatus": "accepted"
}
],
"reminders": {
"useDefault": true
}
}
This has previously been working fine for months and is now no longer working without any changes from my side.
Can anyone provide any insight into why this might be happening?
Thanks

Related

Google Drive API: search file and get a snippet of the content of the results

I have a php script that uses the google/apiclient from composer libraries to search for files on Google Drive.
I know I can get extra data/metadata of the results using fields but there is no field like fullText that comes with the results and contains either the full text or a snippet of the text where the search query was found.
My goal is to give the end user some context of what the result is and if it really is the file they are looking for.
Has anyone done something like this? Maybe a hidden field?
To give a more visual idea of what I have running:
$result = $service->files->listFiles(
[
'q' => "fullText contains 'find this on the file content'",
'supportsAllDrives' => TRUE,
'includeItemsFromAllDrives' => TRUE,
'corpora' => 'allDrives',
'fields' => 'files(id, size, thisFieldContainsTheTextSnippetWhereTheQueryWasFound )'
]
);
And I want this as a result:
$result = Google\Service\Drive\FileList Object
(
[collection_key:protected] => files
[filesType:protected] => Google\Service\Drive\DriveFile
[filesDataType:protected] => array
[files] => Array
(
[0] => Google\Service\Drive\DriveFile Object
(
[collection_key:protected] => spaces
[appProperties] =>
[capabilitiesType:protected] => Google\Service\Drive\DriveFileCapabilities
[capabilitiesDataType:protected] =>
[capabilities] =>
[contentHintsType:protected] => Google\Service\Drive\DriveFileContentHints
[contentHintsDataType:protected] =>
[contentHints] =>
[contentRestrictionsType:protected] => Google\Service\Drive\ContentRestriction
[contentRestrictionsDataType:protected] => array
[contentRestrictions] =>
[copyRequiresWriterPermission] =>
[createdTime] =>
[description] =>
[driveId] =>
[explicitlyTrashed] =>
[exportLinks] =>
[fileExtension] =>
[folderColorRgb] =>
[fullFileExtension] =>
[hasAugmentedPermissions] =>
[hasThumbnail] =>
[headRevisionId] =>
[iconLink] =>
[id] => hAshID
[imageMediaMetadataType:protected] => Google\Service\Drive\DriveFileImageMediaMetadata
[imageMediaMetadataDataType:protected] =>
[imageMediaMetadata] =>
[isAppAuthorized] =>
[kind] =>
[labelInfoType:protected] => Google\Service\Drive\DriveFileLabelInfo
[labelInfoDataType:protected] =>
[labelInfo] =>
[lastModifyingUserType:protected] => Google\Service\Drive\User
[lastModifyingUserDataType:protected] =>
[lastModifyingUser] =>
[linkShareMetadataType:protected] => Google\Service\Drive\DriveFileLinkShareMetadata
[linkShareMetadataDataType:protected] =>
[linkShareMetadata] =>
[md5Checksum] =>
[mimeType] =>
[modifiedByMe] =>
[modifiedByMeTime] =>
[modifiedTime] =>
[name] =>
[originalFilename] =>
[ownedByMe] =>
[ownersType:protected] => Google\Service\Drive\User
[ownersDataType:protected] => array
[owners] =>
[parents] =>
[permissionIds] =>
[permissionsType:protected] => Google\Service\Drive\Permission
[permissionsDataType:protected] => array
[permissions] =>
[properties] =>
[quotaBytesUsed] =>
[resourceKey] =>
[sha1Checksum] =>
[sha256Checksum] =>
[shared] =>
[sharedWithMeTime] =>
[sharingUserType:protected] => Google\Service\Drive\User
[sharingUserDataType:protected] =>
[sharingUser] =>
[shortcutDetailsType:protected] => Google\Service\Drive\DriveFileShortcutDetails
[shortcutDetailsDataType:protected] =>
[shortcutDetails] =>
[size] => fileSize
[spaces] =>
[starred] =>
[teamDriveId] =>
[thumbnailLink] =>
[thumbnailVersion] =>
[trashed] =>
[trashedTime] =>
[trashingUserType:protected] => Google\Service\Drive\User
[trashingUserDataType:protected] =>
[trashingUser] =>
[version] =>
[videoMediaMetadataType:protected] => Google\Service\Drive\DriveFileVideoMediaMetadata
[videoMediaMetadataDataType:protected] =>
[videoMediaMetadata] =>
[viewedByMe] =>
[viewedByMeTime] =>
[viewersCanCopyContent] =>
[webContentLink] =>
[webViewLink] =>
[writersCanShare] =>
[internal_gapi_mappings:protected] => Array
(
)
[modelData:protected] => Array
(
)
[processed:protected] => Array
(
)
>>>>> [thisFieldContainsTheTextSnippetWhereTheQueryWasFound] => '...as i was broswing the website to find this on the file content, i was forced to ask about on st...' <<<<<
)
(
[1] => Google\Service\Drive\DriveFile Object
(
... cut to avoid repeating unnecessary stuff ...
[id] => AnotherhAshID
... cut to avoid repeating unnecessary stuff ...
>>>>> [thisFieldContainsTheTextSnippetWhereTheQueryWasFound] => '...this file has the text "find this on the file content", but just as an example and it is not what I am looking for...' <<<<<
)
)
[incompleteSearch] =>
[kind] =>
[nextPageToken] =>
[internal_gapi_mappings:protected] => Array
(
)
[modelData:protected] => Array
(
)
[processed:protected] => Array
(
)
)

Quickbooks Online API PHP SDK cannot update Bill with values returned from query

According to QBO docs, in order to update the contents of a bill you should
Use this operation to update any of the writable fields of an existing bill object. The request body must include all writable fields of the existing object as returned in a read response. Writable fields omitted from the request body are set to NULL. The ID of the object to update is specified in the request body.
We query a bill like so
SELECT * FROM Bill where DocNumber='150577' and VendorRef='156'
It returns the following:
(
[0] => QuickBooksOnline\API\Data\IPPBill Object
(
[PayerRef] =>
[SalesTermRef] =>
[DueDate] => 2020-10-22
[RemitToAddr] =>
[ShipAddr] =>
[Balance] => 89.59
[HomeBalance] => 89.59
[BillEx] =>
[VendorRef] => 156
[APAccountRef] => 46
[TotalAmt] => 89.59
[BillEmail] =>
[ReplyEmail] =>
[Memo] =>
[GlobalTaxCalculation] => TaxExcluded
[DocNumber] => 150577
[TxnDate] => 2020-10-22
[DepartmentRef] =>
[CurrencyRef] => CAD
[ExchangeRate] => 1
[PrivateNote] =>
[TxnStatus] =>
[LinkedTxn] =>
[Line] => Array
(
[0] => QuickBooksOnline\API\Data\IPPLine Object
(
[Id] => 1
[LineNum] => 1
[Description] =>
[Amount] => 54.02
[LinkedTxn] =>
[DetailType] => AccountBasedExpenseLineDetail
[PaymentLineDetail] =>
[DiscountLineDetail] =>
[TaxLineDetail] =>
[SalesItemLineDetail] =>
[DescriptionLineDetail] =>
[ItemBasedExpenseLineDetail] =>
[AccountBasedExpenseLineDetail] => QuickBooksOnline\API\Data\IPPAccountBasedExpenseLineDetail Object
(
[CustomerRef] =>
[ClassRef] =>
[AccountRef] => 40
[BillableStatus] => NotBillable
[MarkupInfo] =>
[TaxAmount] =>
[TaxCodeRef] => 22
[TaxInclusiveAmt] =>
[ExpenseDetailLineDetailEx] =>
)
[DepositLineDetail] =>
[PurchaseOrderItemLineDetail] =>
[SalesOrderItemLineDetail] =>
[ItemReceiptLineDetail] =>
[JournalEntryLineDetail] =>
[GroupLineDetail] =>
[SubTotalLineDetail] =>
[TDSLineDetail] =>
[CustomField] =>
[LineEx] =>
)
[1] => QuickBooksOnline\API\Data\IPPLine Object
(
[Id] => 2
[LineNum] => 2
[Description] =>
[Amount] => 23.88
[LinkedTxn] =>
[DetailType] => AccountBasedExpenseLineDetail
[PaymentLineDetail] =>
[DiscountLineDetail] =>
[TaxLineDetail] =>
[SalesItemLineDetail] =>
[DescriptionLineDetail] =>
[ItemBasedExpenseLineDetail] =>
[AccountBasedExpenseLineDetail] => QuickBooksOnline\API\Data\IPPAccountBasedExpenseLineDetail Object
(
[CustomerRef] =>
[ClassRef] =>
[AccountRef] => 37
[BillableStatus] => NotBillable
[MarkupInfo] =>
[TaxAmount] =>
[TaxCodeRef] => 22
[TaxInclusiveAmt] =>
[ExpenseDetailLineDetailEx] =>
)
[DepositLineDetail] =>
[PurchaseOrderItemLineDetail] =>
[SalesOrderItemLineDetail] =>
[ItemReceiptLineDetail] =>
[JournalEntryLineDetail] =>
[GroupLineDetail] =>
[SubTotalLineDetail] =>
[TDSLineDetail] =>
[CustomField] =>
[LineEx] =>
)
[2] => QuickBooksOnline\API\Data\IPPLine Object
(
[Id] => 3
[LineNum] => 3
[Description] =>
[Amount] => 0
[LinkedTxn] =>
[DetailType] => AccountBasedExpenseLineDetail
[PaymentLineDetail] =>
[DiscountLineDetail] =>
[TaxLineDetail] =>
[SalesItemLineDetail] =>
[DescriptionLineDetail] =>
[ItemBasedExpenseLineDetail] =>
[AccountBasedExpenseLineDetail] => QuickBooksOnline\API\Data\IPPAccountBasedExpenseLineDetail Object
(
[CustomerRef] =>
[ClassRef] =>
[AccountRef] => 94
[BillableStatus] => NotBillable
[MarkupInfo] =>
[TaxAmount] =>
[TaxCodeRef] => 22
[TaxInclusiveAmt] =>
[ExpenseDetailLineDetailEx] =>
)
[DepositLineDetail] =>
[PurchaseOrderItemLineDetail] =>
[SalesOrderItemLineDetail] =>
[ItemReceiptLineDetail] =>
[JournalEntryLineDetail] =>
[GroupLineDetail] =>
[SubTotalLineDetail] =>
[TDSLineDetail] =>
[CustomField] =>
[LineEx] =>
)
)
[TxnTaxDetail] => QuickBooksOnline\API\Data\IPPTxnTaxDetail Object
(
[DefaultTaxCodeRef] =>
[TxnTaxCodeRef] =>
[TotalTax] => 11.69
[TaxLine] => QuickBooksOnline\API\Data\IPPLine Object
(
[Id] =>
[LineNum] =>
[Description] =>
[Amount] => 11.69
[LinkedTxn] =>
[DetailType] => TaxLineDetail
[PaymentLineDetail] =>
[DiscountLineDetail] =>
[TaxLineDetail] => QuickBooksOnline\API\Data\IPPTaxLineDetail Object
(
[TaxRateRef] => 37
[PercentBased] => true
[TaxPercent] => 15
[NetAmountTaxable] => 77.90
[TaxInclusiveAmount] =>
[OverrideDeltaAmount] =>
[ServiceDate] =>
[TaxLineDetailEx] =>
)
[SalesItemLineDetail] =>
[DescriptionLineDetail] =>
[ItemBasedExpenseLineDetail] =>
[AccountBasedExpenseLineDetail] =>
[DepositLineDetail] =>
[PurchaseOrderItemLineDetail] =>
[SalesOrderItemLineDetail] =>
[ItemReceiptLineDetail] =>
[JournalEntryLineDetail] =>
[GroupLineDetail] =>
[SubTotalLineDetail] =>
[TDSLineDetail] =>
[CustomField] =>
[LineEx] =>
)
)
[TxnSource] =>
[TaxFormType] =>
[TaxFormNum] =>
[TransactionLocationType] =>
[Id] => 282835
[SyncToken] => 0
[MetaData] => QuickBooksOnline\API\Data\IPPModificationMetaData Object
(
[CreatedByRef] =>
[CreateTime] => 2020-10-22T14:40:58-07:00
[LastModifiedByRef] =>
[LastUpdatedTime] => 2020-10-22T14:40:58-07:00
[LastChangedInQB] =>
[Synchronized] =>
)
[CustomField] =>
[AttachableRef] =>
[domain] =>
[status] =>
[sparse] =>
)
)
We then make some modifications and attempt to repost the updated data using
$out = Bill::update($qb_data_original, $qb_data_updated);
$config = $oAuthKeys->getAsArray();
$resultingBillObj = $dataService->Update($out);
print_r($resultingBillObj);
But the error we get says
PHP Fatal error: Uncaught Exception: Can't convert Passed Parameter to IPPReferenceType. in /var/www/html/vendor/quickbooks/v3-php-sdk/src/Facades/FacadeHelper.php:293
Stack trace:
#0 [internal function]: QuickBooksOnline\API\Facades\FacadeHelper::getIPPReferenceTypeBasedOnArray(NULL, 'PayerRef')
#1 /var/www/html/vendor/quickbooks/v3-php-sdk/src/Facades/FacadeHelper.php(195): ReflectionMethod->invoke(NULL, NULL, 'PayerRef')
#2 /var/www/html/vendor/quickbooks/v3-php-sdk/src/Facades/FacadeHelper.php(117): QuickBooksOnline\API\Facades\FacadeHelper::getComplexListObject('getIPPReference...', 'PayerRef', NULL)
#3 /var/www/html/vendor/quickbooks/v3-php-sdk/src/Facades/Bill.php(8): QuickBooksOnline\API\Facades\FacadeHelper::reflectArrayToObject('Bill', Array, true)
#4 /var/www/html/vendor/quickbooks/v3-php-sdk/src/Facades/Bill.php(17): QuickBooksOnline\API\Facades\Bill::create(Array)
#5 /var/www/html/qb_match.php(214): QuickBooksOnline\API\Facades\Bill::update(Object(QuickBooksOnline\API\Data\IPPBill), Array)
#6 {main}
thrown in /var/www/html/vendor/quickbooks/v3-php-sdk/src/Facades/FacadeHelper.php on line 293
It seems its getting stuck on PayerRef which is the fist value in the result.
What is really odd, is that on the API Explorer when we run the same query it returns a much smaller set of data (itdoes not include the 'PayerRef' value) and if we then post that data back in the API explorer (in the update section) it works fine. This is the results from API explorer
{
"QueryResponse": {
"Bill": [
{
"DueDate": "2020-10-22",
"Balance": 89.59,
"HomeBalance": 89.59,
"domain": "QBO",
"sparse": false,
"Id": "282835",
"SyncToken": "0",
"MetaData": {
"CreateTime": "2020-10-22T14:40:58-07:00",
"LastUpdatedTime": "2020-10-22T14:40:58-07:00"
},
"DocNumber": "150577",
"TxnDate": "2020-10-22",
"CurrencyRef": {
"value": "CAD",
"name": "Canadian Dollar"
},
"ExchangeRate": 1,
"Line": [
{
"Id": "1",
"LineNum": 1,
"Amount": 54.02,
"LinkedTxn": [],
"DetailType": "AccountBasedExpenseLineDetail",
"AccountBasedExpenseLineDetail": {
"AccountRef": {
"value": "40",
"name": "Purchases"
},
"BillableStatus": "NotBillable",
"TaxCodeRef": {
"value": "22"
}
}
},
{
"Id": "2",
"LineNum": 2,
"Amount": 23.88,
"LinkedTxn": [],
"DetailType": "AccountBasedExpenseLineDetail",
"AccountBasedExpenseLineDetail": {
"AccountRef": {
"value": "37",
"name": "Shipping"
},
"BillableStatus": "NotBillable",
"TaxCodeRef": {
"value": "22"
}
}
},
{
"Id": "3",
"LineNum": 3,
"Amount": 0,
"LinkedTxn": [],
"DetailType": "AccountBasedExpenseLineDetail",
"AccountBasedExpenseLineDetail": {
"AccountRef": {
"value": "94",
"name": "otherFees"
},
"BillableStatus": "NotBillable",
"TaxCodeRef": {
"value": "22"
}
}
}
],
"TxnTaxDetail": {
"TotalTax": 11.69,
"TaxLine": [
{
"Amount": 11.69,
"DetailType": "TaxLineDetail",
"TaxLineDetail": {
"TaxRateRef": {
"value": "37"
},
"PercentBased": true,
"TaxPercent": 15,
"NetAmountTaxable": 77.9
}
}
]
},
"VendorRef": {
"value": "156",
"name": "vendora"
},
"APAccountRef": {
"value": "46",
"name": "Accounts Payable (A/P)"
},
"TotalAmt": 89.59,
"GlobalTaxCalculation": "TaxExcluded"
}
],
"startPosition": 1,
"maxResults": 1,
"totalCount": 1
},
"time": "2020-11-22T10:01:06.526-08:00"
}
So, what is the reason for this error? Is it because the data set is unexpected and if so how do we return the same data set that appears in the API Explorer?
Thank you

access single value of php object array

I call an api and the response i get is
Array (
[meta] => Array (
[code] => 200
[type] => Success
[message] => Success
)
[data] => Array (
[items] => Array (
[0] => Array (
[id] => b4a235596fd9550dfb69f181f4db007f
[tracking_number] => 2649884668232181
[carrier_code] => hermes
[order_create_time] =>
[destination_code] =>
[status] => delivered
[track_update] =>
[original_country] =>
[itemTimeLength] => 7
[stayTimeLength] => 74
[service_code] =>
[packageStatus] =>
[substatus] =>
[last_mile_tracking_supported] =>
[origin_info] => Array (
[ItemReceived] => 2019-04-09 09:29
[ItemDispatched] =>
[DepartfromAirport] =>
[ArrivalfromAbroad] =>
[CustomsClearance] =>
[DestinationArrived] =>
[weblink] => https://www.hermesworld.com/en/
[phone] =>
[carrier_code] => hermes
[trackinfo] => Array (
[0] => Array (
[Date] => 2019-04-15 11:51
[StatusDescription] => Posted through letterbox
[Details] =>
[checkpoint_status] => delivered
)
[1] => Array (
[Date] => 2019-04-15 09:45
[StatusDescription] => Delivery will be attempted between 10:00 and 14:00 today
[Details] =>
[checkpoint_status] => transit
)
[2] => Array (
[Date] => 2019-04-15 06:39
[StatusDescription] => On its way to the courier
[Details] =>
[checkpoint_status] => transit
)
[3] => Array (
[Date] => 2019-04-14 22:33
[StatusDescription] => At the customers local depot
[Details] =>
[checkpoint_status] => transit
)
.....
)
)
[destination_info] =>
[lastEvent] => Posted through letterbox,2019-04-15 11:51
[lastUpdateTime] => 2019-04-15 11:51
)
)
)
) 1
I would like to access the value of checkpoint_status but im not getting there using the following ways:
response in variable
$track = print_r($track);
1. $track['checkpoint_status']
2. $track[0] // just to see if it returns anything, but no result
3. $track[1] // just to see if it returns anything, but no result
4. array_column($track, 'checkpoint_status'); // returns nothing
You need to loop, to get all checkpoint_status
foreach($array['data']['items'] as $item){
foreach($item['origin_info']['trackinfo'] as $trackinfo){
echo $trackinfo['checkpoint_status'].PHP_EOL;
}
}
Sample output:-https://3v4l.org/IM7I1
You can use array_walk_recursive
$r = [];
array_walk_recursive($a, function($v, $k) use(&$r){
($k == 'checkpoint_status') ? ($r[]=$v) : '';
});
https://3v4l.org/rCVEB
$response = [
'meta' => [
'code' => 200,
'type' => 'Success',
'message' => 'Success',
],
'data' => [
'items' => [
'0' => [
'id' => 'b4a235596fd9550dfb69f181f4db007f',
'tracking_number' => '2649884668232181',
'carrier_code' => 'hermes',
'order_create_time' => null,
'destination_code' => null,
'status' => 'delivered',
'track_update' => null,
'original_country' => null,
'itemTimeLength' => 7,
'stayTimeLength' => 74,
'service_code' => null,
'packageStatus' => null,
'substatus' => null,
'last_mile_tracking_supported' => null,
'origin_info' => [
'ItemReceived' => '2019-04-09 09:29',
'ItemDispatched' => null,
'DepartfromAirport' => null,
'ArrivalfromAbroad' => null,
'CustomsClearance' => null,
'DestinationArrived' => null,
'weblink' => 'https://www.hermesworld.com/en/',
'phone' => null,
'carrier_code' => 'hermes',
'trackinfo' => [
'0' => [
'Date' => '2019-04-15 11:51',
'StatusDescription' => 'Posted through letterbox',
'Details' =>null,
'checkpoint_status' => 'delivered',
],
'1' => [
'Date' => '2019-04-15 09:45',
'StatusDescription' => 'Delivery will be attempted between 10:00 and 14:00 today',
'Details' => null,
'checkpoint_status' => 'transit',
],
'2' => [
'Date' => '2019-04-15 06:39',
'StatusDescription' => 'On its way to the courier',
'Details' =>null,
'checkpoint_status' => 'transit',
],
'3' => [
'Date' => '2019-04-14 22:33',
'StatusDescription' => 'At the customers local depot',
'Details' => null,
'checkpoint_status' => 'transit',
],
]
],
'destination_info' => null,
'lastEvent' => 'Posted through letterbox,2019-04-15 11:51',
'lastUpdateTime' => '2019-04-15 11:51',
]
]
]
];
If you are working on development mode you could turn on display errors on php and may get this result:
echo $response['checkpoint_status']; // won't work as response array has no checkpoint_status keyed array
echo $response[0]; // won't work as response array has no 0 keyed array
echo $response[1]; // won't work as response array has no 1 keyed array
print_r(array_column($response, 'checkpoint_status')); // won't work as response array has no column checkpoint_status
There are many ways in which you could get your result one of which is given below:
$trackinfo = $response['data']['items'][0]['origin_info']['trackinfo'];
$checkpoint_status = array_column($trackinfo, 'checkpoint_status');
print_r($checkpoint_status);
Result:
Array (
[0] => delivered
[1] => transit
[2] => transit
[3] => transit
)

Get values from Paypal payment-intent multidimensional array

I want to implement the serverside-sdk from Paypal to my website. Everything works fine so far.
After the payment-intent got send to Paypal, I receive an array with information about the payment from Paypal.
If I print_r the object I got back it looks like this in my browser:
PayPal\Api\Payment Object (
[_propMap:PayPal\Common\PayPalModel:private] => Array ( [intent] => sale [payer] => PayPal\Api\Payer Object (
[_propMap:PayPal\Common\PayPalModel:private] => Array ( [payment_method] => paypal ) ) [transactions] => Array ( [0] => PayPal\Api\Transaction Object (
[_propMap:PayPal\Common\PayPalModel:private] => Array ( [amount] => PayPal\Api\Amount Object (
[_propMap:PayPal\Common\PayPalModel:private] => Array ( [total] => 0.50 [currency] => EUR ) ) [related_resources] => Array ( ) ) ) ) [redirect_urls] => PayPal\Api\RedirectUrls Object ( [_propMap:PayPal\Common\PayPalModel:private] => Array ( [return_url] => https://www.fabiansquinobal.com/addjob_submitted.php [cancel_url] => https://example.com/your_cancel_url.html ) ) [id] => PAYID-LSSMWWI9WR61061C3673442W [state] => created [create_time] => 2019-04-03T15:03:52Z [links] => Array ( [0] => PayPal\Api\Links Object (
[_propMap:PayPal\Common\PayPalModel:private] => Array ( [href] => https://api.sandbox.paypal.com/v1/payments/payment/PAYID-LSSMWWI9WR61061C3673442W [rel] => self [method] => GET ) ) [1] => PayPal\Api\Links Object (
[_propMap:PayPal\Common\PayPalModel:private] => Array ( [href] => https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-0RG36824VV460380F [rel] => approval_url [method] => REDIRECT ) ) [2] => PayPal\Api\Links Object (
[_propMap:PayPal\Common\PayPalModel:private] => Array ( [href] => https://api.sandbox.paypal.com/v1/payments/payment/PAYID-LSSMWWI9WR61061C3673442W/execute [rel] => execute [method] => POST ) ) ) )
)
I am completly overwhelmed with that. I would need to know how I can get to the "[id] => PAYID-LSSMWWI9WR61061C3673442W" or generally extract information out of this "thing".
Regards
EDIT:
The var_export of the array looks like this:
PayPal\Api\Payment::__set_state(
array( '_propMap' => array ( 'intent' => 'sale', 'payer' => PayPal\Api\Payer::__set_state(
array( '_propMap' => array ( 'payment_method' => 'paypal', ), )), 'transactions' => array ( 0 => PayPal\Api\Transaction::__set_state(
array( '_propMap' => array ( 'amount' => PayPal\Api\Amount::__set_state(
array( '_propMap' => array ( 'total' => '15.00', 'currency' => 'EUR', ), )), 'related_resources' => array ( ), ), )), ), 'redirect_urls' => PayPal\Api\RedirectUrls::__set_state(array( '_propMap' => array ( 'return_url' => 'https://www.fabiansquinobal.com/addjob_submitted.php', 'cancel_url' => 'https://example.com/your_cancel_url.html', ), )), 'id' => 'PAYID-LSSNC7I1CX40811F59322531', 'state' => 'created', 'create_time' => '2019-04-03T15:30:05Z', 'links' => array ( 0 => PayPal\Api\Links::__set_state(
array( '_propMap' => array ( 'href' => 'https://api.sandbox.paypal.com/v1/payments/payment/PAYID-LSSNC7I1CX40811F59322531', 'rel' => 'self', 'method' => 'GET', ), )), 1 => PayPal\Api\Links::__set_state(
array( '_propMap' => array ( 'href' => 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-98A35361RF153213R', 'rel' => 'approval_url', 'method' => 'REDIRECT', ), )), 2 => PayPal\Api\Links::__set_state(
array( '_propMap' => array ( 'href' => 'https://api.sandbox.paypal.com/v1/payments/payment/PAYID-LSSNC7I1CX40811F59322531/execute', 'rel' => 'execute', 'method' => 'POST', ), )), ), ), )
)
An echo of the object looks like this:
{ "intent": "sale",
"payer": { "payment_method": "paypal" },
"transactions": [ { "amount": { "total": "0.50", "currency": "EUR" },
"related_resources": [] } ],
"redirect_urls": { "return_url": "https://www.fabiansquinobal.com/addjob_submitted.php", "cancel_url": "https://example.com/your_cancel_url.html" },
"id": "PAYID-LSSNFSY6AJ60558N2288040L",
"state": "created", "create_time": "2019-04-03T15:35:38Z",
"links": [ { "href": "https://api.sandbox.paypal.com/v1/payments/payment/PAYID-LSSNFSY6AJ60558N2288040L",
"rel": "self", "method": "GET" },
{ "href": "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-5KK55362XB209301D",
"rel": "approval_url", "method": "REDIRECT" },
{ "href": "https://api.sandbox.paypal.com/v1/payments/payment/PAYID-LSSNFSY6AJ60558N2288040L/execute",
"rel": "execute", "method": "POST" } ]
}
Either decode the string to an array and use:
$arr = json_decode($json, true);
echo $arr['id'];
Or if you want it as an object:
$arr = json_decode($json);
echo $arr->id;
https://3v4l.org/bF2t9

How can i get subsidiaryList of locations from NetSuite?

I prepared LocationSearch object and sent to NetSuite server
But in result, subsidiaryList of Location Object always is null, it should be same with parent property.
[record] => Array
(
[0] => Location Object
(
[name] => zzzzzz
[parent] => RecordRef Object
(
[internalId] => 7
[externalId] =>
[type] =>
[name] => xxxxxxxx
)
[includeChildren] =>
[subsidiaryList] =>
[isInactive] =>
[tranPrefix] =>
[attention] =>
[addressee] => zzzz
[addrPhone] =>
[addr1] =>
[addr2] =>
[addr3] =>
[city] =>
[state] =>
[zip] =>
[country] => _zz
[addrText] => zzzzz
[override] =>
[logo] =>
[makeInventoryAvailable] => 1
[makeInventoryAvailableStore] => 1
[classTranslationList] =>
[customFieldList] =>
[internalId] => 11
[externalId] =>
[nullFieldList] =>
)
................
$paramtypesmap of class Location
"name" => "string",
"parent" => "RecordRef",
"includeChildren" => "boolean",
"subsidiaryList" => "RecordRefList",
"isInactive" => "boolean",
"tranPrefix" => "string",
"attention" => "string",
"addressee" => "string",
"addrPhone" => "string",
"addr1" => "string",
"addr2" => "string",
"addr3" => "string",
"city" => "string",
"state" => "string",
"zip" => "string",
"country" => "Country",
"addrText" => "string",
"override" => "boolean",
"logo" => "RecordRef",
"makeInventoryAvailable" => "boolean",
"makeInventoryAvailableStore" => "boolean",
"classTranslationList" => "ClassTranslationList",
"customFieldList" => "CustomFieldList",
"internalId" => "string",
"externalId" => "string",
How can i get subsidiaryList of locations from NetSuite ?
Thank you very much
Best regards
Do you have "body fields only" set as a preference?? If so, turn it off.

Categories