Hi there, I have successfully got wordpress gravity form submission to create users in Splynx but I am having trouble getting it to assign existing Tariffs.
See my code below, however I can confirm that the correct name of the internet tariff is coming through to the splynx API because I see it in the API log.
"internet_tariffs FTTB 50/20|89.99"
I have tried making this the Internet Tariff title and the name and neither seem to work
Is this because there are additional fields that are required to be set when assigning a tariff?
add_action( ‘gform_after_submission’, ‘post_to_third_party’, 10, 2 );
function post_to_third_party( $entry, $form ) {
$firstname = rgpost( ‘input_3_3’ );
$surname = rgpost( ‘input_3_6’ );
$phone = rgpost( ‘input_4’ );
$email = rgpost( ‘input_5’ );
$street = rgpost( ‘input_15_2’ );
$city = rgpost( ‘input_15_3’ );
$zipcode = rgpost( ‘input_15_5’ );
$internet_plan = rgpost( ‘input_19’ );
$location = rgpost( ‘input_21’ );
include ‘SplynxApi.php’;
$api_url = ‘http://xxxxxxxx/’; // please set your Splynx URL
$key = “xxxxxxxxxx”; // please set your key
$secret = “xxxxxxxxxxx”; // please set your secret
// don’t forget to add permissions to API Key, for changing locations.
$api = new SplynxAPI($api_url, $key, $secret);
$locationsApiUrl = “admin/administration/locations”;
$customersApiUrl = “admin/customers/customer?” . http_build_query($search);
print “Create Customers\n”;
$result = $api->api_call_post($customersApiUrl,
array(
‘name’ => $firstname . ’ ’ . $surname,
‘login’ => $email,
‘category’ => ‘person’,
‘phone’ => $phone,
‘location_id’ => $location,
‘partner_id’ => ‘1’,
‘street_1’ => $street,
‘zip_code’ => $zipcode,
‘city’ => $city,
‘status’ => ‘active’,
‘internet_tariffs’ => $internet_plan,
));
print "Result: ";
if ($result) {
print “Ok!\n”;
print_r($api->response);
$locationId = $api->response[‘id’];
} else {
print “Fail! Error code: $api->response_code\n”;
print_r($api->response);
$locationId = false;
}