Tea Commerce comes with support for the PayPal Standard payment gateway out of the box.
The process of setting up PayPal Standard for use with Tea Commerce is the same whether you're configuring a live business account or a seller account in the PayPal Sandbox test environment.
When you create a new payment method in Tea Commerce you select the payment provider from the 'Payment provider' tab.
Obviously for the PayPal payment gateway you'll need to choose the 'PayPal' option.
Clicking the 'Load default settings' button will automatically add the default property fields for the payment provider which can be seen below. Note that initially the property values will be empty and not filled as shown.
The above image shows the PayPal payment provider for this payment method fully and correctly configured for use with my Sandbox account.
Some of the fields are self explanatory but others are a bit more mysterious.
- business : This should contain the email address of the business account that will be accepting payments.
Important note : Although PayPal allows it, do NOT enter the Merchant ID in this field. See the note at the end.
- lc : This specifies the locale of the login page that PayPal will present to the customer and you should enter one of the codes documented here.
- return : Enter the link to the page that you would like customers to be directed to upon a successful payment.
- cancel_return : Enter the link to the page that you would like customers to be directed to upon a cancellation of payment.
- paymentaction : Enter 'sale' if you the payment to be actually captured and transferred to your account or 'authorization' if you just want to authorize the sale for manual capture later. If you're selling items that you don't hold stock for the authorize option is useful.
- USER : Your PayPal account's API Username.
- PWD : Your PayPal account's API Password.
- SIGNATURE : Your PayPal account's API Signature.
- isSandbox : 0 to work with a live business account, 1 to work with a Sandbox seller account.
Tea Commerce uses the PayPal Classic API and the first thing you'll need to do is ascertain the API access credentials for your account.
Login to your account, click the 'Profile' link and then click the 'API Access' link.
This will present you with the following screen.
Here we want to choose Option 2 as Tea Commerce will work with the API credentials that have been generated for your account.
Click the 'View API Signature' link.
This screen will display the API Username, API Password & Signature which you should enter into the Tea Commerce configuration screen for your PayPal payment method.
Tea Commerce works with callbacks from PayPal's Instant Payment Notification (IPN) feature.
When the state of a transaction changes PayPal will send the details of the transaction to Tea Commerce's payment call back URL and Tea Commerce will take the appropriate action to amend the order.
To make this work we need to configure the IPN settings in the PayPal account.
Click the 'Profile' link again and then click the 'Instant Payment Notification Preferences' link.
Click the 'Choose IPN Settings' button.
Enter the URL as show above, substituting your own domain name.
It doesn't matter too much what you enter here because Tea Commerce will override this callback URL with each transaction but PayPal will attempt to validate the URL you enter so you'll need to enter something real in order to save it.
Turn IPN messages on by selecting the 'Receive IPN messages (Enabled)' option and click the 'Save' button.
When saved, you will see a new link to the 'IPN History page'. This page is useful if you ever need to troubleshoot callback problems or see the details of an IPN message.
Below is an example of one such message and you can see how Tea Commerce has set the Notification URL.
Above I mentioned not using the Merchant ID in the business field. You'd think it would be sensible to use the unique ID for the PayPal account rather than an email address which may actually get changed at a later date. However if you do I have found that although the transaction runs through smoothly, Tea Commerce will fail to complete the order at the end during the IPN callback.
Another thing worth noting if you are using the Sandbox. In this mode the Payment provider will write the details of callbacks to log files in the root directory. At the time of writing if IIS did not have permission to create the log files in the directory it would error causing the callback processing to fail, often meaning the order would not be completed in Tea Commerce and you'd be left scratching your head wondering why.