3333use Paytrail \SDK \Response \RevertPaymentAuthHoldResponse ;
3434use Paytrail \SDK \Response \SettlementResponse ;
3535use Paytrail \SDK \Response \InvoiceActivationResponse ;
36+ use Paytrail \SDK \Response \InvoiceCancellationResponse ;
3637use Paytrail \SDK \Util \Signature ;
3738use Paytrail \SDK \Exception \HmacException ;
3839use Paytrail \SDK \Exception \ValidationException ;
@@ -782,13 +783,13 @@ function ($decoded) {
782783 }
783784
784785 /**
785- * Activate invoice created with manualInvoiceActivation set to true
786+ * Activate invoice created with manualInvoiceActivation set to true. Supported payment methods: Walley, Klarna
786787 *
787788 * @param string $transactionId
788789 * @return InvoiceActivationResponse
789790 * @throws HmacException
790791 */
791- public function activateInvoice (string $ transactionId )
792+ public function activateInvoice (string $ transactionId ): InvoiceActivationResponse
792793 {
793794 $ uri = "/payments/ {$ transactionId }/activate-invoice " ;
794795
@@ -809,6 +810,27 @@ function ($decoded) {
809810 );
810811 }
811812
813+ /**
814+ * Cancel invoice created with manualInvoiceActivation set to true. Supported payment methods: Klarna
815+ *
816+ * @param string $transactionId
817+ * @return InvoiceCancellationResponse
818+ * @throws HmacException
819+ */
820+ public function cancelInvoice (string $ transactionId ): InvoiceCancellationResponse
821+ {
822+ $ uri = "/payments/ {$ transactionId }/cancel-order " ;
823+
824+ $ response = $ this ->post ($ uri , null , null , $ transactionId );
825+
826+ $ decoded = json_decode ((string ) $ response ->getBody ());
827+
828+ return (new InvoiceCancellationResponse ())
829+ ->setStatus ($ decoded ->status )
830+ ->setMessage ($ decoded ->message )
831+ ->setHttpStatusCode ($ response ->getStatusCode ());
832+ }
833+
812834 /**
813835 * A proxy for the Signature class' static method
814836 * to be used via a client instance.
0 commit comments