定制 elendev/checkout-bundle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

elendev/checkout-bundle

Composer 安装命令:

composer require elendev/checkout-bundle

包简介

Provide simple checkout utilities for paypal

README 文档

README

Bundle configuration

Symfony 2 configuration config.yml

If you don't want to use paypal checkout service, you can remove the paypal configuration. Other available configurations are visible below :

elendev_checkout:
	paypal:
    	username: 'your_paypal_username'
    	password: 'your_paypal_password'
    	signature: 'your_paypal_signature'
    	use_sandbox: 'true/false'
    	currency: 'EUR/USD/..., optionnal, default : EUR'
    	page_style: 'saved pagestyle available on paypal website, optionnal'
    	header_image: 'image visible on top left, optionnal'
    	header_border_color: '6 char length color code (e.g. 888888), optionnal'
    	header_background_color: '6 char length color code (e.g. 777777), optionnal'
    	payment_page_background_color: '6 char length color code (e.g. 666666), optionnal'
    	brand_name: 'name visible on top of payment page, optionnal'

Simple example

This page explain how to use the ElendevCheckoutBundle into a simple controller.

Simple implementation example Here you can see a really simple implementation example :

/**
 * @author Jonas Renaudot
 */
class OrderingController extends Controller {
 
	...

    public function doCheckoutAction($checkoutMethod){
 
        $command = ...; //instance of Elendev\CheckoutBundle\Command\Command
 
        $checkoutProvider = $this->get("elendev.checkout.service_provider")->getService($checkoutMethod);

        $result = $checkoutProvider->doCheckout($command);
 

    	if($result->getStatus() == CheckoutResult::STATUS_IN_PROGRESS){
        	return $result->getHttpResponse();
    	}else if($result->getStatus() == CheckoutResult::STATUS_CANCELED){
        	//Command canceled : return to the info page
        	$this->getRequest()->getSession()->setFlash("info", "Command canceled");
        	return new RedirectResponse($this->generateUrl("ordering.info"));
    	}else if($result->getStatus() == CheckoutResult::STATUS_ERROR){
        	//Error occured : return to the info page allowing user to chose an other payment method
        	$this->get('session')->setFlash("error", "An error occured, retry again please");
        	return new RedirectResponse($this->generateUrl("ordering.info"));
    	}else if($result->getStatus() == CheckoutResult::STATUS_SUCCESS){
        	//save current command and mark it as done
        	...
        	//go to confirmation page
        	return new RedirectResponse($this->generateUrl("ordering.confirmation"));
    	}
	}

    ...
}

Create a new service class

This part explain how to add a new service to the CheckoutServiceProvider. This service will be available through the CheckoutServiceProvider->getService('id') method.

  • Creating a new service class To create a valid service class you need to extends the Elendev\CheckoutBundle\CheckoutService class. The simplest checkout service you can implement is visible below :

    namespace Your\Service\Namespace;

    use Elendev\CheckoutBundle\CheckoutService; use Elendev\CheckoutBundle\Command\Command; use Elendev\CheckoutBundle\CheckoutResult;

    class SimpleCheckoutService extends CheckoutService {

      /**
       * @param Command $command
      * @return CheckoutResult : result of checkout operations
     */
     public function doCheckout(Command $command){
       
          $result = new CheckoutResult();
    
          $result->setStatus(CheckoutResult::STATUS_SUCCESS);
      
          return $result;
      }
    

    } When you return a `CheckoutResult::STATUS_IN_PROGRESS status in the returned response object, the doCheckout method will be called again on page reloading (or on redirect on the current page).

  • Configure a new service Add your new checkout service as a simple service with the elendev.checkout.service tag. The specified id parameter is the service id that you need to use to get the service with the CheckoutServiceProvider->getService('id') method.

    your.service.id: class : Your\Checkout\Service\Class tags : - {name : elendev.checkout.service, id: your_service_id}

统计信息

  • 总下载量: 175
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: Apache2
  • 更新时间: 2012-09-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固