Payment Instruments
The Payment Instruments feature makes using various payments methods more straightforward and, in the case of payment cards, more secure. Payment instrument is a set of fields that can be used to charge a shopper without any action on the shopper's side. For more details and instructions on how to enable the feature, see Payment Instruments.
For help working with this record in the UI, see Payment Instruments.
The following Payment Instruments records are supported in SuiteScript:
-
General Token -the internal ID is
generaltoken
-
Payment Card -the internal ID is
paymentcard
-
Payment Card Token -the internal ID is
paymentcardtoken
Supported Script Types
The Payment Instruments records are scriptable in both client and server SuiteScript.
Usage Note
You cannot retrieve the value of the Payment Card Number (cardnumber) field or the Token (token) field from the original form after you save the payment instrument. For security reasons, the values of those fields are masked. For more information, see Payment Card Number Security and Compliance. The Payment Card Number field is located on the Payment Card record, and the Token field is located on the General Token and Payment Card token records.
Supported Functions
The General Token, Payment Card Token, and Payment Card records can be created, read, updated, deleted, and searched by using SuiteScript. The records cannot be copied or transformed.
Code Sample
The following script sample shows how to create a payment instrument of the Payment Card type. The script sets the compulsory fields, and also enables Dynamic mode, so other compulsory fields are set automatically.
The script sample sets the Preserve on File field value to True. Therefore, the payment instrument information is saved in the system and can be used in other transactions.
require(['N/record'], function(record){
function createPaymentCard(){
var recordObj = record.create({
type: record.Type.PAYMENT_CARD,
isDynamic: true
});
recordObj.setValue({
fieldId: 'entity',
value: '6'
});
recordObj.setValue({
fieldId: 'cardnumber',
value: '4111111111111111'
});
recordObj.setValue({
fieldId: 'expirationdate',
value: new Date(2023, 11)
});
recordObj.setValue({
fieldId: 'paymentmethod',
value: '5'
});
recordObj.setValue({
fieldId: 'nameoncard',
value: 'John Wolfe'
});
recordObj.setValue({
fieldId: 'preserveonfile',
value: true
});
var recordId = recordObj.save({
ignoreMandatoryFields: false
});
}
createPaymentCard();
});
Related Topics
- Payment Instruments
-
Payment Card Number Security and Compliance
- Working with the SuiteScript Records Browser
- SuiteCloud Supported Records
- Lists