Checkout Button Callbacks don't work if customer is using 2 factor authentication - coinbase-api

Checkout Button Callbacks don't work if customer is using 2 factor authentication.
I mean, customer can pay with checkout button but if they are using 2fa, they can pay with coinbase but callbacks doesn't work.
My code is below.
<a class="buy-with-crypto m-option" href="https://commerce.coinbase.com/checkout/<?php echo $key; ?>">
<span><img src="/theme-assets/images/coinbase250px.png" class="img-fluid" style=""></span>
</a>
<script src="https://commerce.coinbase.com/v1/checkout.js"></script>
<script>
BuyWithCrypto.registerCallback('onSuccess', function(e){
window.location.href = "<?php echo base_url(); ?>subscription/coinbase_payment_result/"+e.code+"/<?php echo $order['id']; ?>"; });
BuyWithCrypto.registerCallback('onFailure', function(e){
alert('Your charge has been failed.'); });
</script>
Thanks

Related

Pepper: how to activate output of the box by Html/Javascript webpage

I'm programming an App for the Aldebaran's Pepper robot. I'm using Choregraphe and I made an html page for displaying in robots tablet.
I just want to activate an output (that i have to add at the "SHOW APP" box) by pressing a button in the Html page displayed on the tablet of the robot.
How to do this?
index.html
<head>
<script src="/libs/qi/2/qi.js"></script>
<script src="js/script.js"></script>
</head>
<body>
<div class="flex">
<button class="button" onclick="launchEvent1()">First event</button>
<button class="button" onclick="launchEvent2()">Second event</button>
<button class="button" onclick="launchEvent3()">Third event</button>
<button class="home" onclick="launchEventHome()">Home button</button>
</div>
</body>
script.js
session = null
QiSession(connected, disconnected, location.host);
function connected(s) {
console.log("Session connected");
session = s;
//If you want to subscribe so some events (to send info pepper->tablet) call the function here
}
function disconnected(error) {
console.log("Session disconnected");
}
function launchEventHome(){
session.service("ALMemory").then(function (memory) {
memory.raiseEvent("homeEvent", "paramHome");
});
}
function launchEvent1(){
session.service("ALMemory").then(function (memory) {
memory.raiseEvent("event1", "param1");
});
}
function launchEvent2(){
session.service("ALMemory").then(function (memory) {
memory.raiseEvent("event2", "param2");
});
}
function launchEvent3(){
session.service("ALMemory").then(function (memory) {
memory.raiseEvent("event3", "param3");
});
}
On choregraphe, click on "add event from ALMemory" (the plus icon on the left side) and select "add new key". Give it the name you gave it on your .js file (in my case, event1, event2, event3 and homeEvent).
With that, whenever the user clicks on the button on the tablet, it will trigger the event and it will send the param as a dynamic type (param1, 2, etc. depending on which button the user pressed)
What you can do is use the Javascript SDK to raise ALMemory events, and subscribe to those in Choregraphe.
Something like this (left red box):

Angular JS translate not working properly inside Visualforce page

I need to translate my HTML into different languages based on user preference. For that, I am using Angular JS translate method. The example when I write inside notepad and saved as ".html" is working fine. But when I pasted the same code inside my Salesforce Visualforce page, its behavior changes.ie. When I click on the button"IT" to translate the content to "Italics" the contents are translating to Italics but within seconds the contents are again going back to their preferred language "EN". I have given below my screenshot of output.
I have given below my code, can anyone say what's wrong in this.
<!DOCTYPE html>
<html ng-app="app">
<head>
</head>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<script src="https://cdn.rawgit.com/angular-translate/bower-angular-translate/2.5.2/angular-translate.js"></script>
<script>
// Code goes here
var app = angular.module('app', ['pascalprecht.translate']);
app.config(['$translateProvider',
function($translateProvider) {
$translateProvider.translations('it', {
'Purchase order': "Ordine di acquisto ",
'Number:': "Numero:",
'Customer data': "Dati Cliente",
'Surname / Company':"Cognome/Società",
'Name':"Nome",
'Piazza way':"Via/Piazza",
'City':"Città",
'VAT tax code':"Codice Fiscale/Partita IVA",
'Phone':"Telefono",
'E-Mail':"E-Mail",
'CAP':"CAP"
});
$translateProvider.preferredLanguage("en");
}
]);
app.controller('AppController', function ($translate) {
// this.browser = navigator.userAgent;
this.useLang = function (lang) {
$translate.use(lang);
}
});
</script>
<div ng-controller="AppController as app">
<h3 translate> Purchase order </h3>
<p translate>Number:</p>
<h3 translate>Customer data</h3>
<p><span translate>Surname / Company</span>_________</p>
<p> <span translate>Name</span>__________</p>
<p><span translate>Piazza way</span>____________</p>
<p><span translate>CAP</span>_______<span translate>City</span>______</p>
<p><span translate>VAT tax code</span>__________</p>
<p><span translate>Phone</span>____________</p>
<p><span translate>E-Mail</span>_________</p>
<button ng-click="app.useLang('it')">IT</button>
<button ng-click="app.useLang('en')">EN</button>
</div>
</body>
</html>
try this
{{'variable_name' | translate }}
After going through the solutions provided in developer forums, finally I found the solution for my problem. Actually the reason behind my content going back to "english" from "italics" is "page refreshing". To stop the page from refreshing I need to set the <button> type as "button".
ie <button type="button">
Code change
<button type="button" ng-click="app.useLang('it')">IT</button>
<button type="button" ng-click="app.useLang('en')">EN</button>
I did the change in my code and it stopped the page from refreshing, which in turn gave my expected result.

My web page redirects to a blank screen on submitting the form

I am trying to display a flash message saying 'Mail sent' on sending an email from a form in cakephp. The email is send successfully to the recipient but then it goes to a blank screen and doesn't display the flash message which indicates that the message has been sent.I have checked for spaces before and after php tags in the controller and that doesnt seem to be the problem.IT works fine on my localhost and displays the message but not on the server.I will put my controller code
public function contact() {
$email = new CakeEmail();
if ($this->request->is('post')) {
$this->Contact->set($this->request->data);
if ($this->Contact->save($this->request->data)) {
//$this->Project->set($this->data)
$name = $this->request->data['Contact']['name'];
$mail = $this->request->data['Contact']['email'];
$email->from(array($mail => $name));
$email->to('sales#blacknova.com.au');
if (isset($this->request->data['Contact']['contacttime'])) {
$ctime = implode(',', $this->request->data['Contact']['contacttime']);
}
$message = "Phone No : ".$this->request->data['Contact']['phone']."\n\nBest Contact time :".$ctime." \n\nMessage : ".$this->request->data['Contact']['description'];
$email->subject('BlackNova Website Contact Form Message');
//$email->send($message);
//$success =1;
//$email->send($this->request->data['Contact']['phone']);
//pr($message);
if ($email->send($message)) {
$this->Session->setFlash('Mail sent successfully');
$this->redirect(array('controller' => 'BlockContents', 'action' => 'contact'));
//pr($success);
}
}
}
}
There is a contact.ctp
<div id="formcontainer_left">
<?php echo $this->Form->create('Contact'); ?>
<div class="inputbox1"><?php echo $this->Form->input('name');?></div><br>
<div class="inputbox2"><?php echo $this->Form->input('email'); ?></div><br>
<div class="inputbox3"><?php echo $this->Form->input('phone');?></div><br>
</div>
<div id="formcontainer_right">
<div id="me"><?php echo $this->Form->input('description');?>
</div>
<?php echo $this->Form->submit('SUBMIT');?>
</div>
<div id="formcontainer_xright">
<div class="formcontainer_last"> BEST TIME TO CONTACT* </div>
<div id="chkbox">
<?php echo $this->Form->input('contacttime',array('label'=>false,'type'=>'select','class'=>'checkdiv','multiple'=>'checkbox','options'=>array('Before work' =>'Before work','During work'=>'During work','After work'=>'After work'),'escape'=>false)) ;?>
</div>
</div>
<?php echo $this->Form->end(); ?>
<div class="contactformbottom">
</div>
</div>
<div id="formcontainer2">
<p> <?php echo $this->Session->flash();?></p>
Could somebody please help me find out why it happens only on the srver and not on the local host?
The problem is that your BlockContents isn't a valid controller in the redirect url.
If you try using an underscored version block_contents instead, you'll find it'll probably work.
Take a look at the recommended usage in the book. http://book.cakephp.org/2.0/en/getting-started/cakephp-conventions.html#url-considerations-for-controller-names
As #DavidYell says, the problem is the controller in the redirect. If you do need that redirect, his answer should solve everything. I just want to point out you don't really need the redirect if all you want is to clear the values in the textboxes but stay on the same action.
if ($email->send($message)) {
$this->Session->setFlash('Mail sent successfully');
$this->request->data = null;
}
should clear the textboxes with no need of redirection.

cakephp need to place animated waiting icon

I linked my page to paypal, I coded like this
<div class="paypal">
<h1><?php __('Please wait while we transfering you to the payment gateway.');?></h1>
<?php echo $paypal->submit(__('Click here if this page appears for more than 5 seconds', true), $paypalData); ?>
<script type="text/javascript">
document.getElementById('frmPaypal').submit();
</script>
</div>
I need to place an animated gif waiting icon instead of button....
If you're wanting to output the image using CakePHP:
echo $this->Html->image('loading.gif', array('alt' => 'Loading'));
Otherwise you can use HTML:
<img src="loading.gif">

CakePHP Recaptcha using CakeDC plugin version 1.1 no post received by controller method no error message

Using Cakephp 2.2.4 and the Recaptcha plugin 1.1 from CakeDC on a form. The page is SSL/HTTPS. When I submit form with correct recaptcha text entered the form resets and no messages.
have checked $this->request->data in the appropriate method in controller and no post is received by it.
Anyone come across this problem or have a solution ?
Thanks.
Extract from Controller code:
if ($this->request->is('post')) {
if ($this->Recaptcha->verify()) {
Extract from View:
echo $this->BootstrapForm->input('message', array(
'type' => 'textarea',
'required' => 'required',
'helpInline' => '<span class="label label-important">' . __('Required') . '</span> ')
);
?>
<?php echo $this->Recaptcha->display(array('recaptchaOptions'=>array('theme' => 'clean'))); ?>
<?php echo $this->BootstrapForm->submit(__('Submit'),array('class' => 'btn btn-primary'));?>
</fieldset>
<?php echo $this->BootstrapForm->end();?>
Have made no changes to model for recaptcha.
CakeDC plugin I am using is this one:
https://github.com/CakeDC/recaptcha
See the SSL part here.
reCAPTCHA on an https site
In order to avoid getting browser warnings when you use reCAPTCHA on
an SSL site, you should replace http://www.google.com/recaptcha/api
with https://www.google.com/recaptcha/api when you request a
challenge. Your request to reCAPTCHA would look like this:
<script type="text/javascript"
src="https://www.google.com/recaptcha/api/challenge?k=your_public_key">
</script>
<noscript>
<iframe src="https://www.google.com/recaptcha/api/noscript?k=your_public_key"
height="300" width="500" frameborder="0"></iframe><br>
<textarea name="recaptcha_challenge_field" rows="3" cols="40">
</textarea>
<input type="hidden" name="recaptcha_response_field"
value="manual_challenge">
</noscript>

Resources