Heartland has partnered with PayPal to provide merchants the ability to process PayPal Express payments through the same Heartland Portico gateway as credit card payments. Merchant who choose to integrate PayPal Express payments through Heartland benefit from consolidated reporting, a single point of contact for both payment types, and more!
Create a BuyerData Object
Buyer data helps PayPal control the checkout flow (with the return and cancel URLs) as well as potentially identify the consumer using a PayPal payer ID.
Create a PaymentData Object
Payment data holds the many types of totals (subtotal, shipping total, etc.) and the payment type to be used in the transaction. The amounts provided in HpsPaymentData should add up to the amount argument in the various HpsPayPalService methods. If they do not, PayPal will reject the transaction.
Create a ShippingInfo Object
Shipping information can be optional when creating a new session as this information can be provided by PayPal during checkout. If it is provided during session creation, the SDK will pass a flag to prevent PayPal from prompting the consumer for shipping address information in the PayPal interface. If it is not provided during session creation, the developer will want to request the session information after the consumer is redirected to the return URL.
Create a Line Items List
The line item list is an list of HpsLineItem objects. The item amounts should add up to the HpsPaymentData subtotal property.
If a discount or multiple discounts need to be sent with the order, a line item object should be created with a negative amount.
Creating line items
Create a PayPal Session
A session will be created with PayPal to be referenced in all future method calls. The response contains two important pieces of information:
Session ID: the token generated by PayPal
Redirect URL: the initial destination URL where the consumer will be redirected
From here, the consumer will be within the PayPal checkout flow and their user interface. On completion, the consumer will be redirected to the return URL set in the HpsBuyerData object, and on cancellation, the consumer will be redirected to the cancel URL in the HpsBuyerData object.
Creating a session
Get Session Information
The session ID is in the token query string parameter when the consumer is redirected to the return URL. The consumer’s PayPal payer ID is in the PayerID query string parameter.
Getting session information
Authorize the Consumer’s Account
Creating an authorization
Check a Pending Transaction’s Status
At times, PayPal will respond in an authorization request stating the authorization is in a pending status. This most often occurs when the consumer only has ACH/eCheck backing her account, so the funds requested in the authorization cannot be confirmed. Before the authorization can be captured, the status of the pending authorization must be checked/updated using the status method.
Checking the status
Capture the Authorization
Capturing the authorization
Authorize with an Automatic Capture
When a merchant can immediately ship an order or is selling services/virtual products, the use of delayed captures is usually not needed. For these cases, the Sale payment type is often preferred as it acts as an authorization with an automatic capture.