How to charge your own fees alongside Paypal? - php

I've searched everywhere in order to find an answer but have not found one. All i know is that in order to do it you need paypal adaptive payments i think (if you know another way let me know)
What im trying to do is make it so that when a user purchases a product 15% goes to one paypal account and the rest goes to the authors paypal account but have done loads of searching and have found nothing
PayPalAP::setAuth('my_api_username', 'my_api_password', 'my_api_signature');
// I'm not passing in an environment, which will default it to sandbox mode.
$options = array(
'cancelUrl' => 'http://my_cancel_url',
'returnUrl' => 'http://my_return_url',
'currencyCode' => 'USD',
'receiverEmailArray' => array('receiver_of_funds'),
'receiverAmountArray' => array('15'),
'ipnNotificationUrl' => 'http://my_ipn_listener_url'
);
$respo

Adaptive Payments would be the way with paypal ... But I would recommend using stripe for this kind of transaction. The API allows better control and was build for this kind of complexity. If you can replace paypal with stripe, do it. If not, you will need to contact paypal. They made this feature restricted.

Patrick Simard is correct that this feature is now restricted, but assuming you have received authorization from PayPal to use the adaptive API, then you have two option:
Chained Payments
Parallel Payments
Both will achieve the same end game, but which one you choose is ultimately up to you.
Chained Payments
With Chained Payments, you set up a payment option where the initial payment goes into one account, a portion is removed/left in that account, and then the rest is sent on to a second account.
Parallel Payments
Parallel Payments will produce a similar result, but rather than all of the funds being sent to one account first before being sent onwards, the money is instead sent to two different accounts immediately. (This option actually supports up to 6 accounts being paid at once.)
Examples of the HTTP I/O can be found on the linked documentation pages. You will simply need to set up cURL requests to create these. (Which should be a fairly straight forward process.)
To reiterate, though, heed the following notice from PayPal about using this API:
Important: Adaptive Payments is now a limited release product. It is restricted to select partners for approved use cases and should not be used for new integrations without guidance from PayPal.
This warning can be found at the top of documentation pages for Adaptive Pay.
Edit: In response to your comment, I have located a possible alternative that does not rely on the Adaptive Payments API, and seemingly does not require special permission from PayPal to use.
The option I found is to use Express Checkout with Parallel Payments. This utilizes the PayPal Name-Value Pair (NVP) and SOAP API. Some details on this option can found on this documentation page: https://developer.paypal.com/docs/classic/express-checkout/integration-guide/ECParallelPayments/
As a caution, though, that page seems to indicate that the NVP and SOAP API is deprecated. I am unsure what they are replacing it with, but at this time, it does still appear to be an opportunity, although you may have to update your code at some point when they release their replacement for NVP & SOAP and/or when they remove NVP & SOAP.
There is also a full list of SDKs, which includes an Express Checkout SDK written in PHP for the NVP & SOAP API: https://developer.paypal.com/docs/classic/api/nvpsoap-sdks/

Related

Accept PayPal payment using only credit card with Omnipay (PHP)

I integrated OmniPay in my project few days ago, and I wondered if there is any option coming with it to actually enable credit card payments.
https://github.com/thephpleague/omnipay
I want to understand how to enable the PayPal credit card payments (which do not require an paypal account) using it.
What PayPal API settings should I enable?
How can I code this?
Is there any option to do this using PayPal & PHP at all ?
I tried to document myself on this and I couldn't find any answer to this question. Neither on the https://github.com/thephpleague/omnipay nor on Stack.
The setting mentioned in comments, 'PayPal Account Optional' exists so you have the ability to only accept payments from people with an account (when set to 'No').
If set to 'Yes', payments without an account can be possible. But whether the option will be offered to a particular payer in a particular PayPal checkout attempt depends on very many factors, which you do not control.
The only way to have some guarantee of a guest method being offered is to show a credit card form on your own site, before the buyer reaches a PayPal.com page, using the black 'Debit or Credit Card' button that is part of the JS SDK. You can see an example demo here: https://developer.paypal.com/demo/checkout/#/pattern/server
That JS code used for payer approval can be paired with any backend to create and capture the order via API -- including Omnipay, which essentially acts as a proxy for the PayPal API. This JS replaces any redirect over to PayPal which you might be familiar with from oler legacy integrations; the JS SDK is a more modern way to get the payer's approval, via a small in-context window or open a credit card form iframe instead which is a better UX than redirecting away anyway.

Paypal Adaptive: Should it be used considering it is under limited release?

For setting up a transaction between Paypal account to another Paypal account without user intervention/permission, I was planning to integrate Paypal Adaptive but had second thoughts due to a note on the Paypal's web page for Adaptive payments. The screen shot and link of the note attached below:
https://developer.paypal.com/docs/classic/adaptive-payments/integration-guide/APIntro/
Screenshot:
This got me to wondering whether Adaptive is a good choice for new integrations considering the limited release note or whether I would be able to make requests in a live account currently? (It works in sandbox account currently)
If yes, then should I be worried there may be some future update that would render my integration to not work?
If its not a good choice then what other alternatives does Paypal offer that are best suitable for Paypal account to account transaction?
Initially, I was actually trying to integrate PreApprove coupled with Pay API for automated transactions without user intervention/permission but used "DoReference" instead due to this note from Paypal.

Paypal payments for digital goods

Hi I have some questions for paypal digital goods express checkout
I am following paypal tutorial on integrating payments for digital goods and using merchant sdk for same.But I want some suggestion and have some questions
Is there some other better alternative to integrate payment for digital goods ?
Should I configure IPN or can I rely on return url to save data on backend?
How can I make sure that data is from paypal both on return url and IPN .
As read I need to make request to https://www[.sandbox].paypal.com/cgi-bin/webscr/ with command cmd => _notify-validate [reference]
Is there any inbuilt function in sdk I am using or should I make manual call ?
re: #1, EC for Digital Goods is a solid choice for digital goods sales. If you don't need the digital-goods specific features you can also use PayPal's regular/plain EC or the newer RESTful products.
re: #2, EC doesn't do the payment until you make an API call (well, unless you explicitly ask it to with an added parameter). So you can use either the response from the DoEC API call or set up IPN. If you do choose to actually have the payment take place on PayPal's site you have some small chance of the user paying and not redirecting back successfully (e.g. they close the browser window, or the network hiccups). This should be very rare & you can probably handle it manually or with some other mechanism, but this is one reason people like IPNs: PayPal will try repeatedly to push you the info, so it requires more than a transient failure to not get the word (eventually).
re #3, it sounds like you know to validate the IPNs. And if you use GetExpressCheckout API calls you are hitting PP so again you can be certain of the source of the reply. This is one advantage the API integration model has over the redirection-based mechanisms in Website Payments Standard (although if you were using WPS you could use a feature called PDT to ask it to send you the same signature block as is used in IPN so you could post back to PP to validate the redirection contents).

How to get started on making a custom payment system using PHP?

Let's say, for the sake of discussion, my client does not want to use the Paypal api for transactions. I have already made a shopping cart. The user submits the items on the shopping cart and their credit card number.
Assuming I'm not using any api, how would I then charge the user's credit card for the items on the shopping cart? I understand that it is complex, just wondering what the general process is like and how to get started.
You're going to need to trigger a bank transaction, so obviously you're going to need to use an API at some level. I think the way to go would be to first learn in some detail how at least one of the popular commercial (by definition?) payment card processing services works, e.g.:
https://paymentvision.com/Payment-Gateway/Payment-Gateway-API.aspx
http://aws.amazon.com/fps/
https://www.firstdata.com/en_us/customer-center/merchants/support/first-data-global-gateway-api-software-landing.html
http://www.authorize.net/
The next step would be to design the "payment processing" subsystem of your PHP application/library around the "backend workflow" (perhaps using a 3rd party PHP library, if one is available), and do some testing.
Then I would plan for a security audit of your code & systems before you actually use it to handle payment card information on behalf of a customer/3rd party.
You can also capture all the card information and use an external payment processor. The problem is that you will be hit with major fees since it will be considered a keyed in and not swiped transaction.
If you don't want/like paypal, don want to use a payment processor like authorize.net, you could look at other options like stripe.com.
Find an payment gateway, such as authorize.net. With payment gateways such as this, your client will need to sign up for a merchant account with a credit card processing agency. You payment gateway can help you with this.
Then, you'll usually get a token or api key that you will use to connect to the payment gateways services. From php, you'll use cURL or fsockopen to connect to them. Securely send your api key, get a response, then send some other required message, get another response, and then send in credit card information and credit card holder information.
There are lots of PHP Libraries to choose from out there for different payment gateways. I'm not suggesting authorize.net, it was just an example. But when you find one you are happy with, and happy with the fees that are associated with processing credit cards, you can either use a prewritten library, or they payment gateway will provide you with and API that will tell you how to integrate with their system.
Payum efficiency proved by 1k+ stars on a GitHub, great comments and a million of downloads. Supports 50+ different payment gateways so you surely find what you need.

Taking payment on a website

Whats the recommended way to do this with Paypal (i've heard they're a nightmare to deal with).
Ideally the user would sign up with credit card details and then i'd process the payments through their banks? Is that how it works? With API's?
Ideally the user would sign up with
credit card details and then i'd
process the payments through their
banks? Is that how it works?
No. In a correctly designed system you never have access to your user's credit card number. It's your payment processor (eg PayPal, MoneyBookers, FastSpring, etc.) that takes care of processing your customer's credit card.
So your customer is taken to the payment processor's site (on a page which can be customized to use your company's logo etc.) and then your payment processor warns you when a purchase a made (for example by calling a specific URL).
With API's?
Yup, PayPal (and MoneyBookers and things like FastSpring) offer APIs for several languages (like Java APIs).
PayPal has a dev environment on which you can test these kind of functionalities, so does MoneyBookers if I recall correctly (also note that sometimes the dev environments are a bit buggy and/or down).
PayPal offers APIs for processing payments. Typically, the user is taken off your page to login into paypal and then paypal calls back to your site with approval/shipping info. The whole point is for the user to shield their credit card info from your site, making things safer.* You can use either the NVP (name-value pair) or SOAP protocol for development. There are also 3rd party libraries to simplify integration.
Check out the API reference here to get an idea:
https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/howto_api_reference
*PayPal does offer a Direct Payment API which allows your site to take credit cards directly and use PayPal as the gateway:
https://www.paypal.com/cgi-bin/webscr?cmd=_dcc_hub-outside

Categories