addReceipt

Parent Previous Next

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

 

Syntax

integer 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

 

integer

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

 

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

 

Dim receipt As eBizCharge.Receipt = New eBizCharge.Receipt

       receipt.Name = "test receipt_VB"

       receipt.Target = "email"

       receipt.Subject = "test receipt"

       receipt.FromEmail = "devsupport@eBizCharge.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#

 

          eBizCharge.Receipt receipt = new eBizCharge.Receipt();

           receipt.Name = "test receipt";

           receipt.Target = "email";

           receipt.Subject = "test receipt";

           receipt.FromEmail = "devsupport@eBizCharge.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:eBizCharge" 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">192.168.0.1</ClientIP>

<PinHash xsi:type="ns1:ueHash">

<HashValue xsi:type="xsd:string">11ac55b0a0b59f8f028dbf85bc32266fa973dd0e</HashValue>

<Seed xsi:type="xsd:string">12678150211876663375</Seed>

<Type xsi:type="xsd:string">sha1</Type>

</PinHash>

<SourceKey xsi:type="xsd:string">HB4P7C4K2w2ZCQQQXRqrxDj6agrS2NIT</SourceKey>

</Token>

 <Receipt xsi:type="ns1:Receipt">

   <Name xsi:type="xsd:string">addReceipt1909111717</Name>

   <Subject xsi:type="xsd:string">1561375697</Subject>

   <FromEmail xsi:type="xsd:string">test@test22.com</FromEmail>

   <Target xsi:type="xsd:string">email</Target>

   <ContentType xsi:type="xsd:string">both</ContentType>  

   <TemplateHTML xsi:type="xsd:string">WWlwcGUgc2tpcHB5ICBbVHJhbnNhY3Rpb24uQ3JlYXRlZF0=</TemplateHTML>

   <TemplateText xsi:type="xsd:string">WWlwcGUgc2tpcHB5ICBbVHJhbnNhY3Rpb24uQ3JlYXRlZF0=</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:eBizCharge"

 xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"

 xmlns:xsd="http://www.w3.org/2001/XMLSchema"

 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

 SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">

<SOAP-ENV:Body>

<ns1:addReceiptResponse>

 <addReceiptResponseReturn xsi:type="xsd:integer">32</addReceiptResponseReturn>

</ns1:addReceiptResponse>

</SOAP-ENV:Body>

</SOAP-ENV:Envelope>

: