Giter VIP home page Giter VIP logo

php-xmlrpc's Introduction

Klarna XMLRPC PHP SDK (DEPRECATED)

Packagist Version

Deprecation notice

This repo has been marked as deprecated. The SDK is not longer supported.
Please use https://github.com/klarna/kco_rest_php SDK instead.

About Klarna

Klarna was founded in Stockholm in 2005 with the idea of providing a zero-friction online payment solution that would allow consumers and merchants to interact with each other as safely and simply as possible. We do this by letting the consumer receive the goods first and pay afterwards, while we assume the credit and fraud risks for the merchants. Today, Klarna is one of Europe's fastest growing companies. In just 8 years, we've grown to 800 employees operating in 7 European countries with over 8 million consumers. But we are not satisfied with that. Our goal is to become market leaders within invoice-based payments worldwide and change the way the world shops online.

Get started

Prerequisites

  • PHP 5.4.0 or above
  • API credentials

Usage

Example files can be found in the docs/ directory.

Documentation

Documentation and more examples can be found at developers.klarna.com.

Upgrading

If you are upgrading from version 4 or earlier you can read more about it in docs/UPGRADE_v5.md

Questions and feedback

If you have any questions concerning this product or the implementation, please contact [email protected].

How to contribute

At Klarna, we strive toward achieving the highest possible quality for our products. Therefore, we require you to follow these guidelines if you wish to contribute.

To contribute, the following criteria needs to be fulfilled:

  • Description regarding what has been changed and why
  • Pull requests should implement a boxed change
  • All code and documentation must follow the PEAR coding standards
  • All classes must follow the PSR-0 standard

License

The Klarna XMLRPC PHP SDK is released under Apache License, Version 2.0

php-xmlrpc's People

Contributors

alexions avatar backendtea avatar bubach avatar joakimlofgren avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-xmlrpc's Issues

Use static::printDebug('... instead of self::printDebug('... to allow Late Static Bindings

In order to allow Late Static Bindings usage you have to use
static::printDebug('... instead of self::printDebug('...

In this case I will be able to overwrite your static method like this

class XCKlarna extends Klarna\XMLRPC\Klarna {
    public static function printDebug($msg, $mixed) {//{{{
        if (defined('XC_KLARNA_DEBUG')) {
            x_log_add('klarna', "{$msg}: \n" . print_r($mixed, true));
        }
    }//}}}
}

http://stackoverflow.com/questions/18848373/php-overwriting-of-static-methods-does-not-work-as-expected

Invalid return payload: enable debugging to examine incoming payload (XML error at line 1, check URL) (Error code: 2)

Hello,
after the installation of the plugin "WooCommerce Klarna Gateway v2.0" we entered the “Eid – Germany ” and the “Shared Secret – Germany” with the help of the Klarna support.

Now, if we generate an ordner, we geht the error message:

“XML-RPC Fault #2: Invalid return payload: enable debugging to examine incoming payload.”

The Klarna support cannot solve the problem.

WP Version: 4.5.2
Server Info: Apache/2.2.31 (Unix)
PHP Version: 7.0.6
MySQL Version: 5.5.48
WC Database Version: 2.5.5

When i go to xmlrpc.php the browser shows: "XML-RPC server accepts POST requests only."

Has anybody an idea. ?

segfaults on throwing Exception

There is a Bug in PHP 5.6 which produces segfaults when you throw an exception encoded in ISO-8859-1 on a system with default charset UTF-8.

Throwing a KlarnaException caused by response faultCode !== 0 and faultString (ISO-8859-1) results in segfaults in apache child process.

Example:
https://github.com/klarna/php-xmlrpc/blob/v4.1/src/Klarna.php#L3661

To prevent this, you could use something like this:

throw new KlarnaException(
    iconv('ISO-8859-1//TRANSLIT', ini_get('default_charset'), $xmlrpcresp->faultString()), 
    $status
);

Tested on:

  • Linux 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt20-1+deb8u4 (2016-02-29) x86_64
  • Apache/2.4.10 (Debian)
  • PHP Version 5.6.17-0+deb8u1
  • Default Charset: UTF-8

Test:

throw new Exception(iconv(ini_get('default_charset'), 'ISO-8859-1', 'ß'));

Have Klarna::setAddress accept one call to set both Billing and Shipping Address

Currently, Klarna::setAddress will only accept an address, if either the flag Flags::IS_SHIPPING or Flags::IS_BILLING has been set (eg: $k->setAddress(Flags::IS_SHIPPING, $addr);)
If both of these flags are set in the same call, it will refuse to accept an address passed to the function. (eg: $k->setAddress(Flags::IS_SHIPPING & Flags::IS_BILLING, $addr);)

Is it possible to extend the functionality of Klarna::setAddress to allow both flags to be set, and set both the Billing and Shipping addresses at the same time?

Klarna::update does not clear data even if $clear is true

Hi,

While reworking some code using this library we detected a problem where some invoices ended up with data from other orders as well, and after some investigation we found that the update-function in the Klarna class doesn't actually clear the object afterwards ($clear isn't used at all in that function), even thou the $clear-flag is set (by default) to true. Other similar functions like activate or reserveAmount does this, which makes me believe this is by omission.

PHP 7 deprecation errors

Using this library with PHP 7 triggers several deprecation errors. Example:

Methods with the same name as their class will not be constructors in a future version of PHP; 
xmlrpc_client has a deprecated constructor

I have reported the issue to the phpxmlrpc project and they recommend updating to version 4.0.

Typo in namespace on line 86 of CurlTransport.php

throw new Exceptions\KlarnaException(

Should read

throw new Exception\KlarnaException(

This typo causes a fatal error when there is an issue with the connection:
Fatal error: Class 'Klarna\XMLRPC\Exceptions\KlarnaException' not found in /home/lsash/public_html/vendor/klarna/php-xmlrpc/src/Klarna/XMLRPC/CurlTransport.php on line 86

KlarnaException might contain invalid characters

Bug description:

KlarnaException which can be attempted to be thrown at line of 3669 of Klarna.php might contain possibly invalid characters from incorrectly interpreted faultString().

Suggested bug fix:

Pull request: #1

Use namespaces

This library doesn't work very well to include into a namespaced project, since the library itself doesn't make use of namespaces. Our project uses Laravel, which can autoload libraries. However it can't autoload this library since it doesn't use namespace. Therefore we have to use functions like require to include the library, which doesn't look very good.

Is there any plan for refactoring this library to make use of namespaces, instead of putting it all in the global namespace?

Project structure

With current file structure, this library is almost unusable in projects. Lets consider following example project structure:

|-- app/
  |-- app.php
|-- lib/

Project adheres to PSR-0 standard, lib/ is added to include path, so including this library should be straightforward. Since classes in this library are not scoped under directory (Klarna/Invoice/ perhaps?), after adding it, project would look something like this:

|-- app/
  |-- app.php
|-- lib/
  |-- Klarna/
    |-- ...
  |-- Klarna.php
  |-- KlarnaAddr.php
  |-- ...

Which looks messy to say at least. If we consider using this library alongside kco_php library (much better one btw, real joy working with it), that's when the things get out of hand:

|-- app/
  |-- app.php
|-- lib/
  |-- Klarna/
    |-- Checkout/
      |-- ...
    |-- Checkout.php
    |-- ArgumentNotSetException.php
    |-- ...
  |-- Klarna.php
  |-- KlarnaAddr.php
  |-- ...

Libraries get merged into one messy blob of files, making it so much harder to work with them. I would also like to add that this is not some hypothetical scenario, which is unlikely to happen. Project structure used in this example is oversimplified structure of popular e-commerce framework and using these two two libraries together is almost unavoidable.

As a solution, I see scoping this library under Klarna/Invoice/, as mentioned above. That would result in a following project structure:

|-- app/
  |-- app.php
|-- lib/
  |-- Klarna/
    |-- Checkout/
      |-- ...
    |-- Invoice/
      |-- ...
    |-- Checkout.php

Which looks much, much better. This would also require some class name changes, to keep the PSR-0, which would than in turn mean that next version would not be backward compatible. Is such a change realistic? If not, I'd like to hear suggestions, which approach should one take to be able to use this library?

Verification of SSL Issuer "thawte SSL CA - G2" fails on Debian 8

This issue is not really related to Klarna/PHP-XMLRPC but I guess it's good to know:

This curl exception will be thrown: CURL error: SSL certificate problem: unable to get local issuer certificate when doing request as following:

---CURL INFO---
url: https://payment.testdrive.klarna.com:443/
content_type: 
http_code: 0
header_size: 0
request_size: 0
filetime: -1
ssl_verify_result: 1
redirect_count: 0
total_time: 0.635116
namelookup_time: 0.528931
connect_time: 0.575807
pretransfer_time: 0
size_upload: 0
size_download: 0
speed_download: 0
speed_upload: 0
download_content_length: -1
upload_content_length: -1
starttransfer_time: 0
redirect_time: 0
redirect_url: 
primary_ip: 88.80.182.203
certinfo: 
primary_port: 443
local_ip: 10.20.1.24
local_port: 39457
---END---

System:

  • Linux 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt20-1+deb8u4 (2016-02-29) x86_64
  • Apache/2.4.10 (Debian)
  • PHP Version 5.6.17-0+deb8u1

Curl-Info from php -i:

cURL support => enabled
cURL Information => 7.38.0
Age => 3
Features
AsynchDNS => Yes
CharConv => No
Debug => No
GSS-Negotiate => No
IDN => Yes
IPv6 => Yes
krb4 => No
Largefile => Yes
libz => Yes
NTLM => Yes
NTLMWB => Yes
SPNEGO => Yes
SSL => Yes
SSPI => No
TLS-SRP => Yes
Protocols => dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, ldaps, pop3, pop3s, rtmp, rtsp, scp, sftp, smtp, smtps, telnet, tftp
Host => x86_64-pc-linux-gnu
SSL Version => OpenSSL/1.0.1k
ZLib Version => 1.2.8
libSSH Version => libssh2/1.4.3

There seems to be no way to register a CA Root Certificate on the fly for requests against Klarna API. You need to set curl.cainfo for cURL in php.ini globally to resolve this issue since Klarna/XMLRPC/Klarna isolates its instance of PhpXmlRpc\Client completely.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.