Proposal summary
This proposal details how to enable SagePay as an external payment gateway in NetSuite with the help of SagePay APIs.
Requirement
- Payments (Via the SagePay Integration) will be triggered from the Sales Order record only via a button/popup.
- On Customer Deposit Record
- The Deposit record must be created from the Sales Order to maintain the link to the Sales Order, and to ensure that the Deposit Application will correctly allocate the payment(s) to the Invoice.
- Payment reference number must be stored in {custbody_nbs_sagepay_reference}
- Payment Method must be set to Sagepay
- On Customer Deposit Record
- Refunds (via the SagePay integration) will be triggered from the Customer Deposit or the Credit Memo via a button/popup.
- If the Invoice has not been raised, the refund must be triggered from Customer deposit
- Refund to use the reference number stored in {custbody_nbs_sagepay_reference}
- Refund Method must be set to Sagepay
- Amount is set in the Integration Popup.
- If the Sales Order has already been invoiced then the refund MUST be triggered from a Credit Memo via a button/popup.
- The user MUST enter the Reference number of the payment that they want to Refund (by copy/past from the deposit record).
The user MUST enter the amount that they want to refund. - The Sage Pay integration will create the Customer Refund setting the following
- The Sagepay Reference number
- Refund Method must be set to Sagepay
- The user MUST enter the Reference number of the payment that they want to Refund (by copy/past from the deposit record).
- If the Invoice has not been raised, the refund must be triggered from Customer deposit
Solution
Two custom fields will be added to the Customer Refund record, namely ‘Refund for Deposit’ and ‘SagePay reference’.
The ‘Refund for Deposit’ field will list only the deposit that is created for the customer selected on the Customer Refund record. Upon choosing a deposit on the ‘Refund for Deposit’ field, the SagePay reference will be sourced from the Customer Deposit record and will be set on ‘SagePay reference’ field on the Customer Refund record
Accepting Payment by SagePay
- On viewing the Sales Order Page, a button named ‘Pay by SagePay’ will be shown if the Sales Order is not Billed (or not Closed) and if the total sum of Customer Deposit does not match with the Sales Order total
- Clicking on this button either redirect the user to a custom page or shows a popup
- On the new page/popup, there will be an option to enter information such as
- Card Holder Name, Card Number, Expiry Date, and Security Code
- Other relevant details will be automatically sourced from the Sales Order
- On submitting the form,
- If the payment is successful, a customer deposit will be created and the user will be redirected to the Customer Deposit page.
- The Deposit record must be created from the Sales Order to maintain the link to the Sales Order and to ensure that the Deposit Application will correctly allocate the payment(s) to the Invoice.
- Payment reference number must be stored in {custbody_nbs_sagepay_reference} and {pnrefnum}
- Payment Method will be set to Sagepay
- If the payment is failed, the same will be notified to the user
- If the payment is successful, a customer deposit will be created and the user will be redirected to the Customer Deposit page.
- On the new page/popup, there will be an option to enter information such as
- Clicking on this button either redirect the user to a custom page or shows a popup
Refund by SagePay
Refund from Customer Deposit
- On viewing the Customer Deposit Page, a button named ‘Refund by SagePay’ will be shown if the payment method is SagePay.
The button navigates the user to the Customer Refund page with the ‘Refund for Deposit’ field and the ‘SagePay reference’ field auto-populated by referring to the Customer Deposit.
Note: If the Invoice has not been raised, the refund must be triggered from the Customer Deposit- Please note that the user can override the value on the ‘Refund for Deposit’ field either by
- Choosing a different customer deposit against which the refund is initiating by selecting the same from the ‘Refund for Deposit’ field and the ‘SagePay reference’ field will be auto-populated by referring to the Customer Deposit
- If the user chooses a different customer deposit from the ‘Apply’ subtab, this will set the selected Customer Deposit on the ‘Refund for Deposit’ field and the ‘SagePay reference’ field will be auto-populated by referring to the Customer Deposit
- On submitting the Customer Refund record and if the refund type is SagePay, a script will check whether all the values for the mandatory field are present. If not, this will be notified to the user.
- After submitting the Customer Refund record and if the refund type is SagePay, a script logic will try to execute the SagePay refund by taking the information such as SagePay reference from {custbody_nbs_sagepay_reference} field and Refund amount from {total} field
- If the refund is successful
- The Sagepay Refund Reference number will be set on {custbody_nbs_sagepay_refund_reference}
- If the refund is failed, the same will be notified to the user
- If the refund is successful
- Please note that the user can override the value on the ‘Refund for Deposit’ field either by
Refund from Credit Memo
- Note: If the Sales Order has already been invoiced then the refund must be triggered from a Credit Memo
The standard refund navigation from the credit memo will navigate the user to the Customer Refund Page.- On the Customer Refund page, the user can either
- Choose the customer deposit against which the refund is initiating by selecting the same from the ‘Refund for Deposit’ field and the ‘SagePay reference’ field will be auto-populated by referring to the Customer Deposit
- If the user chooses the Customer Deposit from the ‘Apply’ subtab, this will set the selected Customer Deposit on the ‘Refund for Deposit’ field and the ‘SagePay reference’ field will be auto-populated by referring to the Customer Deposit
- On submitting the Customer Refund record and if the refund type is SagePay, a script will check whether all the values for the mandatory field are present. If not, this will be notified to the user.
- After submitting the Customer Refund record and if the refund type is SagePay, a script logic will try to execute the SagePay refund by taking the information such as SagePay reference from {custbody_nbs_sagepay_reference} field and Refund amount from {total} field
- If the refund is successful
- The Sagepay Refund Reference number will be set on {custbody_nbs_sagepay_refund_reference}
- If the refund is failed, the same will be notified to the user
- If the refund is successful
- On the Customer Refund page, the user can either
Assumptions
- The currency will be always GBP
- The mandatory details which will be sent to SagePay during payment are
- The NetSuite transaction reference number will be the document number of the Sales Order.
This will be set as vendorTxCode on SagePay. - The description will be Sales Order document number
- Customer First name and Last Name which will be sourced from the Customer record
- If the customer type is company (not individual), the last name cannot be populated. In this case, the NetSuite user should enter the Last Name manually on the SagePay payment form
- For Billing Address
- Line 1 will be from Sales Order Billing Address Line 1
- City will be from Sales Order Billing Address City
- Postal Code will be from Sales Order Billing Address Zip
- Country will be hardcoded to ‘GB’
- Currency will be hardcoded to ‘GBP’
- apply3DSecure will be hardcoded as ‘UseMSPSetting’
- entryMethod will be hardcoded as ‘Ecommerce’
- Amount will be Sales Order total
- The NetSuite transaction reference number will be the document number of the Sales Order.
- The mandatory details which will be sent to SagePay during refund are
- The NetSuite transaction reference number will be the document number of Customer Refund.
This will be set as vendorTxCode on SagePay. - Description will be hardcoded to ‘Customer Refund’
- Currency will be hardcoded to ‘GBP’
- Amount will be Customer Refund total
- The NetSuite transaction reference number will be the document number of Customer Refund.
- The vendorTxCode is unique in SagePay.
This implies we cannot send the same document number (of Customer Refund or Sales Order ) more than once to SagePay - If there are multiple SagePay payments, there should be multiple refunds as the payment and refund are correlated (one-to-one)
Time
Total Effort: 32 hrs