Cannot retrieve Stripe data on success page - php

I have followed the Stripe documentation, trying to get the e-mail address of a customer but it fails with the following error:
PHP Fatal error: Uncaught exception 'Stripe\Exception\InvalidArgumentException'
with message 'The resource ID cannot be null or whitespace.' in /home/phuketto/public_html/stripe-php/lib/Service/AbstractService.php:99
Stack trace:
#0 /home/phuketto/public_html/stripe-php/lib/Service/Checkout/SessionService.php(90): Stripe\Service\AbstractService->buildPath('/v1/checkout/se...', NULL)
#1 /home/phuketto/public_html/ipnstripe.php(9): Stripe\Service\Checkout\SessionService->retrieve(NULL)
#2 {main}
thrown in /home/phuketto/public_html/stripe-php/lib/Service/AbstractService.php on line 99
In my create session script I am using:
'success_url' => 'https://www.example.com/ipnstripe.php?session_id={CHECKOUT_SESSION_ID}',
In my success_url I am trying to get the customer e-mail to be used further down the script but something goes wrong and the rest of the script is not executed:
require_once('./stripe-php/init.php');
$stripe = new \Stripe\StripeClient('sk_live_xxxxx');
$session = $stripe->checkout->sessions->retrieve($_GET['session_id']);
$customer = $stripe->customers->retrieve($session->customer);
$payeremail = $customer->email;

Related

Fatal error when adding product to cart in PrestaShop

I wont add product to cart in prestashop 1.7 but When i execute code below, i return Fatal error but in other card in browser i refresh cart and have the product, attribute and quantity what adding in code. So whats the problem with code, work well but return fatal error
require_once('config/config.inc.php');
require_once('classes/Cart.php');
function addProductToCart($id, $productAttributeID)
{
$context = Context::getContext();
$id_cart = $context->cookie->__get('id_cart');
$cart = new Cart($id_cart);
$cart->updateQty(1, (int)$id, (int)$productAttributeID);
$cart->update();
Tools::redirect('order');
}
addProductToCart(41, 518);
Fatal error: Uncaught PrestaShopException: Błąd krytyczny in
/home/symon/php/39/pet-food-shop/classes/Tools.php:1109 Stack trace:
0 /home/symon/php/39/pet-food-shop/classes/Product.php(3153): ToolsCore::displayError() #1
/home/symon/php/39/pet-food-shop/classes/Product.php(4741):
ProductCore::getPriceStatic(41, false, 518, 6, NULL, false, true, 1)
2 /home/symon/php/39/pet-food-shop/classes/Cart.php(811): ProductCore::getProductProperties(1, Array) #3
/home/symon/php/39/pet-food-shop/classes/Cart.php(1456):
CartCore->getProducts(true) #4
/home/symon/php/39/pet-food-shop/addProductToCart.php(17):
CartCore->updateQty(1, 41, 518) #5
/home/symon/php/39/pet-food-shop/addProductToCart.php(34):
addProductToCart(41, 518) #6 {main} thrown in
/home/symon/php/39/pet-food-shop/classes/Tools.php on line 1109
Your script is not a part of prestashop (module or override), so prestashop context does not work properly. You should include init.php also.
Then prestashop context works with frontend context, then product price works fine.
<?php
require_once 'config/config.inc.php';
require_once 'init.php';

Why am I getting an invalid parameter error when updating a customer attribute in Shopware?

I am trying to update customer attribute in Shopware but am getting an error:
$builder = $this->container->get('models')->createQueryBuilder()
->update(\Shopware\Models\Customer\Customer::class, 'customer')
->set('customer.active',0)
->where('customer.email= :email')
->setParameter('email ' ,'xyz#test.com');
$builder->getQuery()->execute();
Fatal error: Uncaught Doctrine\ORM\Query\QueryException: Invalid
parameter: token email is not defined in the query. in
/var/www/html/shopware/vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php:134
Stack trace: #0
/var/www/html/shopware/vendor/doctrine/orm/lib/Doctrine/ORM/Query.php(362):
Doctrine\ORM\Query\QueryException::unknownParameter('email ') #1
/var/www/html/shopware/vendor/doctrine/orm/lib/Doctrine/ORM/Query.php(319):
Doctrine\ORM\Query->processParameterMappings(Array) #2
/var/www/html/shopware/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php(962):
Doctrine\ORM\Query->_doExecute() #3
/var/www/html/shopware/vendor/doctrine/orm/lib/Doctrine/ORM/AbstractQuery.php(917):
Doctrine\ORM\AbstractQuery->executeIgnoreQueryCache(NULL, NULL) #4
/var/www/html/shopware/custom/plugins/CustomPlugin/Controllers/Frontend/CustomPlugin.php(17):
Doctrine\ORM\AbstractQuery->execute() #5
/var/www/html/shopware/engine/Library/Enlight/Controller/Action.php(193):
Shopware_Controllers_Frontend_CustomPlugin->indexAction() # in
/var/www/html/shopware/vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php
on line 134
How can I fix this?
Try to use a where statement like this;
->where('customer.email = ?1')->setParameter(1 ,'xyz#test.com');

Fatal error: Uncaught ArgumentCountError

I get this error. I created a button to update the table. When I click the button, I get an error. How to fix it?
Fatal error: Uncaught ArgumentCountError: Too few arguments to function personel::update_form(), 0 passed in C:\xampp\htdocs\warehouse\panel\system\core\CodeIgniter.php on line 360 and exactly 1 expected in C:\xampp\htdocs\warehouse\panel\application\controllers\personel.php:57 Stack trace: #0 C:\xampp\htdocs\warehouse\panel\system\core\CodeIgniter.php(360): personel->update_form() #1 C:\xampp\htdocs\warehouse\panel\index.php(202): require_once('C:\xampp\htdocs...') #2 {main} thrown in C:\xampp\htdocs\warehouse\panel\application\controllers\personel.php on line 57
Fİle Name: personel.php Controller
MY CODES
public function update_form($id){
$where = array( "id" => $id);
$personel = $this->Personel_model->get($where);
$viewData["personel"] = $personel;
$this->load->view("personel_edit");
}
MY BUTTON CODES
Update
You must pass an ID with the button to function in the controller like this.
Update

Creating item with podio api for PHP

I am trying to Create an item in the podio API for PHP. Here is my code:
Podio::setup($client_id, $client_secret);
Podio::authenticate_with_app($app_id, $app_token);
// Create a field collection with some fields.
// Be sure to use the external_ids of your specific fields
$fields = new PodioItemFieldCollection(array(
new PodioTextItemField(array("external_id"=>"first", "values"=> "Han")),
new PodioTextItemField(array("external_id"=>"last", "values"=> "Solo"))
));
// Create the item object with fields
// Be sure to add an app or podio-php won't know where to create the item
$item = new PodioItem(array(
'app' => new PodioApp($app_id), // Attach to app with app_id=$app_id
'fields' => $fields
));
// Save the new item
$item->save();
But I get error
Notice: Undefined index: request in C:\xampp\htdocs\PodioAPITesting\vendor\podio\podio-php\lib\PodioError.php on line 11
Fatal error: Uncaught PodioMissingRelationshipError: "Item is missing
relationship to app" Request URL: Stack Trace: #0 C:\xampp\htdocs\PodioAPITesting\testPodioAPI.php(66): PodioItem->save() #1 {main} thrown in C:\xampp\htdocs\PodioAPITesting\vendor\podio\podio-php\models\PodioItem.php on line 75
Am I creating the item properly? Could it be because this app has more that two fields? ( I want to set 'first' and 'last', and leave the other fields blank for now)
The problem was that my $app_id was a string when it should have been an integer.

Google+ API CommentActivity return 400 Error

I'm having no luck calling the Google+ API for pushing a CommentActivity moment.
I have been able to push an AddActivity successfully as well as a DiscoverActivity.
I read somewhere on the internet whilst searching for a solution that the 400 HTTP Status represents that my user credentials are invalid, but I have been able to post AddActivity & DiscoverActivity after trying CommentActivity and I have tried disconnecting and reconnecting my account and linking the required credentials to no avail.
Here's my code to generate the moment, I believe this is the error, and it's probably something to do with the use of a Target and a Result in this moment type (Neither DiscoverActivity nor AddActivity have a Result field). In particular, the Target's and Result's URLs are the same but the Result's has an appended anchor. The documentation implies that this should work fine, however.
$moment = new Google_Moment();
$moment->setType("http://schemas.google.com/CommentActivity");
$target = new Google_ItemScope();
$target->setUrl(get_permalink($comment->comment_post_id));
$target->setType("http://schema.org/Article");
$moment->setTarget($target);
$result = new Google_ItemScope();
$result->setId("comment-".$comment_id);
$result->setType("http://schema.org/Comment");
$result->setUrl(get_comment_link($comment_id));
$result->setText($comment->comment_content);
$moment->setResult($result);
Soci_Base::getSocial("google")->getUser($user)->GPlus->moments->insert('me', 'vault', $moment);
GPlus is a reference to a Google_PlusService object.
Here's my exception I receive with stack trace (Pointless parts of the files are omitted, hooks.php and plugin.php are not the Google+ API)
Fatal error: Uncaught exception 'Google_ServiceException' with message 'Error calling POST https://www.googleapis.com/plus/v1/people/me/moments/vault?key=AIzaSyBa27u5PtBgFHO4SY_Fq9_0sO39pFWrRzE: (400) Invalid Value' in /~/src/io/Google_REST.php:66 Stack trace:
#0 /~/G+/src/io/Google_REST.php(36): Google_REST::decodeHttpResponse(Object(Google_HttpRequest))
#1 /~/G+/src/service/Google_ServiceResource.php(186): Google_REST::execute(Object(Google_HttpRequest))
#2 /~/G+/src/contrib/Google_PlusService.php(167): Google_ServiceResource->__call('insert', Array)
#3 /~/hooks.php(54): Google_MomentsServiceResource->insert('me', 'vault', Object(Google_Moment))
#4 /~/plugin.php(406): soci_comment('108040')
#5 /~ in /~/lib/G+/src/io/Google_REST.php on line 66
I think that's all of the info I have on the matter - I have no idea to get the exact HTTP request the script makes.
Thank you in advance for any and all help and for even having a look ^_^
Here's the code for the whole login sequence:
Soci_Google::addActionRequirement('http://schemas.google.com/AddActivity');
Soci_Google::addActionRequirement('http://schemas.google.com/CommentActivity');
Soci_Google::addActionRequirement('http://schemas.google.com/CreateActivity');
Soci_Google::addActionRequirement('http://schemas.google.com/DiscoverActivity');
Soci_Google::addActionRequirement:
public static function addActionRequirement($url) {
self::$activities[] = $url;
}
self::$token is just a reference to a string
$ret = new Soci_Google();
self::$users[$id] = $ret;
$ret->setToken(self::$meta->getMeta($user, self::$token));
return $ret;
Soci_Google __construct():
public function __construct() {
$this->googleObj = new Google_Client();
$this->googleObj->setApplicationName(self::$appName);
$this->googleObj->setClientId(self::$clientID);
$this->googleObj->setClientSecret(self::$clientSecret);
$this->googleObj->setRedirectUri(self::$redirectURI);
$this->googleObj->setDeveloperKey(self::$devKey);
$this->GPlus = new Google_PlusService($this->googleObj);
$this->googleObj->setRequestVisibleActions(self::$activities);
}
Soci_Goolge setToken
$this->googleObj->setAccessToken($googleUsrToken);

Categories