omnipay/paypal and notifyUrl issue - codeigniter

Dear stackoverflow community,
Recently PayPal contacted me to upgrade my 'old-style' CodeIgniter e-commerce cart (an old standard paypal gateway with a simple form to related paypal endpoint) to a solution with access token and client_id + secret. I used omnipay-paypal, following a guide like this:
https://artisansweb.net/paypal-payment-gateway-integration-in-php-using-paypal-rest-api/
And everything seems working fine, but with old standard cart I used a notifyUrl to send payment post data to a controller that made something like this:
foreach ($_POST as $key => $value) {
$request .= '&' . $key . '=' . urlencode(html_entity_decode($value, ENT_QUOTES, 'UTF-8'));
}
$curl = curl_init('https://www.paypal.com/cgi-bin/webscr');
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $request);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_TIMEOUT, 120);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($curl);
If that $response is VERIFIED, I enable related order for delivery (paid).
Issue is that notifyUrl isn't triggered at all with Omnipay and this avoids to fit the shoe.
I tried to setup notifyUrl parameter on purchase, completePurchase method, but nothing to do: no call is sent after payment confirmation and no payment data in the related $_POST object.
Someone could give me some hint or help?
I tried to force the notifyUrl in any possible way, but after transaction is complete and payment confirmed, the notifyUrl is not receiving the expected data with post.

Related

Is it possible to track telegram channel members by "createChatInviteLink" they used to join?

Is it possible to fetch the chatinvitelink that was used to join a private channel?
scenario: I am generating unique joining link for each new user, goal is to have each individual user join through a unique link , so I can track them at later stage.
Now as a first step to Track each user , I am trying to fetch the invite link that was used by each individual user to join the group , But I didnt find any reference in the Telegram bot api documentation , or on the internet. Is it possible to get the invite link used by the user to join the channel, using telegram bot api?
I want to track who joined using created invite link.
Here is the code I am using to generate unique invite link:
function createChatInviteLink($apiToken, $chat_id){
$date = new Date<Time();
$date->modify('+<12 month');
$data = array(
'chat_id' => $chat_id,
'member_limit' => 1,
'expire_date' => $date->getTimestamp()
);
$url = "https://api.telegram.org/bot$apiToken/createChatInviteLink";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, count($data));
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}

facebook share not fetching og:image

I have added FB share dialog to share images on facebook. I have tried all possible solutions but its still not fetching image. After sometime for some posts it works but not most of the times.
I have forcefully scraped the urls using php curl
$current_url = get_permalink();
$curl = 'https://graph.facebook.com/';
$return = getCurlRequest($curl,'id='http://viralsyndicator.com/best-spring-fishing-lures-of-2018-bass-pro-shops-challenge/'&scrape=true&access_token=token');
function getCurlRequest($url,$postdata=""){
//echo $url;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:','Content-Type: application/json'));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$postdata);
curl_setopt($ch, CURLOPT_TIMEOUT_MS, 10000);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
//echo '<pre>';print_r($response);
curl_close($ch);
if ($response == false){ return false;}
return $response;
}
This page always has og:image meta tag but still it does not work. When I go to fb debugger tool and I debug it, first time it says og:image should be provided, scraping it after 2-3 times it starts working.
I have tried og:image:width properties as well.
I am using wordpress plugin to share, I have used FB.ui as well manually and it worked for sharing but I am also using FB comment plugin and when I am commenting and checking checkbox to post on fb as well, its not publishing image and I don't know how to use FB comment plugin manually similarly share to fetch correct image instead of logo.
FB.ui({
method: 'share',
href: '<?php echo $postUrl; ?>',
picture: "http://viralsyndicator.com/wp-content/uploads/2018/02/0-199-670x377_c.jpg",
title: 'title',
description: '<?php echo $decodedPostTitle; ?>',
}, function(response) {});
I dont know how to solve this FB issue.Please help guys.
Thanks

How to Use Google My Business Api to get the reviews , and reply to that

If I have api key of Business API, i just want example of URL, like how to put the place id and api key.
If Google have authorized you to use Google Business API then you need to
Authenticate the user via OAuth.
After authentication which will give you the token, API will return you the users's account.
Now to get the reviews you have to make Http Get request to the endpoint below
https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations/{locationid}/reviews
Your Http Get request must have Access Token
For Example: https://mybusiness.googleapis.com/.../reviews??access_token={tokenHere}
this will return you all the reviews.
Ref: https://developers.google.com/my-business/reference/rest/v4/accounts.locations.reviews
Hope that answered your Question.
*Please note, support of v3 of the API ended on March 10, 2018; v3 will no longer be available on May 10th 2018. So we encourage you to migrate to v4.1 as soon as possible to prevent any interruption in functionality. In addition, the deprecation schedule can be found here
You can get Google My business (GMB) reviews in same ways
Please find the below working code for review reply with PHP HTTP request
$access_token = "<your_access_token_here>";
$query = array('comment' => 'Thank you for visiting our business!');
$request_uri = "https://mybusiness.googleapis.com/v4/accounts/111050869667910417441/locations/17405754705905257334/reviews/AIe9_BFu3rdicGrPrzdyu4PDXmqMAu-9BCJf9_HF0DxzGxsjAGw5KGl1XsdqSkbsAMdl_W2XBG4bwO3wCp0_l_8KLAV7mckl5cSyJItwPqSYGiH3ktK6nrI/reply?access_token=" . $access_token;
$curinit = curl_init($request_uri);
curl_setopt($curinit, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curinit, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($curinit, CURLOPT_POSTFIELDS, json_encode($query));
curl_setopt($curinit, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curinit, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen(json_encode($query)))
);
$json = curl_exec($curinit);
$phpObj = json_decode($json, true);
var_dump($phpObj);
This code worked for me. I used the curl library to answer a review. I hope it serves you
$url = "https://mybusiness.googleapis.com/v4/accounts/{accountId}/locations/{locationId}/reviews/{reviewId}/reply";
$access_token = {access token google}
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$query = array('comment' => 'Thank You!');
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($query));
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Authorization: Bearer '.$access_token.'',
'Content-Type: application/json',
'Content-Length: ' . strlen(json_encode($query)))
);
$response = curl_exec($ch);
echo $response;
curl_close($ch);

Mailchimp API status 200 for members who are already subscribed

The following code is working and subscribing new members successfully. However, the status returns 200 even if the email address is already subscribed. I have checked that $member_id is hashing correctly, and despite identical values it still returns 200.
$result = array(
'status' => sync_mailchimp($data)
);
var_dump($result) // 200
function sync_mailchimp($data) {
// Setup our Mailchimp info
$api_key = 'xxxxx';
$list_id = 'ab8abde5bb';
$member_id = md5(strtolower($data['email'])); // lowercase hash of the email
$datacenter = 'us16';
$url = 'https://' . $datacenter . '.api.mailchimp.com/3.0/lists/' . $list_id . '/members/' . $member_id;
$json = json_encode([
'email_address' => $data['email'],
'status' => $data['status']
]);
// Send via curl
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_USERPWD, 'user:' . $api_key);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
$result = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
return $httpcode;
}
I was also having the same issue while using a similar snippet.
Reading the MailChimp API 3.0 docs relating to managing subscribers (specifically the section Subscribe an Address), it was clear that this method was not the correct way to add a new subscriber.
The request type needs to be a POST
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
and must be sent to the endpoint
https://<data_center>.api.mailchimp.com/3.0/lists/<list_id>/members/
The request body containing the JSON is identical.
The response code will be 200 when an email address is added to the list successfully, and 400 when the email address already exists on the list.
Note that this method will not work for updating an existing subscriber – to do that, the request type must be PATCH, and you must use the original endpoint ending with the hashed email address.

How can I update custom fields using the BigCommerce API?

I am looking to update the custom fields on a product.
I found in the guide on how to do it manually via the admin interface
The API docs suggest that you can't directly modify the custom fields on a product, only access them:
My next thought was to update the product
This is the existing custom_field on the product.
{
"url"=> "https://storename.mybigcommerce.com/api/v2/products/32/customfields.json",
"resource"=>"/products/32/customfields"
}
When I try to modify the url/resource and send the hash back to update, I am greeted with a 400 Bad Request :(
new_custom_fields = {
"url" => "https://storename.mybigcommerce.com/api/v2/products/75/customfields.json",
"resource" => "/products/75/customfields"
}
api.update_products(75, {"custom_fields" => new_custom_fields})
RuntimeError: Failed to parse Bigcommerce response: 400 Bad Request
Thoughts?
this seems to be a bug in the Bigcommerce APIs. Currently only GET requests on the custom fields are supported.
http://developer.bigcommerce.com/api/products/customfields
That is probably the reason why you are hitting a 400.
Not sure if this will help with Ruby, but it might help those using PHP... I'm able to create a custom field on a product using php. Just need the product id and the values for the custom field, "name" and "text".
$data_array = array('name' => 'gender', 'text' => 'male');
BigCommerce::createProductCustomField('17', $data_array);
I haven't tried updating a custom field, but if creating one works, then the following should also work to update a current custom field:
BigCommerce::updateProductCustomField($product_id, $id, $object);
You'll need the $product_id of the product you want to update, the $id of the custom field that you want to update, and $object should be an array like $data_array above.
More info on PHP client for BC: https://github.com/bigcommerce/bigcommerce-api-php
Good luck!
Try this Code :
$headers = array(
"Content-type: application/json",
//"Authorization: Basic " . base64_encode($credentials)
);
$name='Bullet Point ';
$data_array = array('name'=>'Bullet Point','text'=>'Bullet Point value');
$body=json_encode($data_array);
//Get the current url and split it at the '?'
$ch = curl_init('https://www.abc.mybigcommerce.com/api/v2/products/1122/customfields.json'); //open connection
curl_setopt($ch, CURLOPT_TIMEOUT, 60); //set to 60 seconds from BC API Guide v1 PDF example
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); //load all header data
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); //comment out this PUT line to change to a POST statement
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0 );
curl_setopt( $ch, CURLOPT_USERPWD, "admin:api-key");
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 0 );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
$result = curl_exec($ch); //execute post
curl_close($ch);

Resources