Handling Receipts
If you wish to show your own receipt view after a payment is complete, then implement the ReceiptDelegate
and return an empty list for supportedReceiptTypes
. When the payment is complete you can then show your own screen.
By default if you do not implement the ReceiptDelegate
, the receipt screen will show with sms and email receipt types available, and sending the receipts will be handled by YocoSDK.
Pass a ReceiptDelegate
into PaymentParameters
to allow the SDK to provide a base for you where you can implement specific functionality, which should then be handled in your app.
Step 1: Implement the Receipt Delegate
You will need to implement the ReceiptDelegate
to listen for callbacks from the receipt screen
Step 2: Register the Delegate
You will need to pass the ReceiptDelegate
to the SDK as part of the PaymentConfig
Step 3: Implement Optional functions
To get notified of the receipt button presses from the receipt screen (Provided by the SDK), you will need to implement the callback functions that is linked to the ReceiptType
that you have specified in the supportedReceiptTypes()
function.
Supported Receipt Types
Receipt Type | Value | Callback |
---|---|---|
Sms | ReceiptType.SMS | sendSMSReceipt(context: Context, number: String, paymentResult: PaymentResult, progress: UpdateReceiptProgress) |
ReceiptType.EMAIL | sendEmailReceipt(context: Context, address: String, paymentResult: PaymentResult, progress: UpdateReceiptProgress) | |
ReceiptType.PRINT | printReceipt(printOnDevice: Boolean, paymentResult: PaymentResult, progress: UpdateReceiptProgress) |
It is up to you to decide how the receipt is handled. In each callback, it will provide you with a progress
parameter - this allows you to control the receipt screen's selected button state.
It will also provide the current PaymentResult with the info related to the transaction result.
Receipt State
The receipt state can be changed multiple times, as long as you keep calling the state using the progress parameter. Each state represents a view change for the specific button [Initial (default), Valid, In progress, Error, Complete]