Hi, I am trying to set the duplicateWindow time using:
$transactionRequestType->setTransactionSettings();
I found this in the PHP SDK code on this page >>
public function setTransactionSettings(array $transactionSettings) {}
That tells me this method accepts an array, but I'm not sure how to format the data I send.
I found the XML version:
<transactionSettings>
<setting>
<settingName>duplicateWindow</settingName>
<settingValue>0</settingValue>
</setting>
</transactionSettings>
But I'm not sure how to translate that into a PHP array.
Thanks,
- Don
Solved! Go to Solution.
12-01-2016 01:31 PM - edited 12-01-2016 01:35 PM
Hi Don,
Instead of calling that method directly, we have other methods that allow you to add settings to the array that eventually gets used to build the transaction. For duplicateWindow specifically, you'd do something like this:
First, you'll need to create a variable of type "SettingType", then add the SettingName and SettingValue to that variable using the "setSettingName" and "setSettingValue" methods, like so:
//add the values for transaction settings $duplicateWindowSetting = new AnetAPI\SettingType(); $duplicateWindowSetting->setSettingName("duplicateWindow"); $duplicateWindowSetting->setSettingValue("600");
Then, add the settings to the TransactionRequestType values that you're building using the "addToTransactionSettings" method:
$transactionRequestType->addToTransactionSettings($duplicateWindowSetting);
Other transaction settings are set the same way.
Let us know if you have any other questions!
12-02-2016 10:30 AM
Hi Don,
Instead of calling that method directly, we have other methods that allow you to add settings to the array that eventually gets used to build the transaction. For duplicateWindow specifically, you'd do something like this:
First, you'll need to create a variable of type "SettingType", then add the SettingName and SettingValue to that variable using the "setSettingName" and "setSettingValue" methods, like so:
//add the values for transaction settings $duplicateWindowSetting = new AnetAPI\SettingType(); $duplicateWindowSetting->setSettingName("duplicateWindow"); $duplicateWindowSetting->setSettingValue("600");
Then, add the settings to the TransactionRequestType values that you're building using the "addToTransactionSettings" method:
$transactionRequestType->addToTransactionSettings($duplicateWindowSetting);
Other transaction settings are set the same way.
Let us know if you have any other questions!
12-02-2016 10:30 AM
That's exactly what I was looking for. Thank you. I'll post my results later.
- Don
12-02-2016 11:55 AM
How could I use this method to set multiple settingNames?
Thanks,
Don
12-09-2016 11:14 AM
Hi Don,
It would be pretty similar, just making a new instance of class SettingType() for each different setting you wanted. Something like
//add the values for each setting $duplicateWindowSetting = new AnetAPI\SettingType(); $duplicateWindowSetting->setSettingName("duplicateWindow"); $duplicateWindowSetting->setSettingValue("600");
$allowPartialAuthSetting = new AnetAPI\SettingType();
$allowPartialAuthSetting->setSettingName("allowPartialAuth");
$allowPartialAuthSetting->setSettingValue("true");
and so on, then adding each transaction setting to the transaction request by doing something like:
$transactionRequestType->addToTransactionSettings($duplicateWindowSetting); $transactionRequestType->addToTransactionSettings($allowPartialAuthSetting);
12-09-2016 03:00 PM
Thank you for you help!
- Don
12-14-2016 12:11 PM
$transactionRequestType->addToTransactionSettings($duplicateWindowSetting);
this has changed a bit. Now you need to pass an array
$transactionRequestType->addToTransactionSettings([$duplicateWindowSetting]);
12-30-2016 10:40 AM
Perhaps this is the new SDK, which I need to update to soon.
If I try to pass the setting as an array now, it causes an error.
Can you show more code to clarify?
Thanks,
Don
01-06-2017 07:20 AM
The addToTransactionSettings method expects as its argument an instance of "SettingType", so passing an array will fail.
"SettingType" is in fact an array defined elsewhere in the SDK, but since it's defined as its own datatype, you've got to pass addToTransactionSettings something that it will recognize as a SettingType.
In my sample code above, I first declare $duplicateWindowSetting as a "SettingType":
$duplicateWindowSetting = new AnetAPI\SettingType();
Then I add some data, and after that pass it to the addToTransactionSettings method:
$transactionRequestType->addToTransactionSettings($duplicateWindowSetting);
@fifty-git, even in the latest SDK you shouldn't need to pass an array as long as you're following this pattern.
01-06-2017 09:20 AM
very cool, thank you Aaron!
01-06-2017 11:12 AM