PHP Classes

File: demo/SendingPayments.php

Recommend this page to a friend!
  Classes of Oleksii Mylotskyi   PHP MoySklad Client   demo/SendingPayments.php   Download  
File: demo/SendingPayments.php
Role: Example script
Content type: text/plain
Description: Demo Files
Class: PHP MoySklad Client
Access the MoySklad API using ORM like objects
Author: By
Last change:
Date: 9 years ago
Size: 1,412 bytes
 

Contents

Class file image Download
<?php
namespace Zf2ClientMoysklad;

require_once
__DIR__.'/_config.php';

use
Zf2ClientMoysklad\Entity\CustomerOrder;
use
Zf2ClientMoysklad\Entity\PaymentIn;
use
Zf2ClientMoysklad\Repository\BasicRepository;

global
$sm;

/* @var $entityManager EntityManager */
$entityManager = $sm->get('zf2clientmoysklad_entity_manager');

/*====================== Method for sending payments ==========================*/

/* @var $repository BasicRepository */
$repository = $entityManager->getRepository('Zf2ClientMoysklad\Entity\CustomerOrder');

/* @var $customerOrders CustomerOrder[] */
$customerOrders = $repository->findAll(array('externalCode = '=>array('P1fV-3Y3jhas7lnpZ_0ON0',
                                                                     
'XXFSCoT7iAmnJIjeCHwqn0')));

foreach (
$customerOrders as $orderEntity) {
   
$paymentIn = new PaymentIn();

   
$paymentIn->setCustomerOrderUuid($orderEntity->getUuid());
   
$paymentIn->setSum($orderEntity->getSum());
   
$paymentIn->setSumInCurrency($orderEntity->getSumInCurrency());
   
$paymentIn->setSourceAgentUuid($orderEntity->getSourceAgentUuid());
   
$paymentIn->setTargetAgentUuid($orderEntity->getTargetAgentUuid());
   
$paymentIn->setDescription('Оплата через Робокассу');

   
$entityManager->persist($paymentIn);
}

$entityManager->flush();

/*---------------------------------------------------------------------------------*/