DavidCampbell
-
Posts
37 -
Joined
-
Last visited
-
Days Won
4
Content Type
Profiles
Forums
Events
Downloads
Gallery
Store
Posts posted by DavidCampbell
-
-
No worries Stef, I'll write up some instructions. I have it all working as expected.
- 1
-
bug fixed:
here is my new checkout.php
<?php include('app/init.php'); if(isset($_POST)) { // create Payment Object include('app/models/m_payments.php'); $Payments = new Payments(); // get item data $items = $Cart->get(); // get details $details['subtotal'] = $Cart->get_total_cost(); $details['shipping'] = 0; foreach ($items as $item) { $details['shipping'] += $Cart->get_shipping_cost($item['price']); } $details['shipping'] = number_format($details['shipping'], 2, '.', ''); $details['tax'] = number_format($details['subtotal'] * SHOP_TAX, 2, '.', ''); $details['total'] = number_format( $details['subtotal'] + $details['shipping'] + $details['tax'], 2, '.', ''); // send to PayPal $error = $Payments->create_payment($items, $details); if ($error != NULL) { $Template->set_alert($error, 'error'); $Template->redirect('cart.php'); } } else { $Template->redirect('cart.php'); }
note the changes to number_format() where appropriate.
- 1
-
Any progress on this course idea?
I've been doing JAVA, and it wasnt until I started learning Java that I really "got" programming. I had played with PHP before that.
Anyway I fully intend to become a good Java programmer, because it's the highest paying here in the UK. If freelancing/being an entrepreneur doesn't work out. Although a computer science degree seems to be required for a lot of these Java jobs.
-
Well I've kinda got it working, only it doesnt like me buying 10 TV's LOL. I can buy 2 headphones though, so not sure whats going with the quantity bug.
This is the error I get:Fatal error: Uncaught exception 'InvalidArgumentException' with message 'Total is not a valid numeric value' in /Volumes/5TB_Seagate/htdocs/phpCart/app/vendor/paypal/rest-api-sdk-php/lib/PayPal/Validation/NumericValidator.php:23 Stack trace: #0 /Volumes/5TB_Seagate/htdocs/phpCart/app/vendor/paypal/rest-api-sdk-php/lib/PayPal/Api/Amount.php(54): PayPal\Validation\NumericValidator::validate('3,302.39', 'Total') #1 /Volumes/5TB_Seagate/htdocs/phpCart/app/models/m_payments.php(132): PayPal\Api\Amount->setTotal('3,302.39') #2 /Volumes/5TB_Seagate/htdocs/phpCart/checkout.php(31): Payments->create_payment(Array, Array) #3 {main} thrown in /Volumes/5TB_Seagate/htdocs/phpCart/app/vendor/paypal/rest-api-sdk-php/lib/PayPal/Validation/NumericValidator.php on line 23
-
Actually this link here seems to be the most relevant so far: https://paypal.github.io/PayPal-PHP-SDK/sample/doc/payments/CreatePaymentUsingPayPal.html
Which is the top link on this page: https://paypal.github.io/PayPal-PHP-SDK/sample/
Seems to be an online version of the locally installed PayPal sample used in the tutorial.
-
OK I think i've just discovered the new place under API Explorer which takes you to here https://www.paypal.com/apex/product-profile/expressCheckout/getAccessToken (the second image).
I haven't confirmed it by going through the steps, but it looks promising.- 1
-
No worries Stef, I'm on this vid right now "Steps to Submitting a Payment" and it is hard to find the equivalent area on developer.paypal.com in order to generate the JSON like the vid is doing. Yeah it really needs an update. I was hoping to wrap this course up.
Anyway it's been good so far getting my head into this whole MVC with PHP. Up to now I've only used PHP procedurally.I'll keep poking around and see if I can get this paypal sorted.
- 1
-
I've just found the download for the sdk here 0.7.1 - scroll down you'll see it. I've not tested it yet.
https://github.com/paypal/PayPal-PHP-SDK/releases?after=v0.11.0 -
I've just found the download for the sdk here 0.7.1 - scroll down you'll see it. I've not tested it yet.
https://github.com/paypal/PayPal-PHP-SDK/releases?after=v0.11.0- 1
-
Seems like the course is out of date again in December 2018. I've got as far as creating the sandbox accounts. Yet can't find the sample SDK to download as it's not on GitHub as the video shows. So came here looking for answers.
I shall persevere, because I need to get paypal up and running.
I too signed up mainly to learn paypal integration.
Paypal Integration - Php Shopping Cart Tutorial
in PHP
Posted · Edited by DavidCampbell
Videos:
Composer Introduction & SDK Setup
PayPal Settings & Minor Changes
Steps to Submitting a Payment
Integrating PayPal Part 1
Integrating PayPal Part 2
Integrating PayPal Part 3
Integrating PayPal Part 4
On the whole the videos can be followed, but there are few red herrings on the way. And unnecessary distractions.
Composer Introduction & SDK Setup
Forget Composer, this is an unnecessary distraction and just confuses things, maybe mention Composer at the end of the tutorial as an alternative method for installing the SDK.
Get the SDK hosted on Github from here: https://github.com/paypal/PayPal-PHP-SDK/releases
I used the 1.13.0 zip (latest version) from this page and it works fine. To follow the videos you would rename the uncompressed SDK folder to 'vendor' and place it in the /app directory.
The 'samples' are slightly different. They are now hosted online here" https://paypal.github.io/PayPal-PHP-SDK/sample/
Only one sample is actually used in the tutorial, this one: https://paypal.github.io/PayPal-PHP-SDK/sample/doc/payments/CreatePaymentUsingPayPal.html
as you can see it looks virtually the same.
If you want to host the samples locally, you can still do that. Go to the main SDK repository on Github https://github.com/paypal/PayPal-PHP-SDK
you can see the samples directory is there. I did however have trouble downloading directly from here. For some reason when you hit the clone/download button and download from here the zip is missing files and directories you'd expect to be there, including the samples directory. I have no clue why this is. I managed to work around this problem by forking the repository and using the GitHub desktop app to clone my fork to my local drive. It was then fairly simple to drag the 'samples' directory out and host that with my MAMP/LAMP.
PayPal Settings & Minor Changes
Do the changes to init.php etc
Then the first step really is to goto https://developer.paypal.com/ log in and go to the dashboard (it all looks very different, but it's essentially doing the same job as before). Scroll down to REST API apps and create a new App. A client ID, secret and two test accounts (buyer and facilitator) are created automatically. Continue and make the changes to init.php, v_public_cart.php, success.php, v_public_success.php and m_payments.php etc.
Steps to Submitting a Payment
This video is a bit confusing now, as the interactive guide is not the same. The vid really needs to be just a simple explanation of the steps used with paypal.
Integrating PayPal Part 1
Integrating PayPal Part 2
Integrating PayPal Part 3
Integrating PayPal Part 4
Once all the above is sorted you can follow these video's pretty much verbatim, only there are some subtle differences with the bootstrap.php file that you'll be copying from. It's easier to just look at my m_payments.php file:
As you can see it's almost the same, just some subtle difference at the bottom with the re-directs and the try/catch.
I did have to fix that bug that was a result of a comma being in the amount (see earlier post for the fix).
Anyway I think that was everything.
Dave