updateReceipt

Update receipt template

Description

This method allows you to update an existing custom receipt template.

For more information about the template syntax and available fields, see the template documentation.

For security reasons, the default templates can not be modified via this method.

If the receipt is updated successfully the ReceiptRefNum will be returned. If an error occurs, an exception will be thrown.

See also addReceipt, getReceipt, deleteReceipt

Syntax

string updateReceipt ( ueSecurityToken, ReceiptRefNum, Receipt )

Arguments

Type Name Description
ueSecurityToken Token Merchant security token: used to identify merchant and retrieve the custom fields.
string ReceiptRefNum Gateway assigned receipt ID
Receipt Receipt Receipt object containing receipt template data

Return Value

Name Description
string Returns the gateway assigned ReceiptRefNum

Exceptions

The following exceptions (errors) are applicable to this method.

Code Message Advice
20030 Requested receipt not found ReceiptRefNum must match an existing receipt.
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.


    try {
      $ReceiptRefNum = 2;
      $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->updateReceipt($token, $ReceiptRefNum, $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 receiptNum As String
            receiptNum = "9"

            Dim receipt As newtek.Receipt = New newtek.Receipt
            receipt.Name = "test VB_receipt"
            receipt.Target = "email"
            receipt.Subject = "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 response As String
            response = client.updateReceipt(token, receiptNum, receipt)
            MsgBox(response)

.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.

                string receiptRefNum = "5";
                newtek.Receipt receipt = new newtek.Receipt();

                receipt.Name = "test two";
                receipt.FromEmail = "test@test.com";
                receipt.ContentType = "both";
                receipt.Target = "email";

                string message = "Yippy Skippy";
                byte[] toencodeAsBytes = System.Text.ASCIIEncoding.ASCII.GetBytes(message);
                string returnValue = System.Convert.ToBase64String(toencodeAsBytes);
                receipt.TemplateText = returnValue;

                string response;

                try
                {
                    response = client.updateReceipt(token, receiptRefNum, receipt);
                    MessageBox.Show(string.Concat(response));

                }
                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:updateReceipt>
    <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">b724babb0aa5d2be383af4c8c24ab0f33ebe14c9</HashValue>
    <Seed xsi:type="xsd:string">1278607173-test</Seed>
    <Type xsi:type="xsd:string">sha1</Type>
    </PinHash>
    <SourceKey xsi:type="xsd:string">_B4P7C4K2w2ZCQQQXRqrxDj6agrS2NIT</SourceKey>
    </Token>
    <ReceiptRefNum xsi:type="xsd:string">4</ReceiptRefNum>
    <Receipt xsi:type="ns1:Receipt">
    <Name xsi:type="xsd:string">Receipt58</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:updateReceipt>
    </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:updateReceiptResponse>
    <updateReceiptResponseReturn xsi:type="xsd:string">4</updateReceiptResponseReturn>
    </ns1:updateReceiptResponse>
    </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>

Change Log

Version Change
1.7 Changed ReceiptRefNum and ReturnValue to type string