AddOrder issue on WHMCS Local API - php

I'm adding a new order using WHMCS local API. Everything works fine except custom fields.
$command = 'AddOrder';
$postData = array(
'clientid' => $client_id,
'pid' => array($product_id),
'billingcycle' => array('monthly'),
'customfields' => array(base64_encode(serialize(array(1 => $site_id)))),
'paymentmethod' => 'stripe',
);
return localAPI($command, $postData);
My custom field ID is 53 but I set the key to 1 because of tutorials. Also I tried 53 as key array(base64_encode(serialize(array(53 => $site_id)))) but nothing changed.
Do you have any suggestion?

Try this:
$command = 'AddOrder';
$postData = array(
'clientid' => $client_id,
'pid' => array($product_id),
'billingcycle' => array('monthly'),
'customfields[0]' => array(base64_encode(serialize(array(1 => $site_id)))),//changes here
'paymentmethod' => 'stripe',
);
return localAPI($command, $postData);ode here

Related

Hipay payment Gateway integration Response in php

I'm using a hipay wallet test account and used there webservices to integrate. Transaction is working fine but problem is that i'm not getting the response in the page, it is suppossed to get in $_POST['xml'] on the response page
$setUrlAck =show_page_link("payment/hipay_new/response.php",true);
Below is my code
if ($PaymentDetails['sel_payment_env'] == 1) {
$wsdl = 'https://ws.hipay.com/soap/subscription?wsdl'; //for live
} else {
$wsdl = 'https://test-ws.hipay.com/soap/subscription?wsdl';//for testing
}
// If the payment is accepted, the user will be redirected to this page
$setURLOk= show_page_link(FILE_THANKS."?add=success&OrderNo=".$orderid,true);
// If the payment is refused, the user will be redirected to this page
$setUrlNok=show_page_link(FILE_THANKS."?cancleMsg=true",true);
// If the user cancels the payment, he will be redirected to this page
$setUrlCancel=show_page_link(FILE_THANKS."?cancleMsg=true",true);
// The merchant?s site will be notified of the result of the payment by a call to the script
$setUrlAck =show_page_link("payment/hipay_new/response.php",true);
$initArray = array(
'wsLogin' => $wsLogin, // Your wsLogin
'wsPassword' => $wspassword, // Your wsPassword
'websiteId' => $txt_Merchant, // Your webSiteId
'categoryId' => $PaymentDetails['txt_category_id'], // Your website category ID (https://test-payment.hipay.com/order/list-categories/id/(websiteId))
'customerEmail' => $customer_email, // Your customers' email
);
$options = array(
'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP,
'cache_wsdl' => WSDL_CACHE_NONE,
);
$client = new SoapClient($wsdl, $options);
$data = array(
'currency' => $currency_code,
'rating' => 'ALL',
'locale' => 'fr_FR',
'manualCapture' =>1,
'label' => 'My label is a Manged Subscrption Test Service ',
'customerIpAddress' => $_SERVER["REMOTE_ADDR"],
'merchantReference' => 'AZERTY',
'urlCallback' => $setUrlAck, // Here in this page i'm suppossed to get the response in $_POST
'urlAccept' => $setURLOk,
'urlCancel' =>$setUrlCancel,
'payments' => array(
'initial' => array(
'name' => 'Payment',
'description' => 'Payment for printing products',
'amount' => $price,
'subscriptionId' => 'QWERTY',
'periodType' => 'normal',
'recurrence' => array(
'frequency' => 0,
'duration' => 'managed'
),
),
),
);
Kindly guide me if anyone got through the same issues
The issue is solved, problem was that my firewall setting was blocking the response

PayPal API with Laravel

I am using a paypal plugin, and and for some reason I can't get paypal to go to my callback url when payment is complete. I have used the same plugin before which worked so it must be something stupid I am doing.
Here's a sample array of the data I am passing into the plugin
Array
(
[sandboxMode] => 1
[successUrl] => http://x.x.x.x/safespacesforkids/rebuild/public/payment/success
[cancelUrl] => http://x.x.x.x/safespacesforkids/rebuild/public/assessment/checkout
[backendUrl] => http://x.x.x.x/safespacesforkids/rebuild/public/payment/pp/316e7c50a117c91b392a013a6e1a22e9a4f97b1e
[merchantAccount] => myemail#domain.com
[language] => EN
[currency] => AUD
[invoice] => 55ca0738e638d
[purpose] => Company Name
[amount] => 180.68
[remark] =>
)
When I copy backendUrl in to my browser and go there myself it processes the order just fine. but paypal won't
My code
public function redirect()
{
//My Basket - Info
$basket = Cart::getBasket();
//Make payment hash
$user = User::find(Auth::id());
$user->hash = sha1(rand().time());
$user->save();
$paypalInfo = array(
'sandboxMode' => true,
'successUrl' => URL::route('payment.success'),
'cancelUrl' => URL::route('assessment.checkout'),
'backendUrl' => URL::route('payment.paypal', $user->hash),
'merchantAccount' => System::first()->paypal_email,
'language' => 'EN',
'currency' => 'AUD',
'invoice' => uniqid(),
'purpose' => 'Safe Spaces for Kids',
'amount' => Helper::price($basket['total']),
'remark' => ''
);
Helper::pr($paypalInfo,1);
$adapter = Gateway::driver('Paypal')->initialize($paypalInfo);
$generated = $adapter->render();
return View::make('payment/redirect', ['form' => $generated]);
}

How to add multiple emails to a sendgrid mailinglist using guzzle

I think I just have a problem with my syntax. I can add one user at a time no problem just fine:
$client = new \GuzzleHttp\Client();
$data = [
'api_user' => $this->api_user,
'api_key' => $this->api_key,
'list' => 'listname',
'data' => json_encode(array('email' => 'example#email.com', 'name' => 'example'))
];
$client->post('https://api.sendgrid.com/api/newsletter/lists/email/add.json', ['body' => $data]);
Now I can't figure out how to specify multiple emails using guzzle. Sendgrid's docs (https://sendgrid.com/docs/API_Reference/Marketing_Emails_API/emails.html) show a curl example using multiple data[]={..json..} params, which I can't figure out how to specify with Guzzle.
So far I've tried a multidimensional array, which doesn't work because I believe I need to pass them as separate params, not as one:
$data = [
'api_user' => $this->api_user,
'api_key' => $this->api_key,
'list' => 'listname',
'data' => json_encode(array(
array('email' => 'example1#email.com', 'name' => 'example1'),
array('email' => 'example2#email.com', 'name' => 'example2'),
array('email' => 'example3#email.com', 'name' => 'example3')
))
];

SOAP 4 set_relationship not working

After battling for getting more than 20 entries with get_entry_list, i'm now trying to use the SOAP API on SugarCRM 6.5 to set a relationship between two elements, created from a form on the user-land website.
The set_relationship method is described as following in the devs blog :
$response = set_relationship(session, module_name, module_id, link_field_name, related_ids, name_value_list, delete);
So here is the code which handles the request, assuming that another part of the code handles the security.
$values = array( 'id_frame' => $_POST['id_frame'],
'id_battery' => $_POST['id_battery'],
'reseller' => $_POST['reseller'],
'date_purchase' => $_POST['date_purchase'],
'products_versionning' => $_POST['product_purchased'],
'first_name' => $_POST['first_name'],
'last_name' => $_POST['name'],
'phone_home' => $_POST['phone'],
'email' => $_POST['email'],
'primary_address_street' => $_POST['address'],
'primary_address_street_2' => $_POST['address2'],
'primary_address_street_city' => $_POST['city'],
'primary_address_street_postalcode' => $_POST['zip'],
);
try{
$prod_register = $soapClient->set_entry(
$sessid,
'myco_product_register',
array( array('name' => 'id_frame', 'value' => $values['id_frame']),
array('name' => 'id_battery', 'value' => $values['id_battery']),
array('name' => 'date_purchase', 'value' => $values['date_purchase']),
array('name' => 'first_name', 'value' => $values['first_name']),
array('name' => 'last_name', 'value' => $values['last_name']),
array('name' => 'phone_home', 'value' => $values['phone_home']),
array('name' => 'email', 'value' => $values['email']),
array('name' => 'primary_address_street', 'value' => $values['primary_address_street']),
array('name' => 'primary_address_street_city', 'value' => $values['primary_address_street_city']),
array('name' => 'primary_address_street_postalcode','value' => $values['primary_address_street_postalcode']),
array('name' => 'description','value' => "Modèle : " . $values['products_versionning'] . "\nAcheté le " . $values['date_purchase'] . " à " . $values['reseller']),
)
);
$client = $soapClient->set_entry(
$sessid,
'Accounts',
array( array('name' => 'name', 'value' => $values['first_name'] . ' ' . $values['last_name']),
array('name' => 'billing_address_street', 'value' => $values['primary_address_street']),
array('name' => 'billing_address_city', 'value' => $values['primary_address_street_city']),
array('name' => 'billing_address_postalcode', 'value' => $values['primary_address_street_postalcode']),
)
);
$entry_id = $prod_register->id;
$relationship_parameters = array(
"module1" => "myco_product_register",
"module1_id" => array($entry_id),
"module2" => "myco_products_versionning",
"module2_id" => array($values['products_versionning'])
);
//Now i'm setting the relationships
$response = $soapClient->set_relationship($sessid, "myco_product_register", $entry_id,
'myco_products_versionning_id_c', $values['products_versionning'], array(), 0);
$response = $soapClient->set_relationship($sessid, "myco_product_register", $entry_id,
'myco_resellers_id_c', $values['reseller'], array(), 0);
Both set_entry requests work and return a working id, but no one of the relationships work ($responses contains a failed equal to 1). So that's not a connection problem or such.
Talking about the relationships, one guy from the devblog said that
there has to be a relationship between the two modules
there has to be at least one related field in the module which handle the relation, whose name you can find in the module's vardefs.php
and i have
A One-to-one relationship between the product_register module and both products_versionning and resellers
A related field in product_register for each related module.
What may i be missing ?
try checking the log file of SugarCRM, you should find some mistakes. I used this API to create a relationship between Contacts and Accounts, and working properly. On the logs might find the answer to the problem.
try {
$result = $this->soapClient->set_relationship($this->sessionId,
$accountModuleName, $accountId, $relationName, $contactsId);
$this->doEvent(self::EVENT_WS_OPERATION_CALL);
if ($result->created > 0 && $result->failed === 0) {
return true;
} else {
return false;
}

if is_numeric condition issue

I have a http_build_query array and file_get_contents that looks like this:
$optionValues = http_build_query( array(
'leadcomm' => getVariable('LEADCOMM'),
'CCID' => getVariable('CCID'),
'QTR' => getVariable('QTR'),
'CLK' => getVariable('CLK'),
'dck' => getVariable('DCK'),
'bal_one' => getVariable('BAL_ONE'),
'product' => getVariable('PRODUCT'),
'prop_st' => getVariable('PROP_ST'),
'cred_grade' => getVariable('CRED_GRADE'),
'prop_zip' => getVariable('PROP_ZIP'),
'prop_desc' => getVariable('PROP_DESC'),
'spec_home' => getVariable('SPEC_HOME'),
'purchase_contract' => getVariable('PURCHASE_CONTRACT'),
'est_val' => getVariable('EST_VAL'),
'down_pmt' => getVariable('DOWN_PMT'),
'loan_type' => getVariable('LOAN_TYPE'),
'buy_timeframe' => getVariable('BUY_TIMEFRAME'),
'agent_found' => getVariable('AGENT_FOUND'),
'va_status' => getVariable('VA_STATUS'),
'income' => getVariable('INCOME'),
'annual_verifiable_income' => getVariable('ANNUAL_VERIFIABLE_INCOME'),
'fha_bank_foreclosure' => getVariable('FHA_BANK_FORECLOSURE'),
'num_mortgage_lates' => getVariable('NUM_MORTGAGE_LATES'),
'email' => getVariable('EMAIL'),
'fname' => getVariable('FNAME'),
'lname' => getVariable('LNAME'),
'address' => getVariable('ADDRESS'),
'city' => getVariable('CITY'),
'state' => getVariable('STATE'),
'zip' => getVariable('ZIP'),
'pri_phon' => getVariable('PRI_PHON'),
'sec_phon' => getVariable('SEC_PHON'),
'capture_method' => getVariable('CAPTURE_METHOD'),
'aid' => getVariable('AID'),
'srlp' => getVariable('SRLP'),
'scid' => getVariable('SCID'),
'buyer_id' => getVariable('BUYER_ID'),
'cid' => getVariable('CID'),
'ppcid' => getVariable('PPCID')
)
);
$url = 'http://api.example.com/import-lead-data.php';
$options['http'] = array(
'method' => "POST",
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => $optionValues,
);
$context = stream_context_create($options);
$result = file_get_contents($url, NULL, $context);
I need to check if $results returns a numeric value. If it does, I need to set a new variable ($lead_id) to equal $results, pass $lead_id through another http_build_query array and finally do another file_get_contents $results. The code above works fine. The second part of the code is where I need some assistance. This is what I have for the second part of my code:
if (is_numberic($result)) {
$lead_id(isset($results));
};
$leadValues = http_build_query( array(
'lead_id' => "LEAD_ID"
)
);
$leadurl = 'http://api.bankradar.com/import-lead-response.php';
$leadoptions['http'] = array(
'method' => "POST",
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => $leadValues,
);
$leadcontext = stream_context_create($leadoptions);
$leadResult = file_get_contents($leadurl, NULL, $leadcontext);
I think my problem is with the isset part of the code but I'm not sure.
you put
if (is_numberic($result)) {
should be
if (is_numeric($result)) {
But, i use this way
if (ctype_digit($result)) {
that way it can only containt digits, no decimals or any other characters... not sure if thats what your after
You are calling $lead_id as a function. Just change
$lead_id(isset($results));
to
$lead_id = $results;
You misspelled is_numeric (there's a b in yours) - is_numberic

Categories