Using Stripe and Mailgun in Custom Webhook hosted on WordPress site - php

Hello Stackoverflowers!
I have been in a really big bind trying to solve this configuration/implementation of a webhook that utilizes both the Stripe PHP library and the Mailgun API. My intention is to send an email (with Mailgun) whenever one of my Stripe customers performs a certain action which has been recorded as an event in my Stripe endpoint. I have been trying to follow the guidelines of this documentation https://stripe.com/docs/recipes/sending-emails-for-failed-payments but unfortunately I think I am missing something in my understanding of how to make this work. I have a SiteGround hosted WordPress site which I am trying to host my webhook.php file and Stripe PHP library on. I uploaded the entire Stripe PHP library (in a folder named "stripe-php-master") to my "/wp-includes/" directory. In the webhook.php file I changed the boilerplate code in the documentation (https://stripe.com/docs/recipes/sending-emails-for-failed-payments) from
// If you're using Composer, use Composer's autoload
require_once('vendor/autoload.php');
to
$file = dirname(__FILE__) . '/init.php';
require_once($file);
because I am not sure how to utilize "Composer" in this scenario within the confines/context of of a SiteGround hosted WordPress site, so I figured this may be a suitable approach (according to https://packagist.org/packages/stripe/stripe-php) please correct me if I am wrong! When I try to visit the URL of my webhook.php file at https://mysitename.com/wp-includes/stripe-php-master/webhook.php I receive this error "Fatal error: Uncaught Error: Class 'Mailgun\Mailgun' not found in /home/mysitef3/public_html/wp-includes/stripe-php-master/webhook.php:16 Stack trace: #0 {main} thrown in /home/mysitef3/public_html/wp-includes/stripe-php-master/webhook.php on line 16". Could any of you please help me figure out what I am doing wrong here please and thank you!!!

Related

Issue with the implementation of the simplesamlphp library into my web application

I tried to implement the simplesamlphp library into my web application. But when I call the requireAuth() function I get a PHP fatal error message. Uncaught Exception: Loader: Illegal character in filename.....
It seems like he can't resolve the Class SimpleSAML\Module\saml\Auth\Source\SP
But I don't know why.
Does anyone have a idea how to fix this?
I already deleted the whole simplesamlphp installation and reinstalled it.
I use the following code:
require 'var/www/simplesamlphp/lib/_autoload.php';
$lAuthSrc = new \SimpleSAML\Auth\Simple('default-sp');
if (!$lAuthSrc->isAuthenticated()) {
$lAuthSrc->requireAuth();
}
$lAttributes = $lAuthSrc -> getAttributes();
foreach($lAttributes as $lAttribute) {
print_r($lAttribute);
}
Some additional informations:
The configured authentication source test works fine. If I login via the configured authentication source, everything works fine and I don't get any error messages (the requireAuth() function don't get called in this case).
I use the latest version of simplesamlphp v.1.18.3
If you need any more information, please let me know.
Honestly it looks like your path is messed up on the require... are you sure you should be using:
require 'var/www/simplesamlphp/lib/_autoload.php';
and not
require '/var/www/simplesamlphp/lib/_autoload.php';
Do you really have a 'var/www' subdirectory relative to the location of the script? That looks wrong to me. If you include that first / before var it makes that path absolute to the typical install location for SSP.
Thank you all for your help. I discovered this morning the issue. The issue was the autoloader which I use for my own application. I registered the application autoloader in another file which gets executed before the code you see above. And simplesamlphp uses some conditions like:
if (!class_exists($className))
And beacuse I registered my application autoloader before the function class_exists checked if the class exists in my application. In my application I don't use namespaces and this was the issue.
To fix this issue, I unregistered my application autoloader before using the simplesamlphp code and registered the autoloader again after the simplesamlphp code.
I hope this will save some of you headaches.

Failed to connect to Recurly Could not resolve host

I'm currently developing a plugin for wordpress that uses recurly for subscription. I already uploaded it to our site and resume coding there. I'm already done with the checkout page and was in the middle of developing the accounts page when I run into an error:
Fatal error: Uncaught exception 'Recurly_ConnectionError' with message 'Failed to connect to Recurly (Could not resolve host: xx-my-subdomain-xx.recurly.com)
xx-my-subdomain-xx is the placeholder for the subdomain
I already increased the connection timeout to 30 but my effort was futile. I tried testing it in my localhost and found out that it was working. I think i has something to do with the cURL but I can't point out what's causing the problem.
Any help would be appreciated.
Recurly_Client::$subdomain = 'your-subdomain-name'; // i.e devapp,myapp..etc
You don't need to write whole subdomain URL you just need to pass your subdomain name which is found in configuration -> site setting (Only the name of the subdomain).
I hope this will solve your issue as I also got the same error after this change its working fine for me.
Provide your subdomain as follows
Recurly_Client::$subdomain = "Your RECURLY_SUBDOMAIN";
Then add your API key and certificate path as follows
Recurly_Client::$apiKey = "Your RECURLY_API_KEY";
Recurly_Client::$CACertPath = "Your RECURLY_OPENSSL_CertificatePATH";
I hope this will work for you.

authenticate in wordpress Api using Basic Auth plugin not working

I am using wp-api-v2 and Basic Auth plugin to add post to my wordpress. it work nice in my local wamp server but wen i upload my code on online server my credential not working and prevent me to aading new post by this error:
"Sorry, you are not allowed to create new posts."
I add my credential by putting this key/value pair to my request header:
key=>"Authorization",
value=>"Basic ".base64_encode($username.":".$password)
is there any Possibility for misconfiguration or problem in my server?
I finally found solution in this link and resolve my problem.

Magento Fatal Error: Class 'Zend_Log' not found

With a module I added an custom customer attribute.
When a client is logged in and want to edit their account information or want to change their password on frontend the following error comes up:
Fatal error: Class 'Zend_Log' not found in /app/code/community/Amar/Profile/Model/Customer/Attribute.php on line 49
I build this website local and uploaded it to the server.
On the local environment this error is not showing up, this error only showing up on the server.
I think it has to do something with file permissions.
Does anyone have a solution for this?
the problem has been solved.
On the live server there was another PHP version which was not compatible with the extension.
For me a function loadByCode() causes the issue, I have renamed it and it is working fine. We should not use generic method names in custom modules.
The function is in \app\code\community\Amar\Profile\Model\Customer\Attribute.php file.

(403) Access Not Configured when adding event to calendar

Today I started to get this error upon adding new events to calendar:
Fatal error: Uncaught exception 'apiServiceException' with message
'Error calling POST https://www.googleapis.com/calendar/v3/
calendars/[cal-id]#group.calendar.google.com/events?alt=json&key=[dev-key]:
(403) Access Not Configured' in /[...]/src/io/apiREST.php:86
Stack trace: #0 /[...]/src/io/apiREST.php(56): apiREST::decodeHttpResponse(Object(apiHttpRequest))
#1 /[...]/src/service/apiServiceResource.php(148): apiREST::execute(Object(apiServiceRequest)) #2 /[...]/src/contrib/apiCalendarService.php(472):
apiServiceResource->__call('insert', Array) #3 /[...]/index.php(160): EventsServiceResource->insert('[cal-id-part]...',
Object(Ev in /[...]/src/io/apiREST.php on line 86
It worked perfectly till now and I didn't change anything in code.
I had a similar problem accessing Google Analytics data with PHP. I fixed it by making sure the Analytics service was turned on for my project in my API console: https://code.google.com/apis/console/.
You may have to turn on the calendar service. See the link below for further explanation when someone had an issue with the translation service:
Translation api has stopped working
Don't know if this will help someone.
I had the same error and I had tried everything. Then I removed "developer_key" from config.php and it worked. Please note I was using Service Account https://developers.google.com/accounts/docs/OAuth2ServiceAccount
Well, they released new version and that what apparently caused errors. Got the newest version now and it works great once again.
Don't know if this will help someone, either.
It may also help to go to the respective calendar-settings page in your Google Account, edit something trivial and explicitly save again, (or re-save once more to set back to the old settings). Sometimes the google servers are a bit hesitant to accept any new settings, especially the "Sharing " settings. Check which of your service accounts have permission levels "can edit" , or "is owner" .

Categories