cancel
Showing results for 
Search instead for 
Did you mean: 

PHP API setTransactionSettings - duplicateWIndow

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

fifty-git
Regular Contributor
1 ACCEPTED SOLUTION

Accepted Solutions

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!

 

View solution in original post

Aaron
All Star
11 REPLIES 11

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!

 

Aaron
All Star

That's exactly what I was looking for. Thank you. I'll post my results later.

 

- Don

fifty-git
Regular Contributor

How could I use this method to set multiple settingNames?

 

Thanks,

 

Don

fifty-git
Regular Contributor

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);

 

Thank you for you help!

 

- Don

fifty-git
Regular Contributor
$transactionRequestType->addToTransactionSettings($duplicateWindowSetting);

 

this has changed a bit. Now you need to pass an array

 

$transactionRequestType->addToTransactionSettings([$duplicateWindowSetting]);

 

 

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

fifty-git
Regular Contributor

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.

very cool, thank you Aaron!

fifty-git
Regular Contributor