Paypal Merchant SDK with Laravel - php

I am trying to create paypal recurring payment profile but i am facing this error
{"error":{"type":"Symfony\Component\Debug\Exception\FatalErrorException","message":"Class 'RecurringPaymentsProfileDetailsType' not found","file":"/home/test/public_html/payment/app/models/payment/Purchase.php","line":7}}
my code
<?php
class Purchase extends Eloquent
{
public static function submit($name, $email, $ccNumber, $pinCode, $expiryDate)
{
$profileDetails = new RecurringPaymentsProfileDetailsType();
$profileDetails->BillingStartDate = "2014-11-17T00:00:00:000Z";
$paymentBillingPeriod = new BillingPeriodDetailsType();
$paymentBillingPeriod->BillingFrequency = 30;
$paymentBillingPeriod->BillingPeriod = "Day";
$paymentBillingPeriod->Amount = new BasicAmountType("USD", "1.0");
$scheduleDetails = new ScheduleDetailsType();
$scheduleDetails->Description = "recurring billing";
$scheduleDetails->PaymentPeriod = $paymentBillingPeriod;
$createRPProfileRequestDetails = new CreateRecurringPaymentsProfileRequestDetailsType();
$creditCard = new CreditCardDetailsType();
$creditCard->CreditCardNumber = "4032034992341100";
$creditCard->CreditCardType = "Visa";
$creditCard->CVV2 = "962";
$creditCard->ExpMonth = 11;
$creditCard->ExpYear = 2019;
$createRPProfileRequestDetails->CreditCard = $creditCard;
$createRPProfileRequestDetails->ScheduleDetails = $scheduleDetails;
$createRPProfileRequestDetails->RecurringPaymentsProfileDetails = $profileDetails;
$createRPProfileRequest = new CreateRecurringPaymentsProfileRequestType();
$createRPProfileRequest->CreateRecurringPaymentsProfileRequestDetails = $createRPProfileRequestDetails;
$createRPProfileReq = new CreateRecurringPaymentsProfileReq();
$createRPProfileReq->CreateRecurringPaymentsProfileRequest = $createRPProfileRequest;
$config = array (
'mode' => Config::get('paypal.mode') ,
'acct1.UserName' => Config::get('paypal.username'),
'acct1.Password' => Config::get('paypal.password'),
'acct1.Signature' => Config::get('paypal.signature')
);
$paypalService = new PayPalAPIInterfaceServiceService($config);
$createRPProfileResponse = $paypalService->CreateRecurringPaymentsProfile($createRPProfileReq);
die($createRPProfileResponse);
}
}
?>

Related

How can i export & Import custom modules as Package using PHP Script (Vtlib Function) from my CRM vtiger 7

I hope all of you are doing well.
I have created a custom module used this script.we have run this script in root folder.All field are working fine and list view also perfect.
```
<?php
include_once 'vtlib/Vtiger/Module.php';
include_once 'vtlib/Vtiger/Package.php';
include_once 'includes/main/WebUI.php';
include_once 'include/Webservices/Utils.php';
$Vtiger_Utils_Log = true;
$MODULENAME = 'Laptop';
$moduleInstance = Vtiger_Module::getInstance($MODULENAME);
if ($moduleInstance || file_exists('modules/'.$MODULENAME)) {
echo "Module already present - choose a different name.";
} else {
$moduleInstance = new Vtiger_Module();
$moduleInstance->name = $MODULENAME;
$moduleInstance->parent= 'Tools';
$moduleInstance->save();
// Schema Setup
$moduleInstance->initTables();
// Field Setup
$block = new Vtiger_Block();
$block->label = 'LBL_'. strtoupper($moduleInstance->name) . '_INFORMATION';
$moduleInstance->addBlock($block);
$blockcf = new Vtiger_Block();
$blockcf->label = 'LBL_CUSTOM_INFORMATION';
$moduleInstance->addBlock($blockcf);
// Text Area1 Item_Name
$itemName = new Vtiger_Field();
$itemName->name = 'itemname';
$itemName->label= 'Item Name';
$itemName->uitype= 1;
$itemName->column = $itemName->name;
$itemName->columntype = 'VARCHAR(100)';
$itemName->typeofdata = 'V~M';
$block->addField($itemName);
// Text Area2 Item_Deatils
$itemdeatils = new Vtiger_Field();
$itemdeatils->name = 'itemdeatils';
$itemdeatils->label= 'Item Deatils';
$itemdeatils->uitype= 1;
$itemdeatils->column = $itemdeatils->name;
$itemdeatils->columntype = 'VARCHAR(100)';
$itemdeatils->typeofdata = 'V~O';
$block->addField($itemdeatils);
$moduleInstance->setEntityIdentifier($itemdeatils);
// Text Area3 Item_Company.
$companyname = new Vtiger_Field();
$companyname->name = 'companyname';
$companyname->label= 'Company Name.';
$companyname->uitype= 15;
$companyname->column = $companyname->name;
$companyname->columntype = 'VARCHAR(100)';
$companyname->typeofdata = 'V~O';
$block->addField($companyname);
$companyname->setPicklistValues( Array ('Sumsung','HP','Dell', 'Lenovo','Apple') );
$description = new Vtiger_Field();
$description->name = 'description';
$description->label= 'Description';
$description->uitype= 19;
$description->column = 'description';
$description->table = 'vtiger_crmentity';
$blockcf->addField($description);
// Recommended common fields every Entity module should have (linked to core table)
$mfield1 = new Vtiger_Field();
$mfield1->name = 'assigned_user_id';
$mfield1->label = 'Assigned To';
$mfield1->table = 'vtiger_crmentity';
$mfield1->column = 'smownerid';
$mfield1->uitype = 53;
$mfield1->typeofdata = 'V~M';
$block->addField($mfield1);
$mfield2 = new Vtiger_Field();
$mfield2->name = 'createdtime';
$mfield2->label= 'Created Time';
$mfield2->table = 'vtiger_crmentity';
$mfield2->column = 'createdtime';
$mfield2->uitype = 70;
$mfield2->typeofdata = 'DT~O';
$mfield2->displaytype= 2;
$block->addField($mfield2);
$mfield3 = new Vtiger_Field();
$mfield3->name = 'modifiedtime';
$mfield3->label= 'Modified Time';
$mfield3->table = 'vtiger_crmentity';
$mfield3->column = 'modifiedtime';
$mfield3->uitype = 70;
$mfield3->typeofdata = 'DT~O';
$mfield3->displaytype= 2;
$block->addField($mfield3);
/* NOTE: Vtiger 7.1.0 onwards */
$mfield4 = new Vtiger_Field();
$mfield4->name = 'source';
$mfield4->label = 'Source';
$mfield4->table = 'vtiger_crmentity';
$mfield4->displaytype = 2; // to disable field in Edit View
$mfield4->quickcreate = 3;
$mfield4->masseditable = 0;
$block->addField($mfield4);
$mfield5 = new Vtiger_Field();
$mfield5->name = 'starred';
$mfield5->label = 'starred';
$mfield5->table = 'vtiger_crmentity_user_field';
$mfield5->displaytype = 6;
$mfield5->uitype = 56;
$mfield5->typeofdata = 'C~O';
$mfield5->quickcreate = 3;
$mfield5->masseditable = 0;
$block->addField($mfield5);
$mfield6 = new Vtiger_Field();
$mfield6->name = 'tags';
$mfield6->label = 'tags';
$mfield6->displaytype = 6;
$mfield6->columntype = 'VARCHAR(1)';
$mfield6->quickcreate = 3;
$mfield6->masseditable = 0;
$block->addField($mfield6);
/* End 7.1.0 */
// Filter Setup
$filter1 = new Vtiger_Filter();
$filter1->name = 'All';
$filter1->isdefault = true;
$moduleInstance->addFilter($filter1);
$filter1->addField($itemName);
$filter1->addField($itemdeatils, 1);
$filter1->addField($companyname, 2);
$filter1->addField($mfield1, 3);
// Sharing Access Setup
$moduleInstance->setDefaultSharing('Private');
// Webservice Setup
$moduleInstance->initWebservice();
$targetpath = 'modules/' . $moduleInstance->name;
if (! is_file($targetpath)) {
mkdir($targetpath);
$templatepath = 'vtlib/ModuleDir/6.0.0';
$moduleFileContents = file_get_contents($templatepath . '/ModuleName.php');
$replacevars = array(
'ModuleName' => $moduleInstance->name,
'<modulename>' => strtolower($moduleInstance->name),
'<entityfieldlabel>' => $field1->label,
'<entitycolumn>' => $field1->column,
'<entityfieldname>' => $field1->name
);
foreach ($replacevars as $key => $value) {
$moduleFileContents = str_replace($key, $value, $moduleFileContents);
}
file_put_contents
($targetpath . '/' . $moduleInstance->name . '.php',$moduleFileContents);
}
if (! file_exists('languages/en_us/ModuleName.php')) {
$ModuleLanguageContents = file_get_contents
($templatepath . '/languages/en_us /ModuleName.php');
$replaceparams = array(
'Module Name' => $moduleInstance->name,
'Custom' => $moduleInstance->name,
'ModuleBlock' => $moduleInstance->name,
'ModuleFieldLabel Text' => $field1->label
);
foreach ($replaceparams as $key => $value) {
$ModuleLanguageContents = str_replace($key, $value, $ModuleLanguageContents);
}
$languagePath = 'languages/en_us';
file_put_contents
($languagePath . '/' . $moduleInstance->name . '.php',$ModuleLanguageContents);
}
}
Settings_MenuEditor_Module_Model::addModuleToApp
($moduleInstance->name, $moduleInstance->parent);
?>
```
how can i export & Import custom modules as Package using PHP Script (Vtlib Function) from my CRM vtiger 7, Please help me.
I was stuck on How to create a custom module in Vtiger using VTlib library. The code you shared is perfect for creating custom module in vtiger.
To Export your custom module in vtiger, you need to run the code below -
require_once('vtlib/Vtiger/Package.php');
require_once('vtlib/Vtiger/Module.php');
$package = new Vtiger_Package();
$package->export(
Vtiger_Module::getInstance('Payslip'),
'test/vtlib',
'Payslip-Export.zip',
true
);
Don't forget to change the module name

UPS Rate API not Fetching Values For Ground / 2nd Day / Overnight [duplicate]

I am using nopcommerce 3.5. I have added plugin of UPS of TransitInTime and Rate API. I want to get rates by calling UPS Rate API. I want all Rates in dropdown on page load.
So for the first I am using test application using webservices of RateWebReference and in which I get only one Rate but I want Rates for all shipping option.
Here is my code of RateWSClient.cs
RateService rate = new RateService();
RateRequest rateRequest = new RateRequest();
UPSSecurity upss = new UPSSecurity();
UPSSecurityServiceAccessToken upssSvcAccessToken = new UPSSecurityServiceAccessToken();
upssSvcAccessToken.AccessLicenseNumber = "CC....";
upss.ServiceAccessToken = upssSvcAccessToken;
UPSSecurityUsernameToken upssUsrNameToken = new UPSSecurityUsernameToken();
upssUsrNameToken.Username = "gi..";
upssUsrNameToken.Password = "Ch..";
upss.UsernameToken = upssUsrNameToken;
rate.UPSSecurityValue = upss;
RequestType request = new RequestType();
String[] requestOption = { "Rate" };
request.RequestOption = requestOption;
rateRequest.Request = request;
ShipmentType shipment = new ShipmentType();
ShipperType shipper = new ShipperType();
shipper.ShipperNumber = "A65V88";
RateWSSample.RateWebReference1.AddressType shipperAddress = new RateWSSample.RateWebReference1.AddressType();
String[] addressLine = { "", "", "" };
shipperAddress.AddressLine = addressLine;
shipperAddress.City = "";
shipperAddress.PostalCode = "30076";
shipperAddress.StateProvinceCode = "GA";
shipperAddress.CountryCode = "US";
shipperAddress.AddressLine = addressLine;
shipper.Address = shipperAddress;
shipment.Shipper = shipper;
ShipFromType shipFrom = new ShipFromType();
RateWSSample.RateWebReference1.AddressType shipFromAddress = new RateWSSample.RateWebReference1.AddressType();
shipFromAddress.AddressLine = addressLine;
shipFromAddress.City = "";
shipFromAddress.PostalCode = "30076";
shipFromAddress.StateProvinceCode = "GA";
shipFromAddress.CountryCode = "US";
shipFrom.Address = shipFromAddress;
shipment.ShipFrom = shipFrom;
ShipToType shipTo = new ShipToType();
ShipToAddressType shipToAddress = new ShipToAddressType();
String[] addressLine1 = { "", "", "" };
shipToAddress.AddressLine = addressLine1;
shipToAddress.City = "";
shipToAddress.PostalCode = "92262";
shipToAddress.StateProvinceCode = "";
shipToAddress.CountryCode = "US";
shipTo.Address = shipToAddress;
shipment.ShipTo = shipTo;
CodeDescriptionType service = new CodeDescriptionType();
//Below code uses dummy date for reference. Please udpate as required.
service.Code = "02";
shipment.Service = service;
PackageType package = new PackageType();
PackageWeightType packageWeight = new PackageWeightType();
packageWeight.Weight = "125";
CodeDescriptionType uom = new CodeDescriptionType();
uom.Code = "LBS";
uom.Description = "pounds";
packageWeight.UnitOfMeasurement = uom;
package.PackageWeight = packageWeight;
CodeDescriptionType packType = new CodeDescriptionType();
packType.Code = "02";
package.PackagingType = packType;
PackageType[] pkgArray = { package };
shipment.Package = pkgArray;
//Shipping Rate Chart
// ShipmentRatingOptionsType SRO = new ShipmentRatingOptionsType();
//SRO.RateChartIndicator = "";
//shipment.ShipmentRatingOptions= SRO;
//rateRequest.Shipment = shipment;
ShipmentRatingOptionsType SRO = new ShipmentRatingOptionsType();
SRO.NegotiatedRatesIndicator = "";
shipment.ShipmentRatingOptions = SRO;
rateRequest.Shipment = shipment;
System.Net.ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy();
Console.WriteLine(rateRequest);
RateResponse rateResponse = rate.ProcessRate(rateRequest);
Console.WriteLine("The transaction was a " + rateResponse.Response.ResponseStatus.Description);
Console.WriteLine("Total Shipment Charges " + rateResponse.RatedShipment[0].TotalCharges.MonetaryValue + rateResponse.RatedShipment[0].TotalCharges.CurrencyCode);
Console.ReadKey();
I have resolved this questions. So If you face this kind of problem don't forget to use
String[] requestOption = { "Shop" };
in place of
String[] requestOption = { "Rate" };
Then you will get rates for all shipping options.

Php soap data send error

When sending data to the SomeMethod() method, the 1 excess parameter returns as an error.
My Code:
$client = new SoapClient('site_url/?wsdl');
$client->soap_defencoding = 'UTF-8';
$loginparam = array('userName'=>'name','password'=>'pass','trace' => 1, 'exceptions' => 0);
$session = $client->OturumAc($loginparam);
$SoapIcHeader = new SoapHeader("http://sanayi.gov.tr","TokenId",$session->OturumAcResult);
$client->__setSoapHeaders($SoapIcHeader);
$OturumUzat = $client->OturumDogrulaVeUzat($session ->OturumAcResult);
$param["BosAgirligi"] = "20";
$param["CalismaBasinci"] = "5";
$param["DoluAgirligi"] = "1";
$param["SonMuayeneTarihi"] = "2017-08-01 10:19:04";
$param["SonMuayeneYapanFirmaMersisNo"] = "123456789";
$param["SuKapasitesi"] = "1";
$param["TestBasinci"] = "10";
$param["DolumBasinci"] = "15";
$param["EtKalinligi"] = "3";
$param["ImalatTarihi"] = "2017-08-01 10:19:04";
$param["SeriNo"] = "123";
$param["TescilEdenTesisId"] = "31fd684c-f97d-48c1-a7fb-60f30f536d8d";
$param["UreticiId"] = "31fd684c-f97d-48c1-a7fb-60f30f536d8d";
// $param["UygunlukIsareti"] = "1";
$date = date('d/m/Y');
$id ="2ad9a9a9-adb9-4fb8-8fae-01e84aa72343";
try
{
$sonuc = $client->TupTescil($id,$date,$param);
print_r($sonuc);
}
catch (Exception $e)
{
echo "Error ! ";
echo $e -> getMessage ();
}
Return Error
Error ! The formatter threw an exception while trying to deserialize the message: Error in deserializing body of request message for operation 'TupTescil'. End element 'Body' from namespace 'http://schemas.xmlsoap.org/soap/envelope/' expected. Found element 'param1' from namespace ''. Line 2, position 281.
This example works with C#
Guid tupKimligi = new Guid("07FAF194-4E80-4359-95D9-011CA1F5A1D4");
DateTime islemSaati = DateTime.Today;
TupTescilBilgisi tescilBilgileri = new TupTescilBilgisi()
{
BosAgirligi = 1,
CalismaBasinci = 1,
DoluAgirligi = 1,
SonMuayeneTarihi = DateTime.Today,
SonMuayeneYapanFirmaMersisNo = "123456789",
SuKapasitesi = 1,
TestBasinci = 1,
DolumBasinci = 1,
EtKalinligi = 1,
ImalatTarihi = DateTime.Today,
SeriNo = "123",
TescilEdenTesisId = tesisId,
UreticiId = ureticiId,
UygunlukIsareti = TupUygunlukIsareti.Pi
};
Tup tescilSonuc = tsc.TupTescil(tupKimligi, DateTime.Today, tescilBilgileri);
You can also look at the wsdl structure here
enter link description here
Thanks for your help

How do I delete a single sitelink using the newest version of Google AdWords API 201509 and leave the rest?

Google added a new way to add sitelink extensions.
https://developers.google.com/adwords/api/docs/guides/extension-settings#add_ad_extensions
I added a bunch of them, but how do you delete them? I had 3 sitelinks on each campaign. I was able to remove a sitelink from the campaigns, but it removed all sitelinks from the campaigns. They are still in the + Extension list, but not associated with any campaigns.
function deleteSitelinks($sitelinks) {
$user = $this->getUser();
$campaignExtensionSettingService = $user->GetService('CampaignExtensionSettingService', ADWORDS_VERSION);
// first remove the sitelinks from the campaigns
$operations = array();
foreach ($sitelinks as $sitelink) {
$sfi = new SitelinkFeedItem();
$sfi->feedItemId = $sitelink->google_feed_item_id;
$campaignExtensionSetting = new CampaignExtensionSetting();
$campaignExtensionSetting->campaignId = $sitelink->campaign->google_id;
$campaignExtensionSetting->extensionType = 'SITELINK';
$extensionSetting = new ExtensionSetting();
$extensionSetting->extensions = array($sfi);
$campaignExtensionSetting->extensionSetting = $extensionSetting;
$operation = new CampaignExtensionSettingOperation();
$operation->operator = 'REMOVE';
$operation->operand = $campaignExtensionSetting;
$operations[] = $operation;
}
$result = $campaignExtensionSettingService->mutate($operations);
// now remove the sitelinks themselves
$feedItemService = $user->GetService('FeedItemService', ADWORDS_VERSION);
$operations = array();
foreach ($sitelinks as $sitelink) {
$sfi = new SitelinkFeedItem();
$sfi->feedId = $sitelink->google_feed_id;
$sfi->feedItemId = $sitelink->google_feed_item_id;
$operation = new FeedItemOperation();
$operation->operator = 'REMOVE';
$operation->operand = $sfi;
$operations[] = $operation;
}
$result = $feedItemService->mutate($operations);
return $result->value;
}
Ok I 'fixed' it by re-adding all the sitelinks that belong to that campaign immediately after deleting the target sitelink. I swear, this is the most retarded part of this API.
...
$result = $campaignExtensionSettingService->mutate($operations);
// now re-add the other sitelinks. the google API is removing/disassociating ALL sitelinks for whatever reason
$operations = array();
foreach ($sitelinks as $sitelink) {
$campaignSitelinks = array();
$siblings = Sitelink::find()->where(['campaign_id' => $sitelink->campaign_id])->andWhere(['not', ['id' => $sitelink->id]])->all();
foreach ($siblings as $sibling) {
$sfi = new SitelinkFeedItem();
$sfi->feedItemId = $sibling->google_feed_item_id;
$campaignSitelinks[] = $sfi;
}
$campaignExtensionSetting = new CampaignExtensionSetting();
$campaignExtensionSetting->campaignId = $sitelink->campaign->google_id;
$campaignExtensionSetting->extensionType = 'SITELINK';
$campaignExtensionSetting->extensionSetting = new ExtensionSetting();
$campaignExtensionSetting->extensionSetting->extensions = $campaignSitelinks;
// Create operation.
$operation = new CampaignExtensionSettingOperation();
$operation->operator = 'SET';
$operation->operand = $campaignExtensionSetting;
$operations[] = $operation;
}
$result = $campaignExtensionSettingService->mutate($operations);
// now remove all the sitelinks themselves
$feedItemService = $user->GetService('FeedItemService', ADWORDS_VERSION);
...

Edit a custom field in netsuite using PHP toolkit

I see a bunch of examples of how to add a new order however I'm trying to update a custom field of an existing order using the PHP toolkit. Could anyone start me out with this? I'm not sure where to start.
This is the code to add a new order
<?php
require_once '../PHPToolkit/NetSuiteService.php';
$service = new NetSuiteService();
$svr = new getSelectValueRequest();
$svr->fieldDescription = new GetSelectValueFieldDescription();
$svr->pageIndex = 1;
$priceFields = array(
'recordType' => RecordType::salesOrder,
'sublist' => 'itemList',
'field' => 'price',
'filterByValueList' => array(
'filterBy' => array(
array(
'field' => 'item',
'sublist' => 'itemList',
'internalId' => '458',
)
)
)
);
if ($id != null) {
echo "Custom price level id is " . $id . "\n";
} else {
echo "Custom price level not found " . $id . "\n";
}
$so = new SalesOrder();
$so->entity = new RecordRef();
$so->entity->internalId = 21;
$so->itemList = new SalesOrderItemList();
$soi = new SalesOrderItem();
$soi->item = new RecordRef();
$soi->item->internalId = 104;
$soi->quantity = 3;
$soi->price = new RecordRef();
$soi->price->internalId = $id;
$soi->amount = 55.3;
$so->itemList->item = array($soi);
$request = new AddRequest();
$request->record = $so;
$addResponse = $service->add($request);
if (!$addResponse->writeResponse->status->isSuccess) {
echo "ADD ERROR";
exit();
} else {
echo "ADD SUCCESS, id " . $addResponse->writeResponse->baseRef->internalId;
}
?>
You'll need a customFieldList object, which is an array of custom fields. There are different objects for the different data types of custom fields - below would be a string custom field. I utf8_encode to deal with weird characters that you normally don't see.
$customFieldList = new CustomFieldList();
$customField = new StringCustomFieldRef();
$customField->value = utf8_encode("contents of string custom field");
$customField->internalId = 'custbody_whatever_your_field_is';
$customFieldList->customField[] = $customField;
$so->customFieldList = $customFieldList;

Categories