Wonder if anyone have tried successfully the Paypal demo code`s ?
My self is trying to get the Express Checkout Flow into my custom php, and downloaded the NVP / SOAP Code Samples from https://demo.paypal.com/us/demo/download?capability=checkOutWithPaypal&lang=PHP
After input of my sandbox account details, it works very well, in-fact just as hoped. But (always a but), it seems that this setting from paypal_config.php do not work as it should be:
//Set this constant USERACTION_FLAG = true to skip review page
define("USERACTION_FLAG", false);
//Based on the USERACTION_FLAG assign the page
if(USERACTION_FLAG){
$page = 'return.php';
} else {
$page = 'review.php';
}
If you try to set that to true, when directing from Paypal, you just comes to an white page.
Anyone got this to work as it should do?
Since its an express checkout, there shouldt be needed for another "review" page, just hit Pay, and done!
Tried to locate all functions in the files, but the $page string is not anywhere to be found else than config file.
Thanks for all answers :)
Related
I'm using PayPal and want to add the payment method SEPA on my current website.
Here are some examples I have followed:
https://developer.paypal.com/docs/checkout/integration-features/standalone-buttons/#funding-sources
https://demo.paypal.com/de/demo/go_platform/pcRestServerV2/paymentOptions
So basically I'm not getting SEPA button as displayed here on above 2nd link.
Here is my code that helps you to identify what I'm doing wrong.
var FUNDING_SOURCES = [
paypal.FUNDING.PAYPAL,
paypal.FUNDING.VENMO,
paypal.FUNDING.CREDIT,
paypal.FUNDING.CARD,
paypal.FUNDING.SEPA,
];
FUNDING_SOURCES.forEach(function(fundingSource) {
// Initialize the buttons
var button = paypal.Buttons({
fundingSource: fundingSource
});
// Check if the button is eligible
if (button.isEligible()) {
// Render the standalone button for that funding source
button.render('#paypalCheckoutContainer');
}
});
Is there a reason you are checking for and rendering particular funding sources? You can let PayPal handle that automatically instead of a forEach loop. Basically, use the simpler code at; https://developer.paypal.com/demo/checkout/#/pattern/client
If you are not located in a country that defaults to showing SEPA, add &buyer-country=DE to the SDK script query string line when testing in sandbox mode. Only do this for testing other countries in sandbox mode, it is not a valid parameter in live. The buyer's country will be auto detected in live.
I have two payment pages for different things. One of them works great and posts the cart to PayPal like it should, the other one shows an empty cart regardless. I've looked through the url string I'm sending to and these are the only arguments that are different:
Works:
&item_name_1=Add+Seats+-+Keynote+Manager
&item_number_1=Add+to+License
&amount_1=68
&quantity_1=1
¬ify_url=http%3A%2F%2Frevolutiondesign.biz%2FIPNBroker.php%3Fkey%3DAZHJ0T1U05V1W1XY8G1C3C3XP3IMF2N2PP%26extendYears%3D0%26newSeats%3D1%26addPortable%3D%26newFeatures%3D
&custom=upgrade
&key=AZHJ0T1U05V1W1XY8G1C3C3XP3IMF2N2PP
&extendYears=0
&newSeats=1
&addPortable=
&addFeatures=
&qtyAddFeatures=0
&costAddFeatures=0
&qtyAddSeats=1
&costAddSeats=68
&qtyPortable=
&costPortable=
&qtyExtend=0
&costExtend=0
&v=63400
Doesn't:
&item_name_1=Add+Cloud+Seats
&item_number_1=Add+Cloud+Seats
&amount_1=94
&quantity_1=1
¬ify_url=http%3A%2F%2Frevolutiondesign.biz%2FIPNBroker.php%3FcustomerID%3Dba3d3c75-5e18-42b7-948e-3e34cccc1d9e%26extendPeriod%3Dmonths%26qtyExtend%3D1%26qtyAddSeats%3D1
&custom=cloudUpgrade
&cstID=ba3d3c75-5e18-42b7-948e-3e34cccc1d9e
&costAddSeats=97
&costExtend=7
&v=GREAT+Design+Group
&extend=1
&extendPeriod=months
&add=1
Is there any difference that anyone can see that would cause the second one not to work?
Ok through some process of elimination I finally identified the issue. The issue was in the presence of the variable called 'Add'. I was using that for the number of licenses the user wanted to add, but PayPal also has that as a variable for cart transactions which I did not realize. I pulled that post data into a php variable and then unset the post so it didn't pass to PayPal and it works now. I could also have renamed that post variable coming from my purchase page and I bet it would work as well.
OK, I've been banging my head against this for a few days now. I'm building a payment process into a PHP application which will allow for upselling products after a customer approves a payment.
I can get the payment charged to the customer without an issue, but if they select any kind of upsell product which requires the order value to change, then I get errors even though it is following to the letter what was in the documentation I could find...
Below is the test function I'm using, this is the function which is called when the user is redirected back to the website AFTER approving the payment.
public function confirmOrder($payer_id, $payment_id, $incentives = false){
//GET PAYMENT
$payment = Payment::get($payment_id, $this->apiContext);
//CREATE EXECUTION WITH PAYER ID
$execution = new PaymentExecution();
$execution->setPayerId($payer_id);
//APPLY PAYMENT AMOUNT - Original amount was 7.00
$amount = new Amount();
$amount = $amount->setCurrency('GBP')->setTotal('8.00');
//PATCH REPLACE
$patchReplace = new Patch();
$patchReplace = $patchReplace->setOp('replace')->setPath('/transactions/0/amount')->setValue($amount);
//CREATE PATCH OBJECT
$patchRequest = new PatchRequest();
$patchRequest = $patchRequest->setPatches(array($patchReplace));
try {
$payment->update($patchRequest, $this->apiContext);
} catch (PayPalConnectionException $ex) {
return "PATCH ERROR: State(" . $payment->getState() . ") ".$ex->getData();
}
}
This isn't the final code I will use but right now I'm just trying to get an order updated before I build in more of the logic. This code gives me the following error:
PATCH ERROR: State(created) {"name":"PAYMENT_STATE_INVALID","message":"This request is invalid due to the current state of the payment","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#PAYMENT_STATE_INVALID","debug_id":"9caacdc1d652b"}
You can see I'm outputting the getState() which is coming back as 'created' which would normally be fine for updating in everything I can find but it is still failing.
Does anyone else have experience with the PayPal PHP SDK and could help point me in the right direction?
In PayPal, once the user has approved the payment from the consent screen, the amount cannot be changed, as you can understand the user agreed to pay only the amount he/she saw on the consent screen. Modifying the amount after user approves it, is not allowed, and that's why you are seeing that state exception, as the state is already approved.
Anyway, looking at your scenario, I think you might be interested in either creating order, or capture, instead of sale.
Also, in our PayPal-PHP-SDK, there are a lot of interesting documents that could help you understand PHP-SDK better. We also provide a lot of runnable samples, that you could setup in your local machine, by one command only.
I've got a problem integrating PayPal Express Checkout. I want to disable the possibility to add a note to the buyer during the checkout process.
I'm using the PHP SOAP SDK (merchant-php-1.1.93_0.zip).
service.EndPoint targets to https://api.sandbox.paypal.com/2.0/.
In the first step of the order, where I make the SetExpressCheckout.. call I set the following value:
$SetECReqDetails->AllowNote = 0;
$SetEcReqDetails is the instance of \SetExpressCheckoutRequestDetailsType. But the customer is still able the enter a note at the PayPal site.
You're setting AllowNote to 0, not "0".
var_dump(0 == null) //outputs: boolean true
Code in the PayPalAPIInterfaceService, line 2436, has the following:
if($this->AllowNote != null) {
//prop is not a collection
//prop not complex
//prop is not value
So basically, you are not defining AllowNote.
I have verified that with the SDK you are using, currently offered on x.com for EC, your code does not work, and the following does work:
$setECReqDetails->AllowNote = "0";
I have been investigating the Facebook Open Graph API. There is a "manage pages" extended permission which allows publishing to a user's Facebook Page news feed/wall via "impersonation". This is nice functionality, but is there anything more you can do through the API?
Specifically, I would like to be able to Add or Remove a "Tab" application from a user's Page via the API. Right now it's complicated to guide a user through the process of adding a tab app to their business (or Place) Facebook Page, and it would be AWESOME if they could just grant my app permission and I could add the app for them with the API.
Basically I am wondering if the API allows for true "page management", or just posting to the Page.
Anyone have any experience with this?
Is the best I can do pointing them to the "add.php" page with the "page" GET variable (e.g. http://www.facebook.com/add.php?api_key=xxxx&pages=1&page=xxxxxx)? This works OK for ADDING a tab application, but there is nothing at all to help them REMOVE an application from their Page so far as I know.
Thanks!
It is worth noting now, for anyone viewing this question (which is celebrating it's 1st birthday!), that Facebook significantly upgraded their API functionality back in July 2011. You can now Add, Remove, Rename, Reorder and set tabs as Default via the Open Graph API. The blog post is here:
https://developers.facebook.com/blog/post/524/
And the official documentation is here:
https://developers.facebook.com/docs/reference/api/page/#tabs
What Facebook does NOT have yet is a new API method for creating new tab apps, or for changing the tab icon. This is a big step though!
UPDATE: There is bug on the new bug tracker to follow about creating apps in the API if you want to follow it and see what they do: http://developers.facebook.com/bugs/295627350461318
There's a way to do it via the API. We finally got it to work, after many hours of sweat and tears :)
You can add a tab to a page without leaving your app. Here's a snippet of code that we used for that. We get a list of pages that a user manages, show them in a drop down and ask them to select what page they want to add our "my agent profile" tab to.
And the final product looks something like this - http://www.facebook.com/pages/Jennifer-Anderson-Real-Estate-Agent/185071901564573?sk=app_253956901293839
protected void btnAddTab_Click(object sender, EventArgs e)
{
if (ddlPage2.SelectedIndex >= 0)
{
FaceBookPages page = FaceBookPages.LookupByPageID(long.Parse(ddlPage2.SelectedValue));
if (page == null)
throw new NPlaySysException("FaceBookPages is null.");
AnalyticLog log = new AnalyticLog();
log.EventID = FBCommon.Events.AddAgentAppTabID;
log.UserID = UserID;
log.EventTime = DateTime.Now;
log.Update();
string result = FacebookSvc.AddTab(Web.AgentAppID, "me", page.AccessToken);
if (result.Equals("true"))
{
FaceBookPages.UpdateAgentProfileAdded(page.PageID, true);
List<FaceBookPages> notTabbedPages = FaceBookPages.LookupAgentProfileNotAddedByUserID(UserID);
imgStep3.ImageUrl = StepDoneImagePath;
divStep3.Attributes["class"] = StepDoneCssClass;
phStep3.Visible = false;
Step3Done = true;
btnCloseStep3.Visible = false;
if (notTabbedPages.Count > 0)
btnEditStep3.Visible = true;
else
btnEditStep3.Visible = false;
}
else
{
lblErrorAddTab.Text = "Failed to add your profile to page.";
Web.EmailError(string.Format("FacebookSvc.AddTab Failed. result={0}<br />UserID={1}<br />PageID={2}", result, UserID, page.PageID));
}
}
}
Yes, the best you can do is direct them to the add.php url. You can't do anything to help them remove the app.
The good news is that the user used to have to go through the add process AND physically decide to "enable" the tab by finding it in the tab dropdown on the page. Facebook has recently changed that and it seems that the tab is now immediately enabled after a user adds the app to their page.
As for "has_added_app" that works... sorta. It will tell you if the app is added to the page, but it won't tell you if the tab is enabled. For example, a user can disable the tab but still technically have the app installed on the page. Therefore "has_added_app" will return true even though the tab isn't actually visible.