How to distinguish between a Google or Paypal response - php

I am working on shopping cart application in which there is an integration of PayPal and Google Checkout. All the code is working fine, but how do I know if the payment is done by Google or PayPal?
The response page for both Google Checkout and PayPal is the same.
After getting response I'm adding all the information to my database and removing items from the session, and then getting redirected to myindex page....

You could set a session variable or some sort of flag when executing the specific code for PayPal or Google.
Example:
payment() {
$vendor = selectedPayementVendor();
if($vendor == 'Google') {
$_SESSION['paymentVendor'] = 'google';
} elseif($vendor == 'PayPal') {
$_SESSION['paymentVendor'] = 'paypal';
} elseif ...
}

Related

PayPal SEPA Payment button not showing

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.

Connection between Customer and Subscription:Braintree API PHP

I'm working on getting all the active members in our Braintree account. I can list all customers but I don't know how to list the active ones.
In the Braintree dashboard, I can easily see it by going to subscriptions and filtering all Active subscriptions then clicking the subscription ID. From there I can see which customer has that subscription ID.
Then I tried getting all the active subscriptions first but I can't find any connection with any customers either.
I'm using the PHP SDK.
Here's how I get our active subscriptions.
My subscription code in my library:
function active_subscriptions(){
return Braintree_Configuration::gateway()->subscription()->search([
Braintree_SubscriptionSearch::status()->in([Braintree_Subscription::ACTIVE])
]);
}
Here's for the controller:
function active_subscriptions(){
$active_subscriptions = $this->braintree_lib->active_subscriptions();
$counter = 5;
foreach($active_subscriptions as $subscription) {
if($counter == 0){
die();
}
echo 'Subscription ID: '.$subscription->id.'<br />';
echo 'merchantAccountId: '.$subscription->merchantAccountId.'<br />';
echo 'planId: '.$subscription->planId.'<br /><br />';
$counter--;
}
}
I found this but it's in Ruby on Rails and there are no details about it in the documentation.
Full disclosure: I work at Braintree. If you have any further questions, feel free to contact
support.
Just to make sure I understand the result you are looking for: You are currently attempting to retrieve all of the customer records that are tied to active subscriptions, correct?
If so, you can achieve this by doing the following:
Iterate over the collection of active subscriptions you received from your search result.
Parse each subscription object for the payment method token associated to each subscription.
Separately, run a paymentMethod.find() call to retrieve the payment method's object.
The payment method object will contain the customer ID.
After following the above steps you can then create a list from your results, which will contain all customers with active subscriptions.
Here is a basic example of how this would be achieved:
$collection = $gateway->subscription()->search([
Braintree_SubscriptionSearch::status()->in(
[Braintree_Subscription::ACTIVE]
)
]);
foreach($collection as $subscription) {
$token = $subscription->paymentMethodToken;
$paymentMethod = $gateway->paymentMethod()->find($token);
$customer = $paymentMethod->customerId;
echo $customer . "\n";
}
If this isn't what you are looking for, or if you have any additional questions you can reach out to Braintree Support directly and we can assist you further.

Paypal Express Checkout demo files NVP/SOAP Demo Samples

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 :)

Applying a Paypal Web Pofile disables "Check out as a Guest"

I am trying to create a paypal payment page, but for some reason when I try to add a custom web profile to the payment the option of checking out as a guest suddenly disappears.
First I am creating the web profile this way:
$flowConfig = new FlowConfig();
$flowConfig
->setLandingPageType("billing")
->setBankTxnPendingUrl("...");
$presentation = new Presentation();
$presentation
->setLogoImage("...")
->setBrandName("...")
->setLocaleCode("...");
$inputFields = new InputFields();
$inputFields
->setNoShipping(1)
->setAddressOverride(0);
$webProfile = new WebProfile();
$webProfile->setName("PROFILE" . uniqid())
->setFlowConfig($flowConfig)
->setPresentation($presentation)
->setInputFields($inputFields);
$request = clone $webProfile;
try {
$createProfileResponse = $webProfile->create($apiContext);
} catch (PayPal\Exception\PayPalConnectionException $ex) {
...
}
$profileId = $createProfileResponse->getId();
Then, I have updated the payment code in this way
$paypalPayment = new PayPalPayment();
$paypalPayment->setIntent("sale");
$paypalPayment->setPayer($payer);
$paypalPayment->setRedirectUrls($redirectUrls);
$paypalPayment->setTransactions(array($transaction));
$paypalPayment->setExperienceProfileId($profileId);
The weird thing is that if I comment the last line I can perform payments as a guest without any issue. If, instead, I leave it this way, I get the customized page but the "Check out as a guest" button is replaced by "Create an account".
Do I really have to choose between having a customized checkout page and the possibility to perform payments without creating paypal accounts? Or am I missing something? I didn't find anything related to this issue in the documentation nor here in stackoverflow, and it seems at least strange!
Thank you
Are you using Express Checkout? It looks like recurring payments without a PayPal account are only compatible with Website Payments Pro accounts.
You can still create recurring payments with EC but they will need a PayPal account to accept them, no guest checkout allowed by the looks of it.
https://www.paypal-community.com/t5/Merchant-services-Archive/How-to-accept-recurring-payments-from-buyers-who-don-t-have-a/td-p/178232

How to disable "note to buyer" in PayPal express checkout?

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";

Categories