processPayment()
PaymentResponse processPayment(string usn, PaymentRequest paymentRequest, AllocationRequest allocationRequest)
This method processes a payment, for example, contacting bank with details, and queues the debits to be allocated to the payment, pending the payment's success. No credit will be created if the payment is rejected.
Parameters
- usn
- Format: string
- paymentRequest
- Format: PaymentRequest XML
- allocationRequest
- Format: AllocationRequest XML
Example: Request a payment
This example shows a PaymentRequest document containing details for a Payway payment.
<PaymentRequest>
<PaymentDetails>
<PaymentType>payway</PaymentType>
<AccountNumber>1234567890</AccountNumber>
<PaymentAmount>2.00</PaymentAmount>
<IncludesSurchargeAmount>1.10</IncludesSurchargeAmount>
<BranchNumber></BranchNumber>
<ExpiryDate>2012-12</ExpiryDate>
<CVV>123</CVV>
<Properties>
<Object></Object>
</Properties>
</PaymentDetails>
</PaymentRequest>
Example: Request a payment for payment plan
<PaymentRequest>
<PaymentDetails>
<PaymentType>payway</PaymentType>
<AccountNumber>1234567890</AccountNumber>
<PaymentAmount>2.00</PaymentAmount>
<IncludesSurchargeAmount>1.10</IncludesSurchargeAmount>
<BranchNumber></BranchNumber>
<ExpiryDate>2012-12</ExpiryDate>
<CVV>123</CVV>
<Properties>
<Object></Object>
</Properties>
</PaymentDetails>
<PaymentPlan>1010</PaymentPlan>
</PaymentRequest>
Example: Request a payment allocation
This example shows an AllocationRequest document to allocate an amount of $0.90 against transaction 21707609.
<AllocationRequest>
<AllocateTo>
<TransactionNumber>21707609</TransactionNumber>
<AllocateAmount>0.90</AllocateAmount>
</AllocateTo>
</AllocationRequest>
Example: Request an auto-allocated payment
This example shows an AllocationRequest document with the <AutoAllocate> element set to true. Smile will allocate the payment to any debits on the account, starting with the oldest unpaid invoice, automatically.
<AllocationRequest>
<AutoAllocate>true</AutoAllocate>
</AllocationRequest>
Results
This method returns a PaymentResponse XML document that contains information about the status of the payment request.
Smile emits the TransactionClosed message when the payment is accepted. Smile emits the TransactionAllocated message when the payment is allocated.
Example: A returned PaymentResponse XML document
This example shows a returned PaymentResponse XML document. The document contains information about the payment and payment allocation and timestamped confirmation of payment receipt and surcharge.
<PaymentResponse xmlns:="http://xml.inomial.com/smile/2.xsd" xmlns:="http://ws.inomial.com/smile.2">
<Payment>
<PaymentNumber>61383006</PaymentNumber>
<PaymentType>
<PaymentTypeId>16</PaymentTypeId>
<Name>Westpac PayWay</Name>
<PaymentTypeCode>payway</PaymentTypeCode>
</PaymentType>
<Account>1000000008</Account>
<Amount formatted="$2.00" currency="AUD">2.00</Amount>
<Surcharge>
<Amount formatted="$1.10" currency="AUD">1.10</Amount>
<TaxAmount formatted="$0.10" currency="AUD">0.10</TaxAmount>
</Surcharge>
<Status>Accepted</Status>
</Payment>
<Allocation>
<AllocateTo>
<TransactionNumber>61383105</TransactionNumber>
<AllocateAmount formatted="$1.10" currency="AUD">1.10</AllocateAmount>
</AllocateTo>
<AllocateTo>
<TransactionNumber>21707609</TransactionNumber>
<AllocateAmount formatted="$0.90" currency="AUD">0.90</AllocateAmount>
</AllocateTo>
</Allocation>
<Receipt>
<version>2.0</version>
<transactionType>Receipt</transactionType>
<company>1</company>
<usn>1000000008</usn>
<transactionNumber>61383006</transactionNumber>
<currency>AUD</currency>
<amount>-2.00</amount>
<accountType>1</accountType>
<gstAmount>0.00</gstAmount>
<entryTimestamp>2012-12-17T09:51:17.868+11:00</entryTimestamp>
<formattedAmount currency="AUD" formatted="$(2.00)">-2.00</formattedAmount>
<formattedGstAmount currency="AUD" formatted="$0.00">0.00</formattedGstAmount>
<unallocatedAmount>0.00</unallocatedAmount>
<enteredByUsn>2142423066</enteredByUsn>
<logTimestamp>2012-12-17T09:51:17.870+11:00</logTimestamp>
<glCode>083</glCode>
<formattedUnallocatedAmount currency="AUD" formatted="$0.00">0.00</formattedUnallocatedAmount>
</Receipt>
<Surcharge>
<version>2.0</version>
<transactionType>Surcharge</transactionType>
<company>1</company>
<usn>1000000008</usn>
<transactionNumber>61383105</transactionNumber>
<currency>AUD</currency>
<amount>1.10</amount>
<accountType>1</accountType>
<gstAmount>0.10</gstAmount>
<entryTimestamp>2012-12-17T09:51:17.868+11:00</entryTimestamp>
<salesReportCategory>surchrg</salesReportCategory>
<formattedAmount currency="AUD" formatted="$1.10">1.10</formattedAmount>
<formattedGstAmount currency="AUD" formatted="$0.10">0.10</formattedGstAmount>
<unallocatedAmount>0.00</unallocatedAmount>
<enteredByUsn>2142423066</enteredByUsn>
<logTimestamp>2012-12-17T09:51:18.367+11:00</logTimestamp>
<glCode>200</glCode>
<formattedUnallocatedAmount currency="AUD" formatted="$0.00">0.00</formattedUnallocatedAmount>
</Surcharge>
</PaymentResponse>
Faults
InvalidRequestExceptionThis fault is returned when PaymentRequest or AllocationRequest are invalid.
NoSuchItemExceptionThis fault is returned when the USN, PaymentRequest or AllocationRequest refer to an object that cannot be found.
Java client syntax
java -cp build/smilewsv2-client.jar [options] com.inomial.smile.client.v2.examples.ProcessPayment usn paymentRequest allocationRequest
- usn
- Purpose: Specifies the USN of the account.
- paymentRequest
- Purpose: Defines the path to the XML document containing the payment request.
- allocationRequest
- Purpose: Defines the path to the XML document containing the allocation request.