PHP code example of bobma-awen / tcc-transaction

1. Go to this page and download the library: Download bobma-awen/tcc-transaction library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bobma-awen / tcc-transaction example snippets


    use LoyaltyLu\TccTransaction\Annotation\Compensable;

    /**
     * @Inject
     * @var OrderInterface
     */
    private $service;

     /**
         *
         * @Compensable(
         * master={"services"=OrderInterface::class,"tryMethod"="creditOrderTcc","confirmMethod"="confirmCreditOrderTcc","cancelMethod"="cancelCreditOrderTcc"},
         * slave={{"services"=PayAccountInterface::class,"tryMethod"="creditAccountTcc","confirmMethod"="confirmCreditAccountTcc","cancelMethod"="cancelCreditAccountTcc"}}
         * )
         *
         * @return array
         */

  public function index(){
        $input = $this->request->input('id');
        return $this->service->creditOrderTcc($input);
   }
  


     $input = $this->request->input('id');
     return $this->service->creditOrderTcc($input);

/**
 * Class OrderService.
 * @RpcService(name="PayService", protocol="jsonrpc-http", server="jsonrpc-http", publishTo="consul")
 */
class PayService implements PayAccountInterface
{
public function creditAccountTcc($input)
    {
        throw new \Exception('msg');
        
    }
}