Git Product home page Git Product logo

mangopay2-php-sdk's Introduction

MANGOPAY PHP SDK mangopay2-php-sdk-cd Latest Stable Version Total Downloads License

MangopaySDK is a PHP client library to work with Mangopay REST API.

Compatibility Notes

  • Since v2.1 of this SDK, you must be using at least v2.01 of the API (more information about the changes required)
  • If you experience problems with authentification and/or the temporary token file following an SDK update (particularly updating to v2.0 of the SDK), you may need to just delete your temporary file (that you specify with $api->Config->TemporaryFolder) - which allows it to be regenerated correctly the next time it's needed

Requirements

To use this SDK, you will need (as a minimum):

  • PHP 5.6 or newer
  • cURL (included and enabled in a standard PHP distribution)
  • OpenSSL (included and enabled in a standard PHP distribution)
  • psr/log v1.0
  • You do not have to use Composer, but you are strongly advised to (particularly for handling the dependency on the PSR Log library)

Installation with Composer

You can use Mangopay SDK library as a dependency in your project with Composer (which is the preferred technique). Follow these installation instructions if you do not already have Composer installed. A composer.json file is available in the repository and it has been referenced from Packagist.

The installation with Composer is easy and reliable:

Step 1 - Add the Mangopay SDK as a dependency by executing the following command:

you@yourhost:/path/to/your-project$ composer require mangopay/php-sdk-v2

Step 2 - Update your dependencies with Composer

you@yourhost:/path/to/your-project$ composer update

Step 3 - Finally, be sure to include the autoloader in your project

require_once '/path/to/your-project/vendor/autoload.php';

The Library has been added into your dependencies and is ready to be used.

Installation without Composer

The project attempts to comply with PSR-4 specification for autoloading classes from file paths. As a namespace prefix is MangoPay\ with base directory /path/to/your-project/.

If you're not using PSR-4 or Composer, the installation is as easy as downloading the library and storing it under any location that will be available for including in your project (don't forget to include the required library dependencies though):

    require_once '/path/to/your-project/MangoPay/Autoloader.php';

Alternatively you can download the package in its entirety (ie with all required dependencies) from the Releases page (look for the mangopay2-php-sdk-[RELEASE_NAME].zip file). Uncompress the zip file you download, and include the autoloader in your project:

    require_once '/path/to/your-project/mangopay2-php-sdk/vendor/autoload.php';

License

MangopaySDK is distributed under MIT license, see the LICENSE file.

Unit Tests

Tests are placed under /path/to/your-project/tests/. The /tests/suites/all.php suite runs ALL tests. You can also use any of /tests/cases/*.php to run a single test case.

Contacts

Report bugs or suggest features using issue tracker on GitHub.

Account creation

You can get yourself a free sandbox account or sign up for a production account by registering on the Mangopay site (note that validation of your production account involves several steps, so think about doing it in advance of when you actually want to go live).

Configuration

Using the credential info from the signup process above, you should then set $api->Config->ClientId to your Mangopay ClientId and $api->Config->ClientPassword to your Mangopay APIKey.

You also need to set a folder path in $api->Config->TemporaryFolder that SDK needs to store temporary files. This path should be outside your www folder. It could be /tmp/ or /var/tmp/ or any other location that PHP can write to. You must use different folders for your sandbox and production environments.

$api->Config->BaseUrl is set to sandbox environment by default. To enable production environment, set it to https://api.mangopay.com.

require_once '/path/to/your-project/vendor/autoload.php';
$api = new MangoPay\MangoPayApi();

// configuration
$api->Config->ClientId = 'your-client-id';
$api->Config->ClientPassword = 'your-client-password';
$api->Config->TemporaryFolder = '/some/path/';
//$api->Config->BaseUrl = 'https://api.mangopay.com';//uncomment this to use the production environment

//uncomment any of the following to use a custom value (these are all entirely optional)
//$api->Config->CurlResponseTimeout = 20;//The cURL response timeout in seconds (its 30 by default)
//$api->Config->CurlConnectionTimeout = 60;//The cURL connection timeout in seconds (its 80 by default)
//$api->Config->CertificatesFilePath = ''; //Absolute path to file holding one or more certificates to verify the peer with (if empty, there won't be any verification of the peer's certificate)

// call some API methods...
try {
    $users = $api->Users->GetAll();
} catch(MangoPay\Libraries\ResponseException $e) {
    // handle/log the response exception with code $e->GetCode(), message $e->GetMessage() and error(s) $e->GetErrorDetails()
} catch(MangoPay\Libraries\Exception $e) {
    // handle/log the exception $e->GetMessage()
}

Sample usage

require_once '/path/to/your-project/vendor/autoload.php';
$api = new MangoPay\MangoPayApi();

// configuration
$api->Config->ClientId = 'your-client-id';
$api->Config->ClientPassword = 'your-client-password';
$api->Config->TemporaryFolder = '/some/path/';

// get some user by id
try {
    $john = $api->Users->Get($someId);
} catch(MangoPay\Libraries\ResponseException $e) {
    // handle/log the response exception with code $e->GetCode(), message $e->GetMessage() and error(s) $e->GetErrorDetails()
} catch(MangoPay\Libraries\Exception $e) {
    // handle/log the exception $e->GetMessage()
}

// change and update some of his data
$john->LastName .= " - CHANGED";
try {
    $api->Users->Update($john);
} catch(MangoPay\Libraries\ResponseException $e) {
    // handle/log the response exception with code $e->GetCode(), message $e->GetMessage() and error(s) $e->GetErrorDetails()
} catch(MangoPay\Libraries\Exception $e) {
    // handle/log the exception $e->GetMessage()
}

// get all users (with pagination)
$pagination = new MangoPay\Pagination(1, 8); // get 1st page, 8 items per page
try {
    $users = $api->Users->GetAll($pagination);
} catch(MangoPay\Libraries\ResponseException $e) {
    // handle/log the response exception with code $e->GetCode(), message $e->GetMessage() and error(s) $e->GetErrorDetails()
} catch(MangoPay\Libraries\Exception $e) {
    // handle/log the exception $e->GetMessage()
}

// get his bank accounts
$pagination = new MangoPay\Pagination(2, 10); // get 2nd page, 10 items per page
try {
    $accounts = $api->Users->GetBankAccounts($john->Id, $pagination);
} catch(MangoPay\Libraries\ResponseException $e) {
    // handle/log the response exception with code $e->GetCode(), message $e->GetMessage() and error(s) $e->GetErrorDetails()
} catch(MangoPay\Libraries\Exception $e) {
    // handle/log the exception $e->GetMessage()
}

Sample usage with Composer in a Symfony project

You can integrate Mangopay features in a Service in your Symfony project.

MangoPayService.php :

<?php

namespace Path\To\Service;

use MangoPay;


class MangoPayService
{

    private $mangoPayApi;

    public function __construct()
    {
        $this->mangoPayApi = new MangoPay\MangoPayApi();
        $this->mangoPayApi->Config->ClientId = 'your-client-id';
        $this->mangoPayApi->Config->ClientPassword = 'your-client-password';
        $this->mangoPayApi->Config->TemporaryFolder = '/some/path/';
        //$this->mangoPayApi->Config->BaseUrl = 'https://api.sandbox.mangopay.com';
    }

    /**
     * Create Mangopay User
     * @return MangopPayUser $mangoUser
     */
    public function getMangoUser()
    {

        $mangoUser = new \MangoPay\UserNatural();
        $mangoUser->PersonType = "NATURAL";
        $mangoUser->FirstName = 'John';
        $mangoUser->LastName = 'Doe';
        $mangoUser->Birthday = 1409735187;
        $mangoUser->Nationality = "FR";
        $mangoUser->CountryOfResidence = "FR";
        $mangoUser->Email = '[email protected]';

        //Send the request
        $mangoUser = $this->mangoPayApi->Users->Create($mangoUser);

        return $mangoUser;
    }
}

Logging

MangoPay uses the PSR3 LoggerInterface. You can provide your own logger to the API. Here is a sample showing Monolog integration :

use Monolog\Logger;
use Monolog\Handler\StreamHandler;

...

$logger = new Logger('sample-logger');
$logger->pushHandler(new StreamHandler($logConfig['path'], Logger::DEBUG));

$this->mangoPayApi = new MangoPay\MangoPayApi();
$this->mangoPayApi->setLogger($logger);

Verifying rate limits status

According to API docs (https://docs.mangopay.com/guide/rate-limiting), MangoPay is providing a way of verifying how many API calls were made, how many are left and when the counter will be reset. So there are 4 groups of rate limits available:

  1. Last 15 minutes:
  2. Last 30 minutes
  3. Last 60 minutes
  4. Last 24 hours

This information is available from the MangoPayApi instance, like in the following example:

<?php

namespace Path\To\Service;

use MangoPay;


class MangoPayService
{

    /**
    * @var MangoPay\MangoPayApi
    */
    private $mangoPayApi;

    public function __construct()
    {
        $this->mangoPayApi = new MangoPay\MangoPayApi();
        $this->mangoPayApi->Config->ClientId = 'your-client-id';
        $this->mangoPayApi->Config->ClientPassword = 'your-client-password';
        $this->mangoPayApi->Config->TemporaryFolder = '/some/path/';
        //$this->mangoPayApi->Config->BaseUrl = 'https://api.sandbox.mangopay.com';
    }

    public function verifyRateLimits()
    {
        // This is an array of 4 RateLimit objects.
        $rateLimits = $this->mangoPayApi->RateLimits;
        print "\nThere were " . $rateLimits[0]->CallsMade . " calls made in the last 15 minutes";
        print "\nYou can do " . $rateLimits[0]->CallsRemaining . " more calls in the next 15 minutes";
        print "\nThe 60 minutes counter will reset at " . date("Y-m-d\TH:i:s\Z", $rateLimits[0]->ResetTimeTimestamp);
        print "\nThere were " . $rateLimits[2]->CallsMade . " calls made in the last 60 minutes";
        print "\nYou can do " . $rateLimits[2]->CallsRemaining . " more calls in the next 60 minutes";
        print "\nThe 60 minutes counter will reset at " . date("Y-m-d\TH:i:s\Z", $rateLimits[2]->ResetTimeTimestamp);
    }
}

mangopay2-php-sdk's People

Stargazers

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

Watchers

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

mangopay2-php-sdk's Issues

Execution date Issue

I have create payin at 18:56 07/04/2015 but it show me Execution date at 16:56 07/04/2015.
How to fix timezone issue?

contributions/immediate-contribution is missing in SDK ?

Hi,
I am new to Mangopay...I have a requirement to create a split payment, as per API document I understood that it can be done using contributions or immediate-contribution method.

// API managers
$this->AuthenticationManager = new ApiOAuth($this);
$this->Clients = new ApiClients($this);
$this->Users = new ApiUsers($this);
$this->Wallets = new ApiWallets($this);
$this->Transfers = new ApiTransfers($this);
$this->PayIns = new ApiPayIns($this);
$this->PayOuts = new ApiPayOuts($this);
$this->Refunds = new ApiRefunds($this);
$this->CardRegistrations = new ApiCardRegistrations($this);
$this->Cards = new ApiCards($this);
$this->Events = new ApiEvents($this);

In the above list I am not able see those methods.Can someone please help me to create split payment.

Thanks in Advance.....

errorCode=09101 : getting this while checking with live server. (at production)

Hi i am using my real card and try to check online payment but i am getting this error.
Everything works fine in sandbox enviroment but while i chnage to live an dtest with real server then i get this error. i go to this error code but where i was wrong i am not getting becouse the ClientID and Password is correct,

My output while card created is
{
AcessKey = 9gHbl11np1yjYhuKF51T;
CardRegistrationURL = "https://webpayment.payline.com/webpayment/getToken";
CreationDate = 1428129041;
Currency = EUR;
PreregistrationData = "I5-F6i4odDiWz3S0GQmyulSYND7gjZqEdIbNoaXh3zu-3OYM0vwsNKu7gM0Kx2KFUE6onk55MkkuWPry3Tn84w";
Status = CREATED;
UserId = 17431574;
cardID = cardID;
errorMsg = "";
mangoPayUserId = mangopayUserID;
status = 1;
}

and whle i update card at that time

[UserId] => 17431574
[AccessKey] => 9gHbl11np1yjYhuKF51T
[PreregistrationData] => I5-F6i4odDiWz3S0GQmyulSYND7gjZqEdIbNoaXh3zu-3OYM0vwsNKu7gM0Kx2KFUE6onk55MkkuWPry3Tn84w
[CardRegistrationURL] => https://webpayment.payline.com/webpayment/getToken
[CardId] => 
[RegistrationData] => errorCode=09101
[ResultCode] => 105299
[ResultMessage] => Token input Error
[Currency] => EUR
[Status] => ERROR
[Id] => cardID
[Tag] => 
[CreationDate] => 1428129041

some info here i hide as mangopayUserID and cardID for security.. what is incorrect an d where i am going wrong

SDK different than the official documentation

Hi,

Thank you for your work on the SDK of the MangoPay API.

Under the API official documentation of the PayIn feature in the CREATE (POST) tab, it "says" through the response that the RedirectURL parameter is directly accessible from the JSON result Object.

But it actually requires to dereference the ExecutionDetails field of the PayIns object ExecutionDetails->RedirectURL and not RedirectURL directly

Is the documentation wrong, or the SDK?

Thank you.

Regards

\MangoPay\Exception: Wrong entity class for user

Hello

i can't create natural user ,

my post is

stdClass Object
(
[FirstName] => jam
[LastName] => xyz
[Email] => [email protected]
[Address] => adajan, surat.
[Birthday] => 1428666100
[Nationality] => FR
[CountryOfResidence] => FR
[Occupation] => programmer
[IncomeRange] => 3
)

Error on legal user create

In mangopay2-php-sdk / demos / api / htmlHelper.php row 230

     if (isset($_POST[$frmName]) && strlen($_POST[$frmName]) > 0) {

            // special fields for Owners property
            if ($entityName == 'Wallet' && $name == 'Owners')
                $entity->$name = explode(';', $_POST[$frmName]);
            // special cast to int for Birthday property in UserNatural class
            elseif ($entityName == 'UserNatural' && $name == 'Birthday')
                $entity->$name = (int)$_POST[$frmName];
            // normal fields
            else
                $entity->$name = $_POST[$frmName];

            $touchedAnyProp = true;
        }

i thing this elseif:

        elseif ($entityName == 'UserNatural' && $name == 'Birthday')

should be

       elseif (($entityName == 'UserNatural' && $name == 'Birthday')||($entityName == 'UserLegal' && $name == 'LegalRepresentativeBirthday'))

trying the second code, it create successfully the legal user, instead the first code throw an error on LegalRepresentativeBirthday

Daniele Paiano - Simone Bestazza

transfer money from User wallet to Client Wallet

Hi,
I use mangopay on my marketplace. I would like to add some "Bonus" into this marketplace. These bonus allows users to improve their visibility on my website.
To have an access to this Bonus, Users have to pay.

Let's take an example:
Bonus 1 = 4.99€

When a User choose the Bonus 1, my App create a Pay-IN with:
amount = 4.99€
fees = 0€
and it works

In this case, I get the whole amount, not fees, but I didn't find how to create a "transfer" from the User's Wallet to my Client Wallet.

Is there a solution ? Thx.

Add method __toString() to MangoPay\Libraries\Error

The MangoPay\Libraries\Error doesn't have a method __toString() so I cannot convert easy error messages to string when I catch a ResponseException since it is a stdClass object and the only solution is serialize or parse the object.

For example:

use MangoPay\Libraries\ResponseException;
use MangoPay\Libraries\Logs as MangoLog;
use MangoPay\Libraries\Exception as MangoException;

// my controller code

// ...

try 
{
    $bankAccount = $mangopay->createBankAccount($user, $details);
}
catch(ResponseException $e) 
{
    MangoLog::Debug('MangoPay\ResponseException Code', $e->GetCode());
    MangoLog::Debug('Message', $e->GetMessage());
    MangoLog::Debug('Details', $e->GetErrorDetails());

    $mangoErrorMessage = 'MangoPay[' . intval($e->GetCode()) . ']: ' . $e->GetMessage() . ' <br />' . serialize($e->GetErrorDetails()->Errors);
    redirect(route('someroute'))->with('error_message', $mangoErrorMessage);
} 
catch(MangoException $e) 
{
    MangoLog::Debug('MangoPay\Exception Message', $e->getTraceAsString());

    $mangoErrorMessage = 'MangoPay[' . intval($e->getCode()) . ']: ' . $e->getTraceAsString();
    redirect(route('someroute'))->with('error_message', $mangoErrorMessage);
}

As you see, I have to use serialize($e->GetErrorDetails()->Errors), because I didn't have a getErrors() or a way to __toString() in that class and Log::Debug is is mostly using a print_r() for this situations that is not good if you want store it in a variable and show as error message in a webapp or store it in a log file.

So actually using a contatenation in a string like:

$myvar = 'Some message: ' . $e->GetErrorDetails()->Errors . ' oops'; 

Will give you a FatalError exception and breaks all the app.

This is probably a easy change and add that methods will not make a BC I think.

PayInDirectCard - Error 400 Bad Request

Hi,

I try to implement a PayInDirectCard (https://docs.mangopay.com/api-references/payins/payindirectcard/)

A. The 1st step (Create CardRegistration) is ok, I get AccessKey, PreregistrationData, CardRegistrationURL and CardRegistrationId

POST /CardRegistrations

        ["UserId"]= string(7) "7959571"
        ["Currency"]= string(3) "EUR" 
        ["CardType"]= string(18) "CB_VISA_MASTERCARD" 

RESPONSE

        ["Id"]= string(7) "8082525" 
        ["Tag"]= NULL 
        ["CreationDate"]= int(1439458468) 
        ["UserId"]= string(7) "7959571" 
        ["AccessKey"]= string(20) "1X0m87dmM2LiwFgxPLBJ" 
        ["PreregistrationData"]= string(86) "XBDYiG8w9PrylPS01KmupQFG9GVaIA5cMBynS5pmG2ZEnWzds_vbQeD1VuUtUossS4wCy-yiraxeE65tmxOe8A" 
        ["RegistrationData"]= NULL 
        ["CardId"]= NULL 
        ["CardType"]= string(18) "CB_VISA_MASTERCARD" 
        ["CardRegistrationURL"]= string(63) "https://homologation-webpayment.payline.com/webpayment/getToken" 
        ["ResultCode"]= NULL 
        ["ResultMessage"]= NULL 
        ["Currency"]= string(3) "EUR" 
        ["Status"]= string(7) "CREATED"

B. The 2nb step (PreRegistrationData through the form) is ok, I get back data.

?data=6GC916dHZPpYrs_zfN6X5JPC2RVgv6611Ff2N88cQLQ_phl4kw1SQMdY024x8x8siIzmOpGy8gxBegF13bkmwlXSGIVoX7WbZ_AulE9KQ98ZFHOBn4JQHdFdQA8F7m_b_uh-M22NjZ6dU5YsJBBYuA

C. The 3rd step (Edit CardRegistration) is ok, I get CardId

PUT /CardRegistrations/8082525

["RegistrationData"]= string(155) "data=6GC916dHZPpYrs_zfN6X5JPC2RVgv6611Ff2N88cQLQ_phl4kw1SQMdY024x8x8siIzmOpGy8gxBegF13bkmwlXSGIVoX7WbZ_AulE9KQ98ZFHOBn4JQHdFdQA8F7m_b_uh-M22NjZ6dU5YsJBBYuA"

RESPONSE

        ["Id"]= string(7) "8082525"
        ["Tag"]= NULL
        ["CreationDate"]= int(1439458468)
        ["UserId"]= string(7) "7959571"
        ["AccessKey"]=  string(20) "1X0m87dmM2LiwFgxPLBJ"
        ["PreregistrationData"]= string(86) "XBDYiG8w9PrylPS01KmupQFG9GVaIA5cMBynS5pmG2ZEnWzds_vbQeD1VuUtUossS4wCy-yiraxeE65tmxOe8A"
        ["RegistrationData"]= string(155) "data=6GC916dHZPpYrs_zfN6X5JPC2RVgv6611Ff2N88cQLQ_phl4kw1SQMdY024x8x8siIzmOpGy8gxBegF13bkmwlXSGIVoX7WbZ_AulE9KQ98ZFHOBn4JQHdFdQA8F7m_b_uh-M22NjZ6dU5YsJBBYuA"
        ["CardId"]= string(7) "8082593"
        ["CardType"]= string(18) "CB_VISA_MASTERCARD"
        ["CardRegistrationURL"]= string(63) "https://homologation-webpayment.payline.com/webpayment/getToken"
        ["ResultCode"]= string(6) "000000"
        ["ResultMessage"]= string(7) "Success"
        ["Currency"]= string(3) "EUR"
        ["Status"]= string(9) "VALIDATED"

D. The final step (PayInDirectCard) is not ok, I can't call it

POST /payins/card/direct

        ["CreditedWalletId"]= string(7) "8060822"
        ["AuthorId"]= string(7) "7959571"
        ["CardId"]= string(7) "8082593"
        ["DebitedFunds"]= {
                                ["Currency"]= "EUR"
                                ["Amount"]= int(10000)
                            }
        ["Fees"]= {
                        ["Currency"]= "EUR"
                        ["Amount"]= int(0)
                    }
        ["SecureMode"]= "DEFAULT"
        ["SecureModeUrl"]= "https://xxx..."

RESPONSE

Exception > failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request

I followed the doc but don't know what I'm doing wrong.

Besides, I don't understand why the parameters of the doc (https://docs.mangopay.com/api-references/payins/payindirectcard/) are not the same than the parameters of the example (https://github.com/Mangopay/mangopay2-php-sdk/blob/master/demos/paymentDirect/payment.php).
(in the doc CardId is a direct parameter - in example, he is a part of ExecutionDetails sub object, etc.)

Any help would be appreciated, thanks.

Feature request: extra argument to the notification / callback

Our system, and I think most other systems would be MUCH simpler if you change the notification callback slightly.

The callback/notification should contain the URL of the resource. If you add the URL of the resource, all existing systems would still work. Like this:

http://oursite.com/callback?RessourceId=914329&EventType=KYC_SUCCEEDED&Date=1413991648&Url=/users/8578/KYC/documents/87670

Of course this would need to be URL encoded, like this:

http://oursite.com/callback?RessourceId=914329&EventType=KYC_SUCCEEDED&Date=1413991648&Url=%2Fusers%2F8578%2FKYC%2Fdocuments%2F87670

Ideally you would send the URL as the only parameter.

Bad request. One or several required parameters are missing or incorrect. An incorrect resource ID also raises this kind of error

Hi ... i am getting this error while create PayIn object and the reponse i am getting the below...
ResponseString --> MangoPay\PayIn Object
(
[CreditedWalletId] => 16733904
[PaymentType] =>
[PaymentDetails] => MangoPay\PayInPaymentDetailsCard Object
(
[CardType] =>
[CardId] =>
)

[ExecutionType] => 
[ExecutionDetails] => MangoPay\PayInExecutionDetailsDirect Object
    (
        [SecureMode] => 
        [SecureModeReturnURL] => http://test.com
        [SecureModeRedirectURL] => 
        [CardId] => 6291053
    )

[AuthorId] => 6286964
[CreditedUserId] => 
[DebitedFunds] => MangoPay\Money Object
    (
        [Currency] => EUR
        [Amount] => 100
    )

[CreditedFunds] => 
[Fees] => MangoPay\Money Object
    (
        [Currency] => EUR
        [Amount] => 0
    )

[Status] => 
[ResultCode] => 
[ResultMessage] => 
[ExecutionDate] => 
[Type] => 
[Nature] => 
[Id] => 
[Tag] => 
[CreationDate] => 
[CreditedUserId ] => 17337581

)

What is worng in that.? the same respoce i get in my test server and everything works fine...
the test server responcs is
CreditedWalletId] => 5154858
[PaymentType] =>
[PaymentDetails] => MangoPay\PayInPaymentDetailsCard Object
(
[CardType] =>
[CardId] =>
)

[ExecutionType] => 
[ExecutionDetails] => MangoPay\PayInExecutionDetailsDirect Object
    (
        [SecureMode] => 
        [SecureModeReturnURL] => http://test.com
        [SecureModeRedirectURL] => 
        [SecureModeNeeded] => 
        [CardId] => 6291026
    )

[AuthorId] => 6286964
[CreditedUserId] => 
[DebitedFunds] => MangoPay\Money Object
    (
        [Currency] => EUR
        [Amount] => 65
    )

[CreditedFunds] => 
[Fees] => MangoPay\Money Object
    (
        [Currency] => EUR
        [Amount] => 0
    )

[Status] => 
[ResultCode] => 
[ResultMessage] => 
[ExecutionDate] => 
[Type] => 
[Nature] => 
[Id] => 
[Tag] => 
[CreationDate] => 
[CreditedUserId ] => 5831904

..

Direct payIn for big amount

Hello,

I have implement mangopay in my site, i did payment of 120 EURO, status PayIn Created not success.

What i need to do next?
Payment less then 100 works fine,

I have set SecureModeReturnURL as below,
$payIn->ExecutionDetails->SecureModeReturnURL = "http".(isset($_SERVER['HTTPS']) ? "s" : null)."://".$_SERVER["HTTP_HOST"]."/customers/secure_mode";

What I need to handle in this return URL?

Any help would be appreciated, thanks.

Transactions with rollbacking

Hello. Is it possible to Have payments transaction with possibility of rollbacks?

We have a case where we are splitting payments to multiple wallets, but in case of an error (network or whatever) we would love to have a rollback of these payments and even new wallets creation.

Do you have anything to suggest?

Feature request: actual mangopay fees in the payments

See the extra fields 'MangopayFees'. This we way we can charge it directly to users per payment.

{
    "Id": "1168654",
    "Tag": "",
    "CreationDate": 1383130296,
    "AuthorId": "1167495",
    "CreditedUserId": "1167492",
    "DebitedFunds": {
        "Currency": "EUR",
        "Amount": 10012
    },
    "CreditedFunds": {
        "Currency": "EUR",
        "Amount": 8794
    },
    "Fees": {
        "Currency": "EUR",
        "Amount": 1218
    },
    "MangopayFees": {
        "Currency": "EUR",
        "Amount": XXX
    },
    "Status": "SUCCEEDED",
    "ResultCode": "000000",
    "ResultMessage": "Success",
    "ExecutionDate": 1383130330,
    "Type": "PAYIN",
    "Nature": "REGULAR",
    "CreditedWalletId": "1167494",
    "DebitedWalletId": null,
    "PaymentType": "CARD",
    "ExecutionType": "WEB",
    "RedirectURL": "https://homologation-secure-p.payline.com/webpayment/?reqCode=prepareStep2&stepCode=step2&token=1mCGbP3dbrNf6YKp3E4g1383130296783",
    "ReturnURL": "http://docs.mangopay.com/?transactionId=1168654",
    "TemplateURL": null,
    "CardType": "CB_VISA_MASTERCARD",
    "Culture": "FR",
    "SecureMode": "FORCE"
}

Call to a member function IsExpired() on a non-object

Hello,

I am using mangopay since march-2015, it's works fine, now days i found fatal error while register new user,

Error: Call to a member function IsExpired() on a non-object
File: /var/www/vhosts/xxx.com/Vendor/mangopay2-php-sdk-master/MangoPaySDK/tools/authorizationTokenManager.inc
Line: 33

please help me to fix this issue,

thanks

Overriding StorageStrategy

If you want to override the SDKs StorageStrategy(IStorageStrategy) you will run in to a problem unless you stick with php serializing the OAuthToken. The reason is that the property create_time is private and thus not accessible to outside code. Now I know this can be worked around using PHP quirks(cast to array) or reflection, but I'd rather not have to rely on hacks.

The better solution would be to make create_time public or add a toArray() function to OAuthToken
that simply returns a copy of the internal state.

That would only solve the reading part however. We would also need to be able to
set the creation_time either by a public property or by a constructor param.

In my opinion all values should be readonly and setable only through the constructor.
It makes more sense for an OAuthToken to be immutable anyway.

3- D secure payment

Hello,

I have implement mangopay in my application, when i make payment larger then 100 i got "009199 PSP technical error".
I have set sandbox mangopay, that's why this error comes?

please give a way to make payment greater then 100.

thanks.

Issue with live

I am not able to work with live mangopay .
Please help me with this

Unit tests are not stateless

On the first run of the whole unit tests test suite all.php, I only have the two errors (see: #9).

On the second, run an exception appear after the first failing tests:

Exception 1!
Unexpected exception of type [MangoPay\ResponseException] with message [Bad request. the body cannot be empty] in [/tmp/mangopay2-php-sdk/MangoPaySDK/tools/restTool.inc line 268]
    in test_Users_AllCards
    in MangoPay\Tests\Users
    in ../cases/users.php
    in MangoPay\Tests\All

Only occures with PHP 5.5 (nothing with 5.3).

With PHP 5.4, the first execution (and only this one) is raising extra errors:

3) Identical expectation [Integer: 500] fails with [Integer: 400] because [Integer: 500] differs from [Integer: 400] by 100 at [/private/tmp/mangopay2-php-sdk/tests/cases/users.php line 226]
    in test_Users_CreateKycPage_EmptyFileString
    in MangoPay\Tests\Users
    in ../cases/users.php
    in MangoPay\Tests\All
4) Identical expectation [Integer: 500] fails with [Integer: 400] because [Integer: 500] differs from [Integer: 400] by 100 at [/private/tmp/mangopay2-php-sdk/tests/cases/users.php line 242]
    in test_Users_CreateKycPage_WrongFileString
    in MangoPay\Tests\Users
    in ../cases/users.php
    in MangoPay\Tests\All

Fetch refunds from a payin transaction

Hello,

I'm working with sdk 1.4.1 :

I need to fetch refunds linked to a payin :

$payinId=15643643143;

$payin=$mangopay->PayIns->Get($payinId); 

echo 'this works :  '. $payin->Id.PHP_EOL;

try{
    $refund=$mangopay->PayIns->GetRefund(payinId);
}catch (\MangoPay\ResponseException $e){
    /**
obtaining : exception 'MangoPay\ResponseException' with message 'Method not allowed. The requested resource does not support http method 'GET'.' in /home/jeanch/www/.../vendor/MangoPay/mangopay2-php-sdk/MangoPaySDK/tools/restTool.inc:272
Stack trace:
#0 /home/jeanch/www/.../vendor/MangoPay/mangopay2-php-sdk/MangoPaySDK/tools/restTool.inc(126): MangoPay\RestTool->CheckResponseCode(Object(stdClass))
#1 /home/jeanch/www/.../vendor/MangoPay/mangopay2-php-sdk/MangoPaySDK/tools/restTool.inc(93): MangoPay\RestTool->RunRequest()
#2 /home/jeanch/www/.../vendor/MangoPay/mangopay2-php-sdk/MangoPaySDK/tools/apiBase.inc(178): MangoPay\RestTool->Request('/payins/2043263...', 'GET')
#3 /home/jeanch/www/.../vendor/MangoPay/mangopay2-php-sdk/MangoPaySDK/tools/apiPayIns.inc(45): MangoPay\ApiBase->GetObject('payins_getrefun...', '20432632', '\\MangoPay\\Refun...')
**/
 echo 'this happens';

}

GetRefund (that should actually be named geteRefunds) not working, I'm looking for an efficient way to this;
The only way i can think of is :

  1. fetch the payin
  2. fetch the author of the payin
  3. fetch transactions linked to the author
  4. check each transaction to see if InitialTransactionId match my initial payin

Is there a better way?

note: i cannot upgrade sdk...

Payout confirmation

I just want to confirm that it's necessary to do payout on each transaction?
or can i do something like
all user make payment and this amount will credit in my wallet, and after rich on some amount do payout.
Please gives step to do transction.

Please add a curl timeout to RestTool

The current RestTool will block indefinitely as there is no timeout set.
This isn't a problem when everything is working as it should, but it does become a problem when it's not.
A 2-5s(or configurable) timeout value seems reasonable.

Unauthorized error

My implementation of Mangopay is working on my local machine, but not on my remote server, where I get an "Unauthorized error" (without further information), using the same credentials on api sandbox.
The main difference I can see is curl version (being 7.35.0 on my local machine and 7.26.0 on remote server).
I don't see any specific curl requirements here, could be curl version a problem?
Is there anything else I could check?

Set up a recurring payment

Hey there,

I'm here again 😄

I'm trying to create a recurring payment system with Mangopay api.

The process is :

  1. Signup, preauthorise the payin and make the first payin (and this is works perfectly)
  2. save the authorisationid and all the others id on the DB
  3. call a function each month for the next payment

Now the strange issue, everything is going great 'till point 3 - there i'm calling the function with this code

$PayIn = new \MangoPay\PayIn();
    $PayIn->CreditedWalletId = $walletid;
    $PayIn->AuthorId = $authorid;
    $PayIn->PaymentType = "PREAUTHORIZED";
    $PayIn->PaymentDetails = new \MangoPay\PayInPaymentDetailsPreAuthorized();
    $PayIn->PaymentDetails->PreauthorizationId = $auth;
    $PayIn->DebitedFunds = new \MangoPay\Money();
    $PayIn->DebitedFunds->Currency = "EUR";
    $PayIn->DebitedFunds->Amount = $value*100;
    $PayIn->Fees = new \MangoPay\Money();
    $PayIn->Fees->Currency = "EUR";
    $PayIn->Fees->Amount = 0;
    // execution type as DIRECT
    $PayIn->ExecutionDetails = new \MangoPay\PayInExecutionDetailsDirect();
    $PayIn->ExecutionDetails->CardId = $cardid;
    $PayIn->ExecutionDetails->SecureModeReturnURL = 'http://test.com';


   $createdPayIn = $mangoPayApi->PayIns->Create($PayIn);//Send the request

And this is what i get

Fatal error: Uncaught exception 'MangoPay\Libraries\ResponseException' with message 'Bad request. One or several required parameters are missing or incorrect. An incorrect resource ID also raises this kind of error.' in /home/wasnaga/public_html/beta/mangopay2-php-sdk-2.3/MangoPay/Libraries/RestTool.php:328

It's strange since all the variable are populated and the code is the same I'm using for make the first PayIn, any suggest ?

PHP 5.3 & PHP 5.4 compatibility

We are not using PHP 5.5 and from what I've read in your code, nothing seems to be blocking the usage of your library in PHP 5.3 (which could also mean PHP 5.4).

  • Not usage of traits
  • Not usage of yield
  • Not usage of new style PHP array allocation like $a = [1, 2, 3];

I've run your tests, I've the issue described here (as I do in PHP 5.5): #9.

So if we consider #10 PHP 5.3 is showing less error than 5.5.

However PHP 5.4 causes new failing tests as referenced in #10.

Could you consider to support those environments?

Erreur d'apel de l'API pour apiUsers::Update

Lors de la l'appel à la méthode "Update" de la class "apiUsers", vous appelez "users_createnaturals" et "users_createlegals" au lieu d'apeller "users_savenaturals" et "users_savelegals".

Call to undefined method MangoPay\ApiWallets::GetTransaction()

Hi!

When trying the "api" demo in the SDK, I get a fatal error: Fatal error: Call to undefined method MangoPay\ApiWallets::GetTransaction() in demos\api\form.php on line 88
To reproduce: in the menu, go to Transactions > List transactions for wallet and submit the form.

It is caused by a typo.
It can be fixed by editing demos/api/menu.php.
Replace line 26 by:

'List transactions for wallet' => 'Wallet_Wallets_ListSubEntity_GetTransactions_FilterTransactions',

Diff: GetTransaction --> GetTransactions

Have a nice day!

Users tests are failing

The users tests are failing with the following output:

1) Identical expectation [Integer: 500] fails with [Integer: 400] because [Integer: 500] differs from [Integer: 400] by 100 at [/tmp/mangopay2-php-sdk/tests/cases/users.php line 226]
    in test_Users_CreateKycPage_EmptyFileString
    in MangoPay\Tests\Users
    in ../cases/users.php
    in MangoPay\Tests\All
2) Identical expectation [Integer: 500] fails with [Integer: 400] because [Integer: 500] differs from [Integer: 400] by 100 at [/tmp/mangopay2-php-sdk/tests/cases/users.php line 242]
    in test_Users_CreateKycPage_WrongFileString
    in MangoPay\Tests\Users
    in ../cases/users.php
    in MangoPay\Tests\All

I've been able to reproduce this with PHP 5.3 (Ubuntu 12.04), 5.4 (Mac OSX) and 5.5 (Ubuntu 12.04).

Can't understand the problem

When I try to use this : $mangoPayApi->Users->CreateBankAccount($UserId, $BankAccount);

I get "Bad request. One or several required parameters are missing or incorrect. An incorrect resource ID also raises this kind of error."

But I used the exact codes from the demo scripts on sandbox. And my mangopay user id is correct ( I can check it on dashboard) Also I can create a bank account for that user on mangopay dashboard. I can't figure out what is the problem. Are you planning to implement more detailed error responses? It is really hard to get what's wrong.

Test suite fails

Test suite fails when run on current HEAD tip of master branch (992e3c1).

/mangopay2-php-sdk$ cd cd tests/suites/
/mangopay2-php-sdk$ php all.php 
all.php
1) Cannot test contesting dispute because there's no disputes that can be resubmited
in the disputes list. at [/mnt/data/dev/mangopay2-php-sdk/tests/cases/disputes.php
line 200]
    in test_Disputes_ResubmitDispute
    in MangoPay\Tests\Disputes
    in ../cases/disputes.php
    in MangoPay\Tests\All
E_NOTICE: Undefined offset: 0 in /mnt/data/dev/mangopay2-php-sdk/tests/cases/disputes.php
on line 347
Exception 1!
Unexpected PHP error [Undefined offset: 0] severity [8] in
[/mnt/data/dev/mangopay2-php-sdk/tests/cases/disputes.php line 347]
    in test_Disputes_GetRepudiation
    in MangoPay\Tests\Disputes
    in ../cases/disputes.php
    in MangoPay\Tests\All
E_NOTICE: Trying to get property of non-object in
/mnt/data/dev/mangopay2-php-sdk/tests/cases/disputes.php on line 347
Exception 2!
Unexpected PHP error [Trying to get property of non-object] severity [8] in
[/mnt/data/dev/mangopay2-php-sdk/tests/cases/disputes.php line 347]
    in test_Disputes_GetRepudiation
    in MangoPay\Tests\Disputes
    in ../cases/disputes.php
    in MangoPay\Tests\All
Exception 3!
Unexpected exception of type [MangoPay\Libraries\ResponseException] with message
[Not found. No HTTP resource was found that matches the request URI
'https://api.sandbox.mangopay.com/v2.01/sdk-unit-tests/repudiations/'.] in
[/mnt/data/dev/mangopay2-php-sdk/MangoPay/Libraries/RestTool.php line 331]
    in test_Disputes_GetRepudiation
    in MangoPay\Tests\Disputes
    in ../cases/disputes.php
    in MangoPay\Tests\All
FAILURES!!!
Test cases run: 16/16, Passes: 621, Failures: 1, Exceptions: 3

Sofortüberweisung payment options for German customers

I was looking to add this Pay-In type and I only found this entry in the API docs. It mentions:

 "DirectDebitType   String  « SOFORT », « ELV » or « GIROPAY »"

My problem is that I cannot see any example using this in the API Doc or even in the API SDK test.

I only found an aprox example using GIROPAY in tests here but it is a bit confused since you treat like "payment type as CARD" and then you use as "pay-in PRE-AUTHORIZED DIRECT".

But I cannot figure out if changing only:

$payIn->PaymentDetails->DirectDebitType = "GIROPAY";

To:

$payIn->PaymentDetails->DirectDebitType = "SOFORT";

it will work, or I will need know the specific fields that SOFORT request for make the payin that probably are pretty similar to GIROPAY.

Could you guide me a bit more on how implement this? And probably will be good count with a example in API Docs tests for SOFORT pay-in.

500 when retrieving SecureModeRedirectURL

Hey, i've a super annoying error when i'm trying to access to SecureModeRedirectURL of the CardPreAuthorization object.

Every time i Get :

\MangoPay\ResponseException: Code: 500
Message: Internal server error. Internal Server Error

Details: MangoPay\Libraries\Error Object ( [Message] => Internal Server Error [Errors] => )

even if I try to print it with. Is the only property in the object that create this error.

Here is my code:

$CardPreAuthorization = new \MangoPay\CardPreAuthorization();
    $CardPreAuthorization->AuthorId = $updatedCardRegister->UserId;
    $CardPreAuthorization->DebitedFunds = new \MangoPay\Money();
    $CardPreAuthorization->DebitedFunds->Currency = "EUR";
    $CardPreAuthorization->DebitedFunds->Amount = $_SESSION['amount']*100;
    $CardPreAuthorization->SecureMode = "DEFAULT";
    $CardPreAuthorization->CardId = $card->Id;
    $CardPreAuthorization->SecureModeReturnURL = "https://mywebsite/index.php";

    $CreatePreAuthorization = $mangoPayApi->CardPreAuthorizations->Create($CardPreAuthorization);
   echo $CreatePreAuthorization->SecureModeRedirectURL;

WHAT ARE THE KEY-VALUES ARE PASS TO GET THE CARD TOKEN WHICH WILL BE USED TO CHEACK THAT GIVEN CARD DETAILS ARE VALID OR NOT. Please help me in this case.

Hi...i am using mangoopay interation for payment. here i can able to create card but i am unable to recive token which help me to update the registerCard with RegistrationData. here i pass six things;
1.creditcardNumber
2.CVV
3.ExpDate
4 AcessKEy
5. ReturnURL
6. PreRegistration data at : https://homologation-webpayment.payline.com/webpayment/getToken.
but i get : errorCode=09101

might happen that my key-value pair is wrong. What it will be if anyone know then please do reply

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.