okay, this is my first time to ask a question here so please give grace if it's not very clear. Anyway, I have this code in Laravel Billing.php.
Is this correct? Whenever a new customer is created, it doesn't have it's user email address but instead this unknown#domain.com was assigned to the user.
This was set by my previous developer. But ever since we hired him for just simple fix, we've had numerous issues with the site.
$stripeCustomer = StripeCustomer::create([
'email' => $currentCustomer->email ? $currentCustomer->email : 'unknown#domain.com',
'description' => $company->name,
'metadata' => [
'company_id' => $company->id,
'card_owner_email' => $currentCustomer->email ? $currentCustomer->email : false,
'company_name' => $company->name,
],
]);
You can remove customer email from the StripeCustomer when creating since stripe API said that email field of customer is optional. Here is the reference link
Here what you should fix:
$customerObject = [
'description' => $company->name,
'metadata' => [
'company_id' => $company->id,
'company_name' => $company->name,
],
];
if ($currentCustomer->email) {
$customerMetadata["metadata"]["card_owner_email"] = $currentCustomer->email;
$customerObject["email"] = $currentCustomer->email;
}
$stripeCustomer = StripeCustomer::create($customerObject);
Related
I'm using the MadelineProto project for php to interact with Telegram API.
Maybe this error has nothing to do with MadelineProto... anyway, I successfully created a supergroup but any other method I call after, gives me a CHAT_WRITE_FORBIDDEN error.
Can't find anything in Telegram Documentation about why I'm getting this error and how to solve.
This is my code:
$MadelineProto = new MadelineProtoAPI('session.madeline', $settings);
$MadelineProto->async(false);
$MadelineProto->start();
// successfully create the group
$updates = $MadelineProto->channels->createChannel([
'megagroup' => true,
'title' => 'Test group',
'about' => 'Test group description',
]);
foreach($updates as $update) {
// try to invite other users --> CHAT_WRITE_FORBIDDEN
$updates = $MadelineProto->channels->inviteToChannel([
'channel' => $update,
'users' => ['########']
]);
// try to change admin rights --> CHAT_WRITE_FORBIDDEN
$updates = $MadelineProto->channels->editAdmin([
'channel' => $update,
'user_id' => '########',
'admin_rights' => [
'_' => 'chatAdminRights',
'change_info' => true,
'post_messages' => true,
'edit_messages' => true,
'delete_messages' => true,
'ban_users' => true,
'invite_users' => true,
'pin_messages' => true,
'add_admins' => true,
'anonymous' => true,
],
'rank' => ''
]);
}
What I'm doing wrong?
Thanks
It seems that the problem was due to the value passed to the 'channel' property. Instead of passing the $update variable, I passed directly the channel id in the form "channel#1234567890" and finally got a correct answer from Telegram.
Good Afternoon,
I'm trying to create a Laravel factory where 2 of the 'columns' have the same values every time its called and the rest of the factory can be random.
For instance, I have the following columns in my DB
name
email
phone_number
status_message
status_code
I currently have my factory as follows;
$factory->define(Brand::class, function (Faker $faker) {
return [
'name' => $faker->unique()->company,
'email' => $faker->companyEmail,
'phone_number' => $faker->phoneNumber
];
});
This part works perfectly, as it should, the problem is that each specific status message comes with an individual status code. Is there a way I could add an array of status messages with a status code and have the factory pick a set at random for that record?
The status code / messages are listed below in array format;
[
'3e2s' => 'tangled web',
'29d7' => 'get certified',
'2r5g' => 'art of war',
]
I hope this makes sense. any help would be greatly appreciated.
as i can understand u need to pick random from this array u mentioned in above
$factory->define(Brand::class, function (Faker $faker) {
$data = [
'3e2s' => 'tangled web',
'29d7' => 'get certified',
'2r5g' => 'art of war',
];
$statusCode = array_rand($data);
$statusMessage = $data[$statusCode];
return [
'name' => $faker->unique()->company,
'email' => $faker->companyEmail,
'phone_number' => $faker->phoneNumber,
'status_message' => $statusMessage,
'status_code' => $statusCode,
];
});
HI I am using braintree(braintree/braintree_php": "4.5.0) . I have implemented the 3dsecure in the web.It working fine. I need to auto renew the payment with paymentMethodToken. Below code i have used for auto renewal.
$trans = [
'amount' => "14.63",
'merchantAccountId' => "Vo**ID",
'paymentMethodToken' =>"token",
'transactionSource' => "recurring",
'customFields' => [
'client_id' => "id",
'service_id' => "id",
'invoice_id' => "id",
'action' => "autorenew",
'slots' => "15",
],
'options' => [
'submitForSettlement' => true,
'storeInVaultOnSuccess' => true,
'paypal' => [
'description' =>"Renew server",
]
]
];
$transaction = $gateway->transaction()->sale($trans);
When run this code i get below error
Authorization in Util.php line 59:
The above code is working when the user enter the credit card information to pay.This only gives error when i do payment with paymentMethodToken to auto renew the payments.Any help?
reference : https://developers.braintreepayments.com/guides/paypal/server-side/php
As per I understood your requirement. You need to do auto payment.
For that, Braintree provide the best way to do this called Subscription.
Let me know, If you need any more help.
I need help. I have a two tables business_departments and companies with association type hasMany.
I need to modify companies list consisting in the department. Code was generated via bake, after that I modified it.
Controller.
$businessDepartment = $this->BusinessDepartments->get($id, [
'contain' => ['Companies']
]);
$companies = $this->BusinessDepartments->Companies->find('list')->where([
'Companies.active' => true,
'Companies.type IS NOT' => 'service',
'OR' => [
'business_department_id IS NULL',
'business_department_id' => $id
]
])->distinct('Companies.id');
if ($this->request->is(['patch', 'post', 'put'])) {
debug($this->request->getData());
$businessDepartment = $this->BusinessDepartments->patchEntity($businessDepartment, $this->request->getData(), ['associated' => ['Companies']]);
debug($businessDepartment);
if ($this->BusinessDepartments->save($businessDepartment)) {
$this->Flash->success(__('The business department has been saved.'));
return $this->redirect(['action' => 'index']);
}
$this->Flash->error(__('The business department could not be saved. Please, try again.'));
}
$this->set(compact('businessDepartment', 'companies'));
Entity.
protected $_accessible = [
'name' => true,
'companies' => true
];
Table
$this->hasMany('Companies', [
'foreignKey' => 'business_department_id',
// Tried it
/*'dependent' => true,
'cascadeCallbacks' => true,
'saveStrategy' => 'replace'*/
]);
template.
echo $this->Form->control('companies._ids', ['options' => $companies, 'multiple' => true, 'class' => 'multiple-find']);
First save with added companies is success, but when I tried to modify companies list (And if try to save without changes) I get error.
Can I save via *._ids or I need to make a custom code for it?
Below debug($this->request->getData())
[
'name' => 'Office',
'companies' => [
'_ids' => [
(int) 0 => '21',
(int) 1 => '29'
]
]
]
But after patchEntity, instead of searching for companies and changing the business_department_id fields in them, patchEntity tries to create new companies and displays an error. Below is a fragment of screenshot.
debug($businessDepartment) and screenshot page
Thank you. I hope for quick answer.
Maybe someone will come in handy!
you have validation errors in your company related data, thats why you
cant save it, if you want to just use _ids as save try clearing
companies field in your $businessDepartment i.e.
$businessDepartment->unsetProperty('companies');
before patchEntity
Graziel
I use Laravel 5 to develop an app and I use Mailchimp for adding subscription. I use Mailchimp v.3 . I can make a list using this code:
$mailchimp = new Mailchimp(xxxxxxxxxxxx-xx);
$contact = [
'company' => $request['campaign'],
'address1' => $request['address'],
'city' => $request['city'],
'state' => $candidate->userCandidate->state,
'zip' => $request['zip'],
'country' => $request['country'],
'phone' => $request['phone'],
];
$campaign_details = [
'from_name' => $request['from_name'],
'from_email' => $request['from_email'],
'subject' => $request['remind_text'],
'language' => 'English'
];
$data = [
'name' => Auth::user()->name . ' Campaign',
'contact' => $contact,
'permission_reminder' => $request['remind_text'],
'campaign_defaults' => $campaign_details,
'notify_on_subscribe' => $request['from_email'],
'notify_on_unsubscribe' => $request['from_email'],
'email_type_option' => false,
'visibility' => $request['visibility'],
];
$list = $mailchimp->post('lists', $data);
I use this library drewm/mailchimp. My code on subscribing is this:
$mailchimp = new Mailchimp($api_key);
$subscriber = [
'email_type' => 'html',
'email_address' => $email,
'language' => 'English',
'status' => 'subscribed',
'merge_fields' => ['zip' => $zip]
];
$result = $mailchimp->post('lists/' . $list_id . '/members', $subscriber);
And I can successfully subscribe it. This is my question how to verify an email first before will be recorded on mailchimp list to avoid spammer. I read on mailchimp that they have DOUBLE OPT-IN method but it is only available if you use their form.
My solution is to email first on subscriber and create a link for verifying and this solution can take time. Is there another solution on this? Does Mailchimp have method to acquire this?
I don't have any idea on Mailchimp API. However, you just have to set up an email validation flow first. In this way, all emails will not be considered as "spam" in your records. Then you're free to do any email tasks without worrying if it is valid or not.
The quick answer to your question is to set the status to "pending" instead of "subscribed", but you should check out MailChimp's docs on managing subscribers with API v3 for more details.
MailboxValidator does have an easy import feature to grab your list from MailChimp for email validation purposes. Then it automatically updates your MailChimp list once the validation process is done.
https://www.mailboxvalidator.com/resources/articles/how-to-import-email-list-from-mailchimp/