addReceipt
Creates a new receipt template
Description
This method allows you to create a new custom receipt template. Once a template has been created it can be selected when running a transaction via one of the transaction methods such as runSale or a receipt can be rendered manually for a transaction using renderReceipt.
For security reasons, the default templates can not be modified via this method.
If the receipt is created successfully a ReceiptRefNum will be returned. This ID is used to uniquely identify the receipt. If an error occurs, an exception will be thrown.
See also updateReceipt, getReceipt, deleteReceipt, emailTransactionReceipt, emailTransactionReceiptByName
Syntax
string addReceipt ( ueSecurityToken, Receipt )
Arguments
Type | Name | Description |
---|---|---|
ueSecurityToken | Token | Merchant security token: used to identify merchant and retrieve the custom fields. |
Receipt | Receipt | Receipt object containing receipt template data |
Return Value
Type | Description |
---|---|
string | Returns the gateway assigned ReceiptRefNum |
Exceptions
The following exceptions (errors) are applicable to this method.
Code | Message | Advice |
---|---|---|
20031 | Invalid content type | ContentType must be either Text, HTML or Both |
20032 | Invalid receipt target | Receipt Target must be either Email or Print |
20033 | Receipt name already used | Receipt template names must be unique |
Examples
PHP
For directions on how to set up the WSDL link, create "$token" and "$client", go to PHP Soap How-to.
<?php
try {
$Receipt = array(
"Name" => "CartReceipt1",
"Subject" => "Sample Cart Order # [Transaction.OrderID]",
"TemplateHTML"=>base64_encode('Yippe skippy [Transaction.Created]'),
"TemplateText"=>base64_encode('Yippe skippy [Transaction.Created]'),
"ContentType" => 'both',
"Target" => 'email',
"FromEmail" => 'noreply@mysamplecart.com'
);
$refnum = $client->addReceipt($token, $Receipt);
}
catch(SoapFault $e) {
echo $e->getMessage();
}
?>
VB
For directions on how to set up the WSDL link and create the "token" and "client" variables, go to the Visual Basic .Net Soap How-to.
Dim receipt As newtek.Receipt = New newtek.Receipt
receipt.Name = "test receipt_VB"
receipt.Target = "email"
receipt.Subject = "test receipt"
receipt.FromEmail = "support@newtekgateway.com"
receipt.ContentType = "text"
Dim message As String
message = "Yippy skippy"
Dim toencode As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(message)
Dim returnValue As String
returnValue = System.Convert.ToBase64String(toencode)
receipt.TemplateText = returnValue
Dim receiptNum As String
receiptNum = client.addReceipt(token, receipt)
MsgBox(receiptNum)
.NET C
For directions on how to set up the WSDL link and create the "token" and "client" variables, go to the C Sharp .Net Soap How-to.
newtek.Receipt receipt = new newtek.Receipt();
receipt.Name = "test receipt";
receipt.Target = "email";
receipt.Subject = "test receipt";
receipt.FromEmail = "support@newtekgateway.com";
receipt.ContentType = "text";
string message = "Yippy Skippy";
byte[] toencodeAsBytes = System.Text.ASCIIEncoding.ASCII.GetBytes(message);
string returnValue = System.Convert.ToBase64String(toencodeAsBytes);
receipt.TemplateText = returnValue;
string receiptRefNum;
try
{
receiptRefNum = client.addReceipt(token, receipt);
MessageBox.Show(string.Concat(receiptRefNum));
}
catch (Exception err)
{
MessageBox.Show(err.Message);
}
XML
Request:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"xmlns:ns1="urn:newtek"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:addReceipt>
<Token xsi:type="ns1:ueSecurityToken">
<ClientIP xsi:type="xsd:string">123.123.123.123</ClientIP>
<PinHash xsi:type="ns1:ueHash">
<HashValue xsi:type="xsd:string">f6cc4dddf3ee69bb27c4852fdb7393f7a65d5e27</HashValue>
<Seed xsi:type="xsd:string">1477767556-test</Seed>
<Type xsi:type="xsd:string">sha1</Type>
</PinHash>
<SourceKey xsi:type="xsd:string">_B4P7C4K2w2ZCQQQXRqrxDj6agrS2NIT</SourceKey>
</Token>
<Receipt xsi:type="ns1:Receipt">
<Name xsi:type="xsd:string">Receipt26</Name>
<Subject xsi:type="xsd:string">Example Order # [Transaction.OrderID]</Subject>
<FromEmail xsi:type="xsd:string">new@example.com</FromEmail>
<Target xsi:type="xsd:string">email</Target>
<ContentType xsi:type="xsd:string">both</ContentType>
<TemplateHTML xsi:type="xsd:string">ZXhhbXBsZSByZWNlaXB0ICBbVHJhbnNhY3Rpb24uQ3JlYXRlZF0=</TemplateHTML>
<TemplateText xsi:type="xsd:string">ZXhhbXBsZSByZWNlaXB0ICBbVHJhbnNhY3Rpb24uQ3JlYXRlZF0=</TemplateText>
</Receipt>
</ns1:addReceipt>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Response:
<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="urn:newtek"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:addReceiptResponse>
<addReceiptResponseReturn xsi:type="xsd:string">28</addReceiptResponseReturn>
</ns1:addReceiptResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>