Example #1
0
 /**
  * Creates self::$JohnsWalletWithMoney (wallets belonging to John) if not created yet
  * @return \MangoPay\Wallet
  */
 protected function getJohnsWalletWithMoney($amount = 10000)
 {
     if (self::$JohnsWalletWithMoney === null) {
         $john = $this->getJohn();
         // create wallet with money
         $wallet = new \MangoPay\Wallet();
         $wallet->Owners = array($john->Id);
         $wallet->Currency = 'EUR';
         $wallet->Description = 'WALLET IN EUR WITH MONEY';
         self::$JohnsWalletWithMoney = $this->_api->Wallets->Create($wallet);
         $cardRegistration = new \MangoPay\CardRegistration();
         $cardRegistration->UserId = self::$JohnsWalletWithMoney->Owners[0];
         $cardRegistration->Currency = 'EUR';
         $cardRegistration = $this->_api->CardRegistrations->Create($cardRegistration);
         $cardRegistration->RegistrationData = $this->getPaylineCorrectRegistartionData($cardRegistration);
         $cardRegistration = $this->_api->CardRegistrations->Update($cardRegistration);
         $card = $this->_api->Cards->Get($cardRegistration->CardId);
         // create pay-in CARD DIRECT
         $payIn = new \MangoPay\PayIn();
         $payIn->CreditedWalletId = self::$JohnsWalletWithMoney->Id;
         $payIn->AuthorId = $cardRegistration->UserId;
         $payIn->DebitedFunds = new \MangoPay\Money();
         $payIn->DebitedFunds->Amount = $amount;
         $payIn->DebitedFunds->Currency = 'EUR';
         $payIn->Fees = new \MangoPay\Money();
         $payIn->Fees->Amount = 0;
         $payIn->Fees->Currency = 'EUR';
         // payment type as CARD
         $payIn->PaymentDetails = new \MangoPay\PayInPaymentDetailsCard();
         $payIn->PaymentDetails->CardId = $card->Id;
         // execution type as DIRECT
         $payIn->ExecutionDetails = new \MangoPay\PayInExecutionDetailsDirect();
         $payIn->ExecutionDetails->SecureModeReturnURL = 'http://test.com';
         // create Pay-In
         $this->_api->PayIns->Create($payIn);
     }
     return $this->_api->Wallets->Get(self::$JohnsWalletWithMoney->Id);
 }