Magento ver. 2.1.7 coupon code not working checkout page - magento2

Hello I am using cart price rule. When I try to apply coupon code into cart page at that time in cart page successfully apply coupon code, but in checkout page coupon code is not apply, or I applied coupon code from cart page then I can not remove coupon code from checkout page.
I am getting the following error when I am trying to apply or cancel coupon code:
jquery.js:10254 DELETE https://domain.nl/rest/default/V1/carts/mine/coupons 404 () send # jquery.js:10254 ajax # jquery.js:9738 delete # storage.js:78 (anonymous) # cancel-coupon.js:35 cancel # discount.js:51 (anonymous) # knockout.js:3863 dispatch # jquery.js:5226 elemData.handle # jquery.js:4878 VM19906:1 Uncaught SyntaxError: Unexpected token < in JSON at position 0
at JSON.parse (<anonymous>)
at Object.process (error-processor.js:19)
at Object.<anonymous> (cancel-coupon.js:56)
at fire (jquery.js:3232)
at Object.fireWith [as rejectWith] (jquery.js:3362)
at done (jquery.js:9842)
at XMLHttpRequest.callback (jquery.js:10311) process # error-processor.js:19 (anonymous) # cancel-coupon.js:56 fire # jquery.js:3232 fireWith # jquery.js:3362 done # jquery.js:9842 callback # jquery.js:10311 XMLHttpRequest.send (async) send # jquery.js:10254 ajax # jquery.js:9738 delete # storage.js:78 (anonymous) # cancel-coupon.js:35 cancel # discount.js:51 (anonymous) # knockout.js:3863 dispatch # jquery.js:5226 elemData.handle # jquery.js:4878 jquery.js:10254 XHR failed loading: DELETE "https://domain.nl/rest/default/V1/carts/mine/coupons".
=> I am also using amasty one step checkout plugin, but I have checked after disable "Amasty OSC" but coupon code not working in checkout page.
Thanks,
Dhvanit

This issue is related to the server settings. You server doesn't accept PUT requests.
It means that all Magento's parts which perform PUT requests to the server, will show errors.
Please contact with your server provider.
And not apply cancel coupon code then enable DELETE requests.

Related

Magento 2 - Custom rest api endpoint for PDF download - net::ERR_HTTP2_PROTOCOL_ERROR 200

I have created custom rest api endpoint in magento for downloading pdf file.
When testing it locally: From separate react JS project I am sending request to that endpoint and file is downloaded successfuly. http/1.1 protocol is used (checked in google chrome dev tools, network tab).
After deployment to staging servers, when I try to make request between staging servers from reactJS project to magento2 project, then upon sending request it takes 30-40 seconds without getting any response and then error is shown in console. There is not anything in the error logs. http2 protocol is used (not sure if that can be a reason for issue).
Failed to fetch - net::ERR_HTTP2_PROTOCOL_ERROR 200
Here is the piece of php code for downloading pdf file:
...
$filename = $outputFileName . time() . '.' . $extension;
$directoryTmpWrite = $this->filesystem->getDirectoryWrite(DirectoryList::TMP);
$directoryTmpWrite->writeFile($filename, $fileContent);
return $this->fileFactory->create(
$outputFileName . '.' . $extension,
[
'type' => 'filename',
'value' => $filename,
'rm' => true,
],
DirectoryList::TMP, //basedir
'application/octet-stream',
''
);
How I resolved my issue?
I had to turn on output buffering in php in magento, to ensure that no output has been sent from a script and instead of that output has been store to a buffer and then sent all together from a script when script execution is finished.
So ob_start() fixed my issue. Right before return statement.

Ruby gem facebook_ads exception_with_response: 400 Bad Request

I'm trying to query the Facebook Marketing API Insights using the facebook_ads Ruby gem. https://github.com/tophatter/facebook-ruby-ads-sdk
I created an app and have Editor permissions on the relevant pages for my company.
Next, I generated a user access token from this page after selecting ads_management permissions.
Next, I followed the instructions on this page to get a permanent page access token.
With the code below I get this error:
/var/lib/gems/2.3.0/gems/rest-client-/var/lib/gems/2.3.0/gems/rest-client-2.0.2/lib/restclient/abstract_response.rb:223:in exception_with_response': 400 Bad Request (RestClient::BadRequest)
from /var/lib/gems/2.3.0/gems/rest-client-2.0.2/lib/restclient/abstract_response.rb:103:inreturn!'
from /var/lib/gems/2.3.0/gems/rest-client-2.0.2/lib/restclient/request.rb:809:in process_result'
from /var/lib/gems/2.3.0/gems/rest-client-2.0.2/lib/restclient/request.rb:725:inblock in transmit'
from /usr/lib/ruby/2.3.0/net/http.rb:853:in start'
from /var/lib/gems/2.3.0/gems/rest-client-2.0.2/lib/restclient/request.rb:715:intransmit'
from /var/lib/gems/2.3.0/gems/rest-client-2.0.2/lib/restclient/request.rb:145:in execute'
from /var/lib/gems/2.3.0/gems/rest-client-2.0.2/lib/restclient/request.rb:52:inexecute'
from /var/lib/gems/2.3.0/gems/rest-client-2.0.2/lib/restclient.rb:67:in get'
from /var/lib/gems/2.3.0/gems/facebook_ads-0.6.6/lib/facebook_ads/base.rb:15:inget'
from /var/lib/gems/2.3.0/gems/facebook_ads-0.6.6/lib/facebook_ads/ad_account.rb:10:in `all'
I have also tried this code with my temporary user access code but get the same result.
Here is my code
#!/usr/bin/ruby
require 'facebook_ads'
MY_PAGE_PERMANENT_ACCESS_CODE = 'my access code'
APP_SECRET = 'my app secret'
FacebookAds.access_token = MY_PAGE_PERMANENT_ACCESS_CODE
FacebookAds.app_secret = APP_SECRET
accounts = FacebookAds::AdAccount.all
It turns out that I was using the page permanent access token which was out of scope for the API call. I needed to use my temporary user access code.
E, [2019-01-19T00:08:49.366067 #19868] ERROR -- : GET /me/adaccounts
OAuthException / 100: (#100) Tried accessing nonexisting field
(adaccounts) on node type (Page) RestClient::BadRequest: 400 Bad
Request
In the pry console for the gem I ran this command to set the account variable:
pry(main)> account = FacebookAds::AdAccount.find('act_MY_ACCOUNT_ID')
and I get this error:
E, [2019-01-19T00:12:24.760545 #20188] ERROR -- : GET /me/adaccounts
OAuthException / 2635: (#2635) You are calling a deprecated version of
the Ads API. Please update to the latest version: v3.2.
RestClient::BadRequest: 400 Bad Request
So, I ran this command:
pry(main)> FacebookAds.base_uri = 'https://graph.facebook.com/v3.2'
"https://graph.facebook.com/v3.2"
Then pry(main)> account = FacebookAds::AdAccount.find('act_MY_ACCOUNT_ID') again.
Finally, I ran:
pry(main)> account.ad_insights
but the result is an empty array when I know this should not be blank. I'm going to skip the gem and use Ruby net/http to query the API directly.

Codeception REST API call for HTTPS url

I'm looking for a codeception configuration to use the Codeception REST Module to make calls against a secured https url.
For example I want to check the online status of our slack bot:
$slackApiUrl = 'https://slack.com/api/users.getPresence';
$params = [
'token' => $apiToken,
'user' => $botUserId,
];
$I->sendPOST($slackApiUrl, $params);
When I execute the test, I'll get a guzzle error like
[GuzzleHttp\Exception\ConnectException] cURL error 35: SSL: CA certificate set, but certificate verification is disabled (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)
I knew, that the default of codeception switch off https secured urls but how can I activate https, when I need it?
My suite.yml:
class_name: AcceptanceTester
modules:
enabled:
- REST:
url: *****
depends: PhpBrowser
- PhpBrowser
- Asserts
- \Helper\Acceptance
I could answer myself. It`s the codeception version. After updating to Codeception v2.2, the same test works like expected.
Codeception PHP Testing Framework v2.2.8
Powered by PHPUnit 5.7.15 by Sebastian Bergmann and contributors.
[Groups] slack
Acceptance (live) Tests (1) --------------------------------------------------------------------------
Modules: REST, PhpBrowser, Asserts, \Helper\Acceptance
------------------------------------------------------------------------------------------------------
slackCest: Check slack bot online status
I send post "https://slack.com/api/users.getPresence"
[...]
[Response] {"ok":true,"presence":"active"}
I am going to Check SlackBot online status
I see response contains json {"ok":true,"presence":"active"}
PASSED

PayPal timeout on classic API sandbox call

I'm using PayPal Digital Goods checkout with the classic API (signature/password API credentials). Live transactions are working but sometime between Dec 27 and Jan 7 sandbox transactions stopped working, claiming "session expired" when trying to confirm the transaction. Following is the response to the Digital Goods checkout and the confirm invocations:
[08-Jan-2014 20:03:06 UTC] PayPal Checkout-Calling SetExpressCheckoutDG
[08-Jan-2014 20:03:07 UTC] PayPal Checkout Result. Results = TOKEN:EC-38C423050J138841W TIMESTAMP:2014-01-08T20:03:07Z CORRELATIONID:381d15bad3eaa ACK:Success VERSION:84 BUILD:9187650
[08-Jan-2014 20:03:07 UTC] RedirectToPayPalDG Header=https://www.sandbox.paypal.com/incontext?token=EC-38C423050J138841W
[08-Jan-2014 20:03:14 UTC] PAYPAL GetExpressCheckoutDetails TOKEN=EC-38C423050J138841W
[08-Jan-2014 20:03:15 UTC] PayPal Confirm--Failed. Results = TIMESTAMP:2014-01-08T20:03:15Z CORRELATIONID:2b45bb61f3787 ACK:Failure VERSION:84 BUILD:9187650 L_ERRORCODE0:10411 L_SHORTMESSAGE0:This Express Checkout session has expired. L_LONGMESSAGE0:This Express Checkout session has expired. Token value is no longer valid. L_SEVERITYCODE0:Error
Note the timestamps: the error return is 9 seconds after the checkout timestamp (when the user process started).
It looks like the classic API to the sandbox is broken. Anyone else seeing this, and if so is there a solution?
Its a different correlation or even a different session.
Problem solved--my error in managing credentials.

Paypal Adaptive Payments 500 proxy error

I'm seeing the following error message when attempting to perform a simple payment using the PayPal Adaptive Payments API and the Explicit Approval Payment Flow in the sandbox environment:
Proxy Error
The proxy server could not handle the request GET /webapps/adaptivepayment/flow/expresscheckoutincontextremembermeflow.
Reason: Error during SSL Handshake with remote server
As per this related post, this issue has supposedly been resolved, but I'm still unable to perform a simple payment in the sandbox environment.
The API call to generate a payKey is returning successfully:
{
'responseEnvelope': {
'ack': 'Success',
'timestamp': '2013-04-01T10:00:33.572-07:00',
'build': '5563463',
'correlationId': '9ddb6d34b8b31'
},
'paymentExecStatus': 'CREATED',
'payKey': 'AP-30241506EH984280M'
}
and the following series of redirects are occurring:
https:// www.sandbox.paypal.com/webapps/adaptivepayment/flow/pay?expType=light&paykey=AP-30241506EH984280M
redirects to:
https:// www.sandbox.paypal.com/webapps/adaptivepayment/flow/payinit?iframecookie=1364835660832&paykey=AP-30241506EH984280M&expType=light
which redirects to:
https:// www.sandbox.paypal.com/webapps/adaptivepayment/flow/corepay
which redirects to:
https:// www.sandbox.paypal.com/webapps/adaptivepayment/flow/expresscheckoutincontextremembermeflow
which gives the 500 proxy error after approximately 210 seconds.
Additionally, if I attempt the workaround of logging into developer.paypal.com in another tab first, I get a 404 error on the initial request:
https:// www.sandbox.paypal.com/webapps/adaptivepayment/flow/pay?expType=light&paykey=AP-45P14958V28124917
I've searched and searched and poked and prodded this issue to death...anyone else seeing this problem, and does anyone have a working resolution?
We are rolling a patch later tonight which we expect to fix this issue permanently.