I am using checkout.com payment gateway. I want to integrate it to my website but in their developer area I am not able to find any suitable solution to integrate it with codeigniter. Below is the developer area of checkout.com
http://developers.checkout.com/
Any help in this regard will be very helpful. Thank you.
They are providing this code for implementation :
window.CKOConfig = {
debugMode: true,
publicKey: 'Your public key',
customerEmail: 'user#email.com',
ready: function (event) {
console.log("CheckoutKit.js is ready");
CheckoutKit.monitorForm('.card-form', CheckoutKit.CardFormModes.CARD_TOKENISATION);
},
apiError: function (event) {
// ...
}
But I am not able to understand that how I will call it with dynamic data and with my some conditions?
They won't give you a codeigniter integration, you can do it yourself with plain PHP though:
https://github.com/CKOTech/checkout-php-library
Did you even read their documentation?
Related
I have the following cenario: On my page are different payment-options. First you choose the method, where by clicking on the paypal-button shout happens nothing. Only if you click then the order-and-pay-button it shout run the behavior of the paypal-button, with opening the paypal-dialog.
My first idea was to use the standard paypal-button and store it in an hidden field.
By clicking on my-paypal-button I load the paypal-script like this:
var wasLoaded = false;
function loadScript() {
if(wasLoaded) return;
wasLoaded = true;
var script = document.createElement('script');
script.type = 'text/javascript';
document.body.appendChild(script);
script.onload = function() {
paypal.Buttons({
// Set up the transaction
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{
amount: {
value: '88.44'
}
}]
});
}, ...
load it to a hidden div.
}
script.src = 'https://www.paypal.com/sdk/js?client-id=SD&intent=capture&vault=false&commit=true';
}
by loading it to an hidden div.
By clicking on order-and-pay I make button.click() to execute the paypal-stuff.
But unfortunately the papypal-stuff is in a iframe, so I do not have access to it.
I could not find any hint in the paypal-specs. They wont always to use there button.
How can I achieve this approach?
Please refer to the below Server-Side API link which will help you achieve Server-side payment integration without PayPal Client's side button.
https://developer.paypal.com/docs/business/checkout/server-side-api-calls/
Feel free to let me know if you have any queries, also I am happy to share postman collections to play around with the APIs.
Speak to you soon!
Regards
Goutham AV
If you already have a button created, i woud just use a PHP generated Link:
If a user clicks on it, that user will be redirected to a PayPal Page -> buy on paypal -> get redirected to your page.
For that purpose i'd recommend PayPal PHP Api: PayPal PHP Api
Step 1: To get your libary working, download and install Paypal Api and start with that code:
<?php
// 1. Autoload the SDK Package. This will include all the files and classes to your autoloader
// Used for composer based installation
require __DIR__ . '/vendor/autoload.php';
// Use below for direct download installation
require __DIR__ . '/PayPal-PHP-SDK/autoload.php';
Step 2: You need to setup your PayPay ClientID and Secret:
// After Step 1
$apiContext = new \PayPal\Rest\ApiContext(
new \PayPal\Auth\OAuthTokenCredential(
'AYSq3RDGsmBLJE-otTkBtM-jBRd1TCQwFf9RGfwddNXWz0uFU9ztymylOhRS', // ClientID
'EGnHDxD_qRPdaLdZz8iCr8N7_MzF-YHPTkjs6NKYQvQSBngp4PTTVWkPZRbL' // ClientSecret
)
);
Step 3: Use Code to generate a Link for your Button. You can use Code Samples from the Paypal Api Sample Pages here
I would recommend you the Code Sample: "PayPal Payments - similar to Express Checkout in Classic APIs"
I know there are maybe better ways to implement paypal buttons on a webpage, but this worked best for me.
I'm trying to build mobile app for the web page which is implemented entirely in PHP Codeigniter framework. I figured I would reuse website's server API for the mobile app. For that I would need RESTfull services.
The thing is I don't know PHP at all! And from what I gather, websites built on Codeigniter don't normally have public endpoint to invoke it's API.
One example would be Ion-auth. The Authentication is done on PHP level with no REST services.
So my question is...does what I've written above make any sense and I understood the framework correctly? If so, does that mean, I'll have to write separate server for my mobile app which would have exactly the same functions and database, or maybe is there a way to reuse current services elegantly?
I have researched about codeigniter-restserver but it seems I would have to rewrite all the logic in the website and I would rather do it in spring or node.
You're going to get a pretty subjective group of answers for this. There are a couple ways to do what you seem to be looking for.
First, is a separate "API" controller with the CodeIgniter-restserver which duplicates all of your controller functions. This would be sub-optimal since you'll have to maintain your website's code in two places.
Another, slightly better option would be to check for $this->input->is_ajax_request() or something similar sent by the mobile app, then send responses back with the restserver but the usual view() for the website.
Ultimately, and your best option, would be to refactor all your code making a single codebase API endpoint (this is where you'd have to decide if CI is a reasonable API or if you want to use something else) and your website and mobile apps use it.
Edit
I just realized you specifically mentioned ion-auth, and I happen to have PyroCMS's users module open.
if ($this->input->is_ajax_request())
{
$user = $this->ion_auth->get_user_by_email($user->email);
$user->password = '';
$user->salt = '';
exit(json_encode(array('status' => true, 'message' => lang('user:logged_in'), 'data' => $user)));
}
so, for the restserver you could instead send back:
$this->response(array('status' => true, 'message' => lang('user:logged_in'), 'data' => $user)), 200);
Edit 2
Regarding how to send post data with Ajax, that's really a whole different question from the OP, but a quick example using jQuery:
// Not complete code
<script>
// Attach a submit handler to the form
$( "#searchForm" ).submit(function( event ) {
// Stop form from submitting normally
event.preventDefault();
// Get some values from elements on the page:
var $form = $( this ),
term = $form.find( "input[name='s']" ).val(),
url = $form.attr( "action" );
// Send the data using post
var posting = $.post( url, { s: term } );
// Put the results in a div
posting.done(function( data ) {
var content = $( data ).find( "#content" );
$( "#result" ).empty().append( content );
});
});
</script>
Example from https://api.jquery.com/jquery.post/
I have an app that has a full angularjs frontend with a codeigniter backend (with thishttps://github.com/philsturgeon/codeigniter-restserver)
I am using the codeigniter backend just to make api requests essentially.
The problem I am having now is managing a navigation view based on whether or not a user is logged in.
I have the navigation in its own navCtrl with a userService and loginCtrl.
I am storing loggedIn true or false in a cookie with a $watch on it in the navCtrl so it will update the navigations appropriately.
Any insight on why this may not be working? Any code i need to provide to clarify? Is there a "better" way to do this?
EDIT: The $watch is not actually catching when I update the value using the userService.
Thank you!
We have a very similar setup as you. What we do is have Codeigniter send a HTTP Status code of 419 (not logged in) or something like that. And then you'll use Angular Interceptors to 'listen' for the response from the backend.
app.factory('loggedIn',function($q,$location){
return {
/*
* Intercept all response errors & handle them
*/
responseError: function(response) {
if (response.status == 419) {
console.error("You are not logged in");
$location.path('/login');
}
return $q.reject(response);
}
};
});
Then push it to the $httpProvider:
app.config(['$httpProvider', function($httpProvider){
$httpProvider.interceptors.push('loggedIn');
}]);
This should handle your front-end navigation pretty easily.
There are also other things that you can do for the $http requests before sending & before response is returned. Makes for a slick setup.
Checking sessions in Angularjs and CI using AJAX:
Javascript function called in angular js controllers:
function check_session()
{
$.get(base_url+"admin/check_session/check", function(data, status){
if(data=="1") /* error 1 => un-athorized user */
{
window.location.href=base_url+"login";
}
});
}
Expaining AJAX request:
check_session is CI controller and check is function in that.
I'd want the user to re input password before they can login to my app. The facebook documentation only shows it using the Javascript SDK. Can someone please guide me or give me some references on how to do it using php?
here's what it looks like in js:
FB.login(function(response) {
// Original FB.login code
}, { auth_type: 'reauthenticate' })
Follow the official documentation but use getReAuthenticationUrl method instead of getLoginUrl.
The parameters are exactly same as getLoginUrl.
I'm trying to integrate PayPal payments within my Phonegap app. I can't see a cross platform way to do it.
I can only see OS specific plugins which I can't use in Phonegap build. Is there a way of integrating it using the childbrowser? Also, I failed to find a plugin for Blackberry.
Note: I use Phonegap build, so I prefer a plugin-less solution.
what you can do is the in app browser to connect to a php driven page online and there do your paypal stuff.
http://docs.phonegap.com/en/2.3.0/cordova_inappbrowser_inappbrowser.md.html
function onDeviceReady() {
var ref = window.open('http://apache.org', '_blank', 'location=yes');
ref.addEventListener('loadstart', function() { alert('start: ' + event.url); });
ref.addEventListener('loadstop', function() { alert('stop: ' + event.url); });
ref.addEventListener('exit', function() { alert(event.type); });
}
Remember to white list the url that you will be using within phonegap else you will not to be able to make a connection.
On the php side write your own restfull api to handle the processing of the payments try to minimize the data sent to and from the api also try to use a secure connection if possible.
paypal examples can be found here:
https://www.x.com/developers/paypal/documentation-tools/paypal-code-samples
its a solution but i do advise to use plugins for every platform, with those you can better guarantee safety, less bugs and less development time.