Integrate Paypal PHP sdk with Cakephp 3.x - paypal

To use Paypal PHP SDK is quite simple but when i try to use this SDK in cakephp 3.x then it generates errors. I changed namespace name in "Paypal SDK project" to bring all files under one name space.
My cakephp project namespace name is
namespace App
but namespace in Paypal SDK is
namespace PayPal
I just changed it to "namespace App" and put all files in PayPal folder and put that folder in "src" folder in cakephp project. but PayPal does not work using this technique.
Can you please advise me how to use this SDK in CakePHP or where to put files are best.
I know there are some other techniques to make payment via paypal without SDK but i want to use SDK.
Can you please guide me little bit how to integrate PayPal PHP SDK in CakePHP.
SDK is provided here
https://github.com/paypal/PayPal-PHP-SDK
some payment samples are here
http://paypal.github.io/PayPal-PHP-SDK/sample/

1. Use composer for installation which will manages the dependencies:
Go to your project directory (Eg:E:\xampp\htdocs\cakephp) in command promot and type following:
composer require "paypal/rest-api-sdk-php:*"
This will install latest version of paypal sdk into the vendor folder,you can go into vendor and check that.
2. Configure your environment:
Make any function for configuration of paypal in any controller you would like:
public function configuration() {
$apiContext = new \PayPal\Rest\ApiContext(
new \PayPal\Auth\OAuthTokenCredential(
'YOUR APPLICATION CLIENT ID', // you will get information about client id and secret once you have created test account in paypal sandbox
'YOUR APPLICATION CLIENT SECRET'
)
);
}
As you are using cakephp framework you don't need to write following line into your function as suggested in papal documentation:
// Autoload SDK package for composer based installations
require 'vendor/autoload.php';
This is because you have already done that with autoload.php file within your vendor folder.
3. Using paypal classes:
You need to use paypal classes/namespace within your controller in this way:
namespace App\Controller; // your controller have this already
use App\Controller\AppController; // your controller have this already
use PayPal\Api\Payer;
use PayPal\Api\Item;
use PayPal\Api\ItemList;
4. Completely follow this quick start guide which will be pretty straight forward now:
Paypal quick start guide.
For making sandbox test accounts:(Paypal developer guide)

I recommend using : omnipay
https://packagist.org/packages/omnipay/paypal
or this add to your composer.json
{
"require": {
"omnipay/paypal": "~2.0"
}
then
$ curl -s http://getcomposer.org/installer | php
$ php composer.phar update
if windows
composer update

Related

Ionic Cloud for angularjs projectcs created using Yeoman Ionic

How to use Ionic Cloud in AngularJs - Ionic Projects generated using generator-ionic
While it is straight forward to use Ionic Cloud services in an angular app, it is not working in apps generated using yeoman ionic generator. It is because of the packaging steps followed by it. How to make those projects to work with Ionic Cloud?
Ionic Platform:
Build, push, deploy, and scale your Ionic apps, the easy way.
Title Description:
The Ionic Platform is a cloud platform for managing and scaling cross-platform mobile apps. Integrated services enable you and your team to build, deploy, and grow your apps efficiently.
Document Objective:
Ionic Platform works well with the standard Ionic projects. But projects following any Non-standard Directory Structure may face a few hurdles. This documents provides the steps to use Ionic Platform in the Ionic projects created using Yeoman.
Document Scope:
This document covers the basic steps for creating an Ionic project using Yeoman and integrating it with Ionic Platform using the Ionic Platform Web Client. This document covers the basic steps to utilize Ionic Deploy, Ionic Analytics and Ionic Push.
Intended Audience:
The intended audience for this document is Web/Mobile App developers, with both beginner and expert level expertise, who are familiar with the below Prerequisites.
Prerequisites:
You should be familiar with the following frameworks/tools before trying this document.
AngularJs: https://docs.angularjs.org/guide
IonicFramework: http://ionicframework.com/docs/guide
Yeoman: http://yeoman.io/codelab/index.html
Ionic Generator: https://github.com/diegonetto/generator-ionic
Ionic Platform: https://ionic.io/platform
Ionic Framework generator
A generator for the Ionic Framework from Yeoman, the Web's Scaffolding tool for modern webapps
Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine. npm is the package manager for JavaScript. Download and install Node (and npm) from http://nodejs.org
$ npm install npm –g
$ npm install -g yo
Yeoman helps you to kick-start new projects, prescribing best practices and tools to help you stay productive.
$ yo ionic [app-name]
In package.json include the following in devDependencies
"grunt-string-replace": "^1.2.1"
In bower.json include the following in dependencies
"ionic-platform-web-client": "^0.7.1"
In Gruntfile.js change the scripts folder to ‘js’. Change in index.html too if required.
grunt.initConfig({ yeoman: {………… scripts: 'js', ………… } })
Then run
$ bower install && npm install
$ grunt$ grunt serve$ cordova platform add android $ grunt build:android --debug
ionic-platform-web-client
A web client that provides interactions with the Ionic platform.
We need some code to let your app talk to the Ionic Platform. We need to add the Ionic platform web client for the Ionic app to interface with the plugins and the Ionic.io platform.
$ ionic io init
In your app.js add the ‘ionic.service.core’ module dependency. In Gruntfile.js add the grunt task ‘ionicSettings’ as given below.
grunt.initConfig({
ionicSettings:JSON.stringify(grunt.file.readJSON('./.io-config.json')),
ionicIoBundlePath:'www/bower_components/ionic-platform-web-client/dist/ionic.io.bundle.min.js',
'string-replace':{
ionicSettings:{
files:{
'<%= ionicIoBundlePath %>':'<%= ionicIoBundlePath %>',
},
options:{
replacements:[
{
pattern:'"IONIC_SETTINGS_STRING_START";"IONIC_SETTINGS_STRING_END"',
replacement:'"IONIC_SETTINGS_STRING_START";var settings =<%= ionicSettings %>; return { get: function(setting) { if (settings[setting]) { return settings[setting]; } return null; } };"IONIC_SETTINGS_STRING_END";'
}
]
}
}
},
copy:{
ionicPlatform:{
expand:true,
cwd:'app/bower_components/ionic-platform-web-client/dist/',
src:[
'**'
],
dest:'www/bower_components/ionic-platform-web-client/dist'
}
}
});grunt.registerTask('ionicSettings',
[
'copy:ionicPlatform',
'string-replace:ionicSettings'
]);
Add the 'ionicSettings' in init and compress tasks after copy.
In index.html move the below tag after all the tag declarations.
<script src="bower_components/ionic-platform-web-client/dist/ionic.io.bundle.min.js"></script>
Then run
$ Grunt serve
Ionic Deploy
Push real-time updates to your production apps, and manage version history.
Ionic Deploy lets you update your app on demand, for any changes that do not require binary modifications, saving you days, or even weeks, of wait time. Follow the below procedure to configure Ionic Deploy for your App.
In Gruntfile.js add the grunt task ‘deploy’ as given below.
grunt.registerTask('deploy',
function (){
return grunt.task.run( [
'init',
'ionic:upload' + this.args.join()
] );
});
then run
$ ionic plugin add ionic-plugin-deploy
Ionic Deploy Code:
var deploy = new Ionic.Deploy();// Check Ionic Deploy for new codedeploy.check().then(function(hasUpdate){
},
function(err){
});// Update app code with new release from Ionic Deploydeploy.update().then(function(result){
},
function(error){
},
function(progress){
});
Deploying Updates:
Send out new code for your app.
Create an apk and install your app. Make few changes in your code and deploy the changes using 'grunt deploy'. Then update it from your app.
You can also deploy it from the apps.ionic.io dashboard. You can deploy the app without the deploy parameter. Then, in the dash board you can add the metadata and versioning details and deploy the app from there.
$ grunt build:android --debug
$ grunt deploy --note "release notes"
$ grunt deploy --note "release notes" --deploy=production
Ionic Analytics
View the live feed of events or the raw / unique number of events / users over time.
How many users are on your app right now? How many of those will use your app tomorrow, or next week? Without information, you have no way of telling if your app is being used in the ways that you expect. Follow the below procedure to configure Ionic Analytics for your App.
In your app.js add the ‘ionic.service.analytics’ module dependency after the ionic.service.core
Run the analytics register method in our module's run function.
$ionicAnalytics.register();
In Ionic Analytics, each tracked action a user makes in your app is represented by an event object. An event is a single action done at a specific point in time. To track your own events, call $ionicAnalytics.track(eventType, eventData) whenever an action occurs.
$ionicAnalytics.track('User Login', { user: $scope.user});
The ion-track-tap directive sends an event when its host element is tapped. The associated ion-track-data directive attaches event data.
<button ion-track-tap="eventType" ion-track-data="expression"></button>
In the apps.ionic.io dashboard you can view the following analytics data,
Events: View the raw number of events over time, or the number of unique users who completed an event. An event can be anything from a user loading the app, to confirming a purchase.
Funnels: A funnel is a sequence of actions that you expect users to take in your app, leading up to a defined goal. Thoughtful use of funnels will let help you improve conversion rates.
Segments: View events over time, grouped by a specified property. Or, calculate the percentage of events that match a given property. Segments helps you understand your user base and see how properties change over time.
Retention: Track how long users are active on your app before they stop using it. Or, identify how long it takes for users to reach a defined goal, like a completed sale.
Pulse: A live feed of events coming in from your users.
Ionic Push
Send targeted and automated push notifications to your users.
Ionic Push lets you create targeted push notifications through a simple dashboard that will be sent automatically when users match specific criteria, and offers a simple API to send push notifications from your own servers.
Android Push Profiles:
Android push notifications use the Google Cloud Messaging (GCM) service. Open the Google Developers Console and create a project. Copy down your project number. This will be the GCM sender ID or GCM Project Number.
In the API Manager section, enable the Google Cloud Messaging API. Then navigate to Credentials section and select Create credentials, then choose API Key, then Server Key. Name your API key and leave the Accept requests from... field blank and click Create. Save your API key!
Authentication:
Go to your app's dashboard on the Ionic Platform and navigate to Settings -> Certificates. If you haven't already, create a new security profile, then hit edit. Note down the Profile Tag.
Now, click the Android tab and find the section marked Google Cloud Messaging, enter the API Key you generated on the Google Developer Console, then click Save. Go to Settings -> API Keys. Under API Tokens, create a new token and copy it. This will your API Token.
$ ionic plugin add phonegap-plugin-push --variable SENDER_ID="GCM_PROJECT_NUMBER"
$ ionic config set gcm_key <your-gcm-project-number>
$ ionic config set dev_push false$ ionic io init
Note: phonegap-plugin-push requires Android Support Repository version 32+
In your app.js add the ‘ionic.service.push’ module dependency after the ionic.service.core
Ionic Push Code:
Initialize the service and register your device in your module's run function. You'll need the device token that is registered by the user for sending notification to the user.
$ionicPush.init({
debug:true,
onNotification:function (notification) {
console.log'token:', notification.payload); }, onRegister: function (token) { console.log(' Device Token:',
token); $ionicPush.saveToken(token); // persist the token in the Ionic Platform
}
});
$ionicPush.register();
then run
$ grunt build:android --debug
Ionic Push lets you create targeted push notifications through the dashboard. You can also send notifications from the server in the below format.
curl -X POST -H "Authorization:Bearer API_TOKEN" -H "Content-Type:application/json" -d '{
"tokens":[
"DEVICE_TOKEN"
],
"profile":"PROFILE_TAG",
"notification":{
"message":"Hello World!" "android":{
"title":"Hi User",
"message":"An update is available for your App",
"payload":{
"update":true
}
}
}
}'"https://api.ionic.io/push/notifications"
Note: The steps to configure Ionic Push for iOS is the same except for creating the Push Profiles. To create iOS push profiles refer http://docs.ionic.io/v2.0.0-beta/docs/ios-push-profiles

Prestashop PayPal module won't save settings

After I install the module and complete my API credentials I click the "save" button and I always get the following error:
Error !
You need to complete the PayPal identification Information in step 3
otherwise you won't be able to accept payment.
I already uninstalled and reinstalled the module.
PrestaShop version: 1.6.1.4
PayPal version: 3.10.6
Because of You install module that is unknown if it support PayPal's latest changes or not.
Seems like when You click save button it send CURL request to PayPal and tires to get necessary data. But response is not same as supposed to be.
If You're PHP dev: You've to debug that module,
otherwise: find someone to fix it.

PayPal Express Checkout Configuration in osCommerce 2.3

I am setting up a website using osCommerce 2.3. The site is close to completion so I set up a PayPal sandbox to test the transaction/payment process. I am using the PayPal Express Checkout module provided with osCommerce. I inserted the sandbox username, password and signature into the module and tried the credentials test link. The test failed and the test debug email showed that no data was being transmitted by either $_GET or $_POST. Where do I go from here?
It turns out I am using WampServer 2.2.22, a 64-bit version which contains a buggy version of the curl.dll. Curl was refusing to load, so when it was making the call to PayPal in the sendTransactionToGateway function in paypal_express.php, the function failed. Working 64-bit versions of curl can be found at http://www.anindya.com/ for php 5.3.13 and 5.4.3. Replacing the old version of curl with the new one and restarting wampserver did the trick.

Grails Facebook-Graph Plugin Oauth2

We have been using the Grails Facebook-graph plugin for a while now - it has been working perfectly until earlier this month when FB apparently turned off their old authentication scheme, and indirectly forced everybody to use oauth2 instead.
This post from FB https://developers.facebook.com/blog/post/525/ describes the changes, and the issue in the Grails plugin seems to be that it does not comply with the new standard.
The main issue appears to be in the way the active user data is being maintained in the plugin. This is currently based on the FB provided cookie "fbs", which contains all the necessary session data related to the active user. Unfortunately, this is no longer provided by FB (apparently replaced by a "fbsr" cookie instead).
I have searched the FB documentation, and in various forums for details on how to upgrade the plugin, but unfortunately without luck.
Can anyone help with a hint or two on what steps should be performed in order to get the plugin updated?
EDIT: I think the updated version of the plugin (0.14) has been pushed the public repository. You should try grabbing that one first before reading the rest of my answer.
It looks like the plugin maintainer, Jesus Lanchas, made some updates over the last few days to enable oauth2 support. It has not been pushed to the plugin repository yet, but I was able to get it working with my project. Here's what I did:
#Install a local copy of the plugin WITHIN my project
mkdir plugins-local
cd plugins-local
git clone git://github.com/chechu/grails-facebook-graph.git
mv grails-facebook-graph facebook-graph
Update BuildConfig.groovy and tell grails where to load the plugin from. I put this line before grails.project.dependency.resolution
grails.plugin.location.'facebook-graph' = "plugins-local/facebook-graph"
Uninstall the existing facebook-graph plugin from my project
grails uninstall-plugin facebook graph
This is a temporary solution for me until the offical update hits the repo, but it allows me to make sure I'm using the same new code everywhere.
EDIT: we released our Facebook Grails SDK on GitHub :
https://github.com/benorama/facebook-grails-sdk.
Currently only tested on Grails 2.0…
Any feedback is welcome before we release it officially to Grails.org.
Indeed, it looks like Grails Facebook-graph plugin does not support OAuth2 Facebook authentication (which is required since October 1st 2011).
We have already ported the official PHP SDK V3.1.1 to ColdFusion 9 (https://github.com/affinitiz/facebook-cf-sdk).
Last month, we started to implement it as a plugin in Grails 2.0.
It is currently at an alpha stage so we have not released it yet, but it is working on our prototype.
To connect to the Facebook Graph API, it uses RestFB internally.
If you want to give it a try and give us some feedbacks, let me know, I'll sent it to you by email.

Check if facebook oauth 2.0 october 1st migration is done

I'm using facebook connect on a website, it worked well with PHP SDK 3.0.1.
Now I've downloaded and started using PHP SDK v.3.1.1 and set Encrypted Access Token to enabled. It still works without problems. Is this enough for the migration? How can I check it? I don't use the js sdk.
According to the migration guide, it looks like you have done all the steps you need for Facebook on an external website by upgrading to 3.1.1 PHP SDK and set encrypted access token.
If you were hosting a fan page or app inside Facebook you would also need an SSL certificate. And there are several code changes required if you are using the javascript SDK which you say you aren't.