angelleye / paypal-php-library Goto Github PK
View Code? Open in Web Editor NEWPHP PayPal SDK Class Library for Classic APIs
Home Page: http://www.angelleye.com
PHP PayPal SDK Class Library for Classic APIs
Home Page: http://www.angelleye.com
Added in version 112.0.
"Added the optional field UseSessionPaymentDetails to the DoExpressCheckoutPayment (NVP | SOAP) API operation. This flag allows merchants to specify if the payment details information passed in SetExpressCheckoutDetails should be used instead of the payment details passed in DoExpressCheckoutPayment."
Apparently this will allow you to keep from having to repeat all the same details in DECP that you include in SEC, which is nice.
That can already be used with the library. I just need to add it to the template with notes.
Create a sample that expands on #32 and adds line items to the Express Checkout flow.
The line items should just be static values stored in an array for easy updating. Should include at least 2 items on the sample.
$order_items = array();
$item = array(
'name' => 'Widget 456', // Item name. 127 char max.
'desc' => 'Widget 456', // Item description. 127 char max.
'amt' => '40.00', // Cost of item.
'number' => '456', // Item number. 127 char max.
'qty' => '1', // Item qty on order. Any positive integer.
'taxamt' => '', // Item sales tax
'itemurl' => '', // URL for the item.
'itemcategory' => '', // One of the following values: Digital, Physical
'itemweightvalue' => '', // The weight value of the item.
'itemweightunit' => '', // The weight unit of the item.
'itemheightvalue' => '', // The height value of the item.
'itemheightunit' => '', // The height unit of the item.
'itemwidthvalue' => '', // The width value of the item.
'itemwidthunit' => '', // The width unit of the item.
'itemlengthvalue' => '', // The length value of the item.
'itemlengthunit' => '', // The length unit of the item.
'ebayitemnumber' => '', // Auction item number.
'ebayitemauctiontxnid' => '', // Auction transaction ID number.
'ebayitemorderid' => '', // Auction order ID number.
'ebayitemcartid' => '' // The unique identifier provided by eBay for this order from the buyer. These parameters must be ordered sequentially beginning with 0 (for example L_EBAYITEMCARTID0, L_EBAYITEMCARTID1). Character length: 255 single-byte characters
);
array_push($order_items, $item);
Right now the WarningsReturned() method is only checking for SUCCESSWITHWARNING. Need to check for FAILUREWITHWARNING, too.
Should probably just use something like strpos() to check for any "failure" at all.
Need to create a mask function to be used when saving API logs for PayFlow.
Would need to always mask the user, password, vendor, partner, cc number, exp date, security code.
Add GetUserAgreement to Adaptive class
Need to get templates setup for PayFlow gateway Express Checkout flow.
We can use our own PayFlow template, of course, and we'll just need to setup all the calls necessary to complete the Express Checkout flow outlined in this documentation: https://www.paypalobjects.com/webstatic/en_US/developer/docs/pdf/pfp_expresscheckout_pp.pdf
Our template / sample names can be PayFlow_SetExpressCheckout.php, PayFlow_GetExpressCheckoutDetails.php, PayFlow_DoExpressCheckoutPayment.php, etc.
I have a use-case where merchant needs to give me certain permissions for me to call APIs on their behalf. RequestPermissions
and GetAccessToken
APIs are working fine, and I can get access token + secret, but there is no way for me to actually utilize this access token within this library.
For example, I can't get merchants personal data (using GetBasicPersonalData
and GetAdvancedPersonalData
) even though I have valid permissions because X-PAYPAL-AUTHORIZATION
header is not being used at all.
Basically what's needed to be added to the library is function to generate value for X-PAYPAL-AUTHORIZATION
, and then to simply adjust CURLRequest()
functions in both PayPal
and PayPal_Adaptive
classes.
Sir ,
I really appreciate your work.
I just want to you to please make available webhook PHP file . So that it will be helpful for everyone who wants to implement webhook using API.
Add IPN template/listener to the class library.
Express Checkout looks to have new fields that I don't yet have setup in the templates and samples provided with the library. Need to get these added.
How is the code suited for the new SSLv3 Vulnerability that came out? That being said Paypal just sent out emails stating that on Dec. 3rd they will no longer support SSLv3, only TLS.
Does the curl of the Code connect through SSL or TLS? If SSL when do you expect new code to be made and pushed that supports TLS?
Basic checkout flow with Express Checkout for demonstration purposes.
Use Bootstrap for the pages so that they have a basic responsive design.
This initial sample can be a bare bones sample for Express Checkout with only the required details to get it working. No need to do line items or any un-required details, although it might make sense to still include line items on the checkout page so it looks like a shopping cart.
Sample flow...
On line 2494 of Adaptive.php $AccountType
is set, however the var is not added to the $ResponseDataArray
. Simply inserting 'AccountType' => $AccountType,
on line 2512, for example, fixes the problem.
UpdateAuthorization was added in version 104.0: https://developer.paypal.com/webapps/developer/docs/classic/release-notes/merchant/PayPal_Merchant_API_Release_Notes_104/
Expand on #39 to create a single checkout with multiple receivers.
Our shopping cart page in this case should show that 1 item is being purchased from "source A" and another item is being purchased from "source B".
Then the EC API calls will include 2 separate $Payments on the same checkout.
Need to go through documentation and check for any new features added to API's, get them applied to the library, and then update the default version to 119.0.
Need to add specific Pay samples for different types of checkout flows.
Need to make sure the Pay samples use the PayWithOptions() method so that the BN code is included.
Right now I have the BMButtonSearch call included, but nothing else in regard to the BM API. Need to go ahead and add in the rest of the API calls.
Right now the verbose option in cURL is hard-coded to 1/true. Need to set this based on $this->Sandbox instead so that it will be true for test mode and false for production.
Need to add some methods for creating simple Payments Standard HTML forms/buttons.
The option to print headers is already included in the BuildHeaders function, but it's not passable from the script using the class. Need to make this an option that the developer can use easily.
Need to add the following.
$PayPalRequestData = array(
'ActivationDetails' => $ActivationDetails, // This array is missing in the sample for CreateRecurringPaymentsProfile.php
'ProfileDetails' => $ProfileDetails,
'ScheduleDetails' => $ScheduleDetails,
'BillingPeriod' => $BillingPeriod,
'CCDetails' => $CCDetails,
'PayerInfo' => $PayerInfo,
'PayerName' => $PayerName,
'BillingAddress' => $BillingAddress
);
Refer to #48
This change caused our app to start launching "Undefined index: Account Id" messages. It would have been better to check those variables with empty() instead of comparing with != '' to avoid non desired notices when the Account Id wasn't sent, specially in this case that it was added in a minor version change
Need to get the CreateAccount API updated to match currently existing parameters.
Expands on #39 to turn the checkout into a signup for a subscription / recurring payments.
I test MassPay in sandbox but returned array have ACK = Failure and raw response have ACK = Success. And MassPay is sent on account, so returned array have bad data.
Array
(
[TIMESTAMP] => 2014-10-05T17:45:11Z
[CORRELATIONID] => f1606e20d0b1e
[ACK] => Failure
[VERSION] => 112.0
[BUILD] => 13154493
[ERRORS] => Array
(
)
[REQUESTDATA] => Array
(
[USER] => xxx
[PWD] => xxx
[VERSION] => 112.0
[BUTTONSOURCE] => AngellEYE_PHPClass
[SIGNATURE] => xxx
[METHOD] => MassPay
[EMAILSUBJECT] => API Test payment
[CURRENCYCODE] => USD
[RECEIVERTYPE] => EmailAddress
[L_EMAIL0] => [email protected]
[L_AMT0] => 1.23
[L_EMAIL1] => [email protected]
[L_AMT1] => 1.45
)
[RAWREQUEST] => USER=xxx&PWD=xxx&VERSION=112.0&BUTTONSOURCE=AngellEYE_PHPClass&SIGNATURE=xxx&METHOD=MassPay&EMAILSUBJECT=API+Test+payment&CURRENCYCODE=USD&RECEIVERTYPE=EmailAddress&L_EMAIL0=user%40domain.com&L_AMT0=1.23&L_EMAIL1=user2%40domain.com&L_AMT1=1.45
[RAWRESPONSE] => TIMESTAMP=2014%2d10%2d05T17%3a45%3a11Z&CORRELATIONID=f1606e20d0b1e&ACK=Success&VERSION=112%2e0&BUILD=13154493
)
On console : 'ErrorException' with message 'Undefined index: SERVER_PORT' in angelleye/paypal-php-library/src/angelleye/PayPal/PayPal.php:80
Console scripts don't have a $_SERVER['SERVER_PORT'] variable.
I've got inline comments for parameters in the template files, but I don't really have any notes about what exactly each API does in the class files. Need to add that from the PayPal docs for each.
I have done this for UpdateAuthorization already if I need to refer back to a sample of what I mean.
Need to add Payments Advanced. The WooCommerce plugin has good examples of the API requests necessary to get this done, so I just need to replicate that functionality within this library.
When I first use the Library, I receive errors about the following files being missing;
paypal.access.class.php
paypal.here.class.php
Commenting out the includes in paypal.class.php lets the library (seemingly) work correctly.
Hi Andrew,
Congratulations on the new class, I am using it on codeigniter and works perfectly.
I would like to suggest a small change
Replace (end of function MaskAPIResult($api_result))
$api_result = '';
foreach($api_result_array as $var => $val)
{
$api_result .= $var.'='.$val.'&';
}
$api_result_length = strlen($api_result);
$api_result = substr($api_result,0,$api_result_length-1);
for
$api_result = http_build_query($api_result_array);
I do believe that you could replace many of the foreach loops that you have on this class with the http_build_query, as the foreach usage is to create the url to send to paypal.
I used to use the same method until I found this php function.
All the best,
Hortênsio
Need to figure out the best way to implement the REST API into this library.
When I moved /includes/config-sample.php to /samples I forgot to adjust all of the template files. They're still pointing to /includes/config.php, which no longer exists.
Need to add a separate config file for the samples and templates to use. In fact, in the templates I should probably add them as something like...
include_once('/path/to/config/file.php');
Need to build this into the Express Checkout flow. It would go in DoExpressCheckoutPayment. Just need to check for the 10486 error, and if that's what we get simply redirect back to the original RedirectURL that was used after calling SetExpressCheckout.
SEC is already returning a RedirectURL for the developer to use. Need to make this available in DECP one way or another.
Right now I have a Logger() method that is using a hard-coded file path. Need to enable the ability to set your own file path as well as enable/disable logging altogether.
Need to add Logger() to each API call method. The Logger() method can check $this->EnableLogging (which needs to be passed in to the constructor with the other config data) within it so that it only logs if it is enabled.
https://access.redhat.com/articles/1232123
Need to change to TLS instead of SSL for cURL requests.
Hi,
Will it be possible to add a filter in the first line of the Angelleye_PayPal constructor that's in /plugins/paypal-for-woocommerce/classes/lib/angelleye/paypal-php-library/includes/paypal.class.php ?
You can make it all lowercase if you want.
$DataArray = apply_filters( 'Angelleye_PayPal_Construct_Params', $DataArray );
I am working on a client project and I need to switch between different paypal accounts based on certain conditions.
class Angelleye_PayPal
{
var $APIUsername = '';
var $APIPassword = '';
var $APISignature = '';
var $APISubject = '';
var $APIVersion = '';
var $APIButtonSource = '';
var $APIMode = '';
var $EndPointURL = '';
var $Sandbox = '';
var $PathToCertKeyPEM = '';
var $SSL = '';
/**
* Constructor
*
* @access public
* @param array config preferences
* @return void
*/
function __construct($DataArray)
{
$DataArray = apply_filters( 'Angelleye_PayPal_Construct_Params', $DataArray );
................................
Add functions to output Payments Standard buttons/forms.
Sample of Express Checkout where a customer uses redeemable offers through their PayPal wallet.
This feature is being added to the library in #45.
Expands on #41 to turn the checkout into a hybrid of shipped items through DECP and a subscription item through RP.
This may be a recent addition by PayPal, but Adaptive Payments now includes the option to require the user to have an instant funding source on account, per documentation at: https://developer.paypal.com/webapps/developer/docs/classic/api/adaptive-payments/Preapproval_API_Operation/. This can be implemented by adding the following:
Adaptive line 1372:
$RequireInstantFundingSource = isset($PreapprovalFields['RequireInstantFundingSource']) ? $PreapprovalFields['RequireInstantFundingSource'] : '';
Adaptive (altered) line 1415:
$XMLRequest .= $RequireInstantFundingSource != '' ? '<requireInstantFundingSource xmlns="">' . $RequireInstantFundingSource . '</requireInstantFundingSource>' : '';
Thanks!
I ran into a CURL configuration problem while running on centos:
http://bugs.centos.org/view.php?id=5620
I changed line 617 to:
curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, "rsa_rc4_128_sha");
The CURL call started working again afterward - but I don't know if this is what you want in your source. Thank you so much for your work!
I thought I had these all removed but somebody pointed out I missed some in the Adaptive class. Need to double check everything and get these all out of there.
The comments next to the request params were copied from the CancelInvoice template and weren't updated, so they still say "cancelation" instead of "reminder".
Simple fix, just need to adjust the comments.
Need to add doc blocks and comment everything so that phpDocumentor can work with it nicely.
Once that's done, install and run phpDocumentor to generate the docs for the library.
Expands on #39 to turn the checkout into a Digital Goods checkout with an embedded payments flow.
Expand on #32 to show that EC can be used to send the payment to 3rd party accounts (an account that is not the same as the API credentials used in the calls) without the need for setting up permissions.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.