I have an issue with Braintree,
Suppose a customer logged in on my site, then I create client token for that customer (By passing customer id in Braintree\ClientToken::generate() function ),
so that if he have any existing payment method then it will be loaded automatically at client side.
But if customer selects new payment method which already in vault:
for card same card number, for Paypal same email address,
then it automatically added in vault for that customer, either it exists or not,
So in my case, i don't want to store same payment method(either Paypal or Card) twice or more for same user,
How can i restrict so that same payment method should not store multiple times in vault?
Full disclosure: I work at Braintree. If you have any further questions, feel free to contact
support.
There is actually a parameter you can set in the Client Token generate options called failOnDuplicatePaymentMethod. If this option is passed as True and the payment method has already been added to the Vault, the request will fail. This can only be passed if a customer_id is passed as well. If the check fails, this option will stop the Drop-in from returning a payment_method_nonce. Unfortunately, this will not work for Paypal Payment methods, and there are a few workarounds for that.
Not Storing in the Vault
You would first need to collect the customer's PayPal email account in the client-side callback. When the payment type is a PayPalAccount , you can then run a Braintree::Customer.search() request on the user's email. If this brings up any customers that have the PayPal email account you specified (which was retrieved from the client-side integration), you wouldn't need to vault the account, you can simply proceed with creating another transaction on the existing token.
Deleting Duplicate Accounts
The second workaround is similar to the first.You collect the customer's PayPal payment method as usual (collect the nonce and pass it to your server) and then use it in a Braintree::PaymentMethod.create or Braintree::Customer.create API request as usual. In the result object returned, you can then check the details of this PayPal transaction, paypal_details and inspect this to find the email address. If this email matches one for a PayPal account for that customer, you can choose to delete the new payment method immediately.
Don't hesitate to reach out to Braintree Support if you need more help.
Related
When you are setting up a PayPal Buy Now Button, you can take customers to the URL when they finish checkout.
Is there a way to retrieve their PayPal email immediately after PayPal checkout using $_GET?
Does PayPal append some kind of ?email=email#address.com at the end of your thankyou page?
Or is there any variable I could add at the end of my thankyou page when typing a success URL inside the PayPal?
Basically I want to store their PayPal email address that they used on deposit, so that when they would cash out, the same PayPal email address will be used.
Just wanted to let you know why I'm interested in storing their real PayPal email address in the first place.
Any help from someone who have knowledge in this would be appreciated.
With a legacy HTML Buy Now button that redirects away from your page, there is never any guarantee the payer will return to your site after a successful transaction. With such an old integration, the only reliable way to get the email address of the payer and record this information in your database is to implement the old IPN service.
Instead, you should do a server-side integration of the current Standard Checkout.
Follow the Set up standard payments guide and make 2 routes on your server, one for 'Create Order' and one for 'Capture Order', documented here. Both routes should return only JSON data (no HTML or text). Inside the 2nd route, when the capture API is successful you should store its resulting payment details in your database (particularly purchase_units[0].payments.captures[0].id, which is the PayPal transaction ID -- as well as the payer object's email address, in your case) and perform any necessary business logic (such as sending confirmation emails or reserving product) immediately before forwarding your return JSON to the frontend caller.
Pair those 2 routes with the frontend approval flow: https://developer.paypal.com/demo/checkout/#/pattern/server
I am implementing PayPal payment to my application.
I am using Laravel Framework and merchant-sdk-php package to handle NVP/SOAP API. I would accually prefer REST API, but i need customers to make Reference Transactions with various amount, in non regular time periods and as far as i know it's possible only with NVP/SOAP API.
The payment flow in shortcut:
1. Payer clicks "connect" button, which is to create billing agreement using "SetExpressCheckout" method. Amount is set to 0 and adding a Billing Agreement field to request. Customer is redirected to PayPal, log in to his account, agreeing to direct debit and finally redirected to my return url.
2. After response is come, return action is fired (the one, which is passed in returnurl field). Next using token from paypal resposne i use CreateBillingAgreement method to get "BillingAgreementID" which i store in database.
3. Using "BillingAgreementID" i make "DoReferenceTransaction" request. No prompt to login is occurring, everything is happening behind the scene. Finally i get response after transaction.
The thinks i want to know are:
1. Is there a way, to get an email address, which consumer used to log in when creating billing agreemenet? I want to show in application which PayPal account (related to mentioned email) is direct debit set to?
2. I want to make some action in databse both after "BillingAgreementID" and "DoReferenceTransaction". Is the response status "Success" and additionally in "DoReferenceTransaction" field "PaymentStatus" set to "Completed" enought to conclude, that transaction is fully completed, and i cant i.e. share some digital goods or should i wait for IPN from this request?
Thanks for all contributions!
Found solution to question 1.
After betting billing agreement id i had to make "GetBillingAgreementCustomerDetails" action. In response i got customer details including email.
Still watching for hint to second question
One of the features on my site allows users to pay via PayPal for items from other users. I'm using the standard REST API since I had already made the code for another project a while ago, which works fine.
https://developer.paypal.com/docs/api/#create-a-payment
Currently, the page sends a 'v1/payments/payment' request which I execute to receive the money in to my PayPal account which created the access token. Is there a way I can directly get the user to pay another PayPal email address?
If not, I guess the only way is to do another request to pay the owner of the content from my PayPal once I receive the money - although it means PayPal get to charge a fee twice.
Thanks.
I'm currently developing an application which has to be able to process PayPal Payments from multiple e-mails and then has to redirected to my IPN class located at my server.
All the users of my application, have the possibility to set-up their own PayPal e-mail address into my system, and then the customers will pay directly to his PayPal Account (that means no intermediates).
But there's a problem, I must ensure that my sellers are actually connected to my IPN. Why? Because if they are not, when a customer makes a payment, the transaction will be actually completed, but they won't be able to download their purchased item, because my application could not receive the params.
So, the question is: how can I ensure this:
User has a valid Paypal Account (based on e-mail)
How do I know (and verify it each time) that this e-mail will sent a params directly to my server's IPN? (So important)
How do I verify each time that some customer makes a purchase?
Thank you so much guys!
I would integrate Express Checkout and have them authorize you $1 (or whatever your minimum for currency is). This way you are guaranteed that the customer has a PayPal account with some balance. You can void the transaction via API and they get their money back.
There's no way to guarantee they send you IPN for their payments. The best bet would be to have them authorize you to run third party calls on their behalf and take the money for them via your system.
See #2
I have site with a members area that I've set up and want to make it so when people register, they need to subscribe to paypal, and only then the user is created in the database.
I don't know much how paypal works. Does anyone have any pointers? How or where do I start?
Basically I need to somehow redirect the visitor to paypal after he presses the "Register" button, make the payment, and then make Paypal return to my site and tell it that the payment was processed, so the user can be created...
Paypal IPN is the Paypal deployment for this kind of requirement.
IPN (Instant Payment Notification) allows you to delegate an endpoint URL that the payment gateway will send postdata to when a payment is completed successfully.
Most of the time this requires utilizing some kind of database to save the registration state while the user is forwarded over to Paypal for the payment process, making use of their SSL encryption and payment logic. When the process is completed, your application is notified with post data containing a unique identitfier generated by your app and passed with the original redirect in order to identify the user's session that has completed payment.
You will want to generate a unique id either using PHP uniqueid() function or by hashing a timestamp. This will be passed along to paypal in your redirect, and paypal will send it along with success/fail flags when the payment is processed. When the user fills out their form and is redirected to Paypal, save a boolean value for IsPaid in your database associated with their ID (i'd recommend using both a primary key as well as this unique transaction id mentioned earlier.) Your IPN script can then listen for the post data, parse it out and change the false IsPaid boolean for that id to true.
There are numerous good tutorials available. I've only used this in MVC deployments, so if you're doing procedural, googling around will help a great deal. Paypal's documentation has the most up to date parameter guides but there are other great, if a bit old, tutorials available independent of them.
http://www.web-development-blog.com/archives/easy-payments-using-paypal-ipn/
http://net.tutsplus.com/tutorials/php/using-paypals-instant-payment-notification-with-php/
Look at the Paypal IPN API, this is used in most paid membership scripts:
https://cms.paypal.com/uk/cgi-bin/?cmd=_render-content&content_ID=developer/library_code