Post by web_2012 » Tue Jul 24, 2018 8:28 pm

Hi, I want to delete Klarna Invoices over the Klarna OpenCart 2.0 Modul.

Adding an order works like this:

Code: Select all

 $transaction = array(
                '4.1',
                'API:OPENCART:' . VERSION,
                $pno,
                $gender,
                '',
                '',
                (string)$order_info['order_id'],
                '',
                $address,
                $address,
                $order_info['ip'],
                0,
                $currency,
                $country,
                $language,
                (int)$klarna_invoice[$order_info['payment_iso_code_3']]['merchant'],
                $digest,
                $encoding,
                $pclass,
                $goods_list,
                $order_info['comment'],
                array('delay_adjust' => 1),
                array(),
                array(),
                array(),
                array(),
                array()
            );

            $xml  = '<methodCall>';
            $xml .= '  <methodName>add_invoice</methodName>';
            $xml .= '  <params>';

            foreach ($transaction as $parameter)  {
                $xml .= '    <param><value>' . $this->constructXmlrpc($parameter) . '</value></param>';
            }

            $xml .= '  </params>';
            $xml .= '</methodCall>';

            $header = array();

            $header[] = 'Content-Type: text/xml';
            $header[] = 'Content-Length: ' . strlen($xml);

            $curl = curl_init();

            curl_setopt($curl, CURLOPT_URL, $url);
            curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
            curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
            curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
            curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
            curl_setopt($curl, CURLOPT_POSTFIELDS, $xml);

            $response = curl_exec($curl);
The Klarna support can't help me because the don't support OpenCart. The only hint they gave me was to use the delete_invoice function with the invoice number.

I was trying it like this:

Code: Select all

                $xml  = '<methodCall>';
            $xml .= '  <methodName>delete_invoice</methodName>';
            $xml .= '  <params>';

                $xml .= '    <param><value>3458767058974000000</value></param>';

            $xml .= '  </params>';
            $xml .= '</methodCall>';

            $header = array();

            $header[] = 'Content-Type: text/xml';
            $header[] = 'Content-Length: ' . strlen($xml);

            $curl = curl_init();

            curl_setopt($curl, CURLOPT_URL, $url);
            curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
            curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
            curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
            curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
            curl_setopt($curl, CURLOPT_POSTFIELDS, $xml);

            $response = curl_exec($curl);

            curl_close($curl);
with invoice_delete and invoice number, but the invoice will not be deleted.

Does anyone have an idea, why this don't work?

Greetings

Newbie

Posts

Joined
Thu Aug 02, 2012 2:58 pm

Post by straightlight » Wed Jul 25, 2018 12:44 am

Posted in the v3.x releases section of the forum.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.

F. Rules:

- viewtopic.php?f=176&t=200480
- viewtopic.php?f=176&t=200804


Regards,
Straightlight


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 12 guests