developer:soap-1.4:methods:addreceipt

Soap API v1.4

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.

See also updateReceipt, getReceipt, deleteReceipt, emailTransactionReceipt, emailTransactionReceiptByName

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

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 usaepay.Receipt = New usaepay.Receipt
        receipt.Name = "test receipt_VB"
        receipt.Target = "email"
        receipt.Subject = "test receipt"
        receipt.FromEmail = "devsupport@usaepay.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.

           usaepay.Receipt receipt = new usaepay.Receipt();
            receipt.Name = "test receipt";
            receipt.Target = "email";
            receipt.Subject = "test receipt";
            receipt.FromEmail = "devsupport@usaepay.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:usaepay" 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:usaepay" 
  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>

Change History

Version Change
1.3 Method added in this release
developer/soap-1.4/methods/addreceipt.txt · Last modified: 2010/09/03 14:35 by irina

Page Tools