コード例 #1
0
 public function parseSubscriptionCancelled(UnitTester $I)
 {
     $parser = new \BB\Services\Payment\GoCardlessWebhookParser();
     $parser->parseResponse($this->subscriptionCancelledPayload());
     $I->assertEquals('cancelled', $parser->getAction());
     $I->assertEquals('subscription', $parser->getResourceType());
     $I->assertEquals(1, count($parser->getSubscriptions()));
     $I->assertEquals(0, count($parser->getBills()));
     $this->assertSubscriptionFormat($I, $parser->getSubscriptions());
 }
コード例 #2
0
 public function receive()
 {
     $request = \Request::instance();
     if (!$this->goCardless->validateWebhook($request->getContent())) {
         return \Response::make('', 403);
     }
     $parser = new \BB\Services\Payment\GoCardlessWebhookParser();
     $parser->parseResponse($request->getContent());
     switch ($parser->getResourceType()) {
         case 'bill':
             switch ($parser->getAction()) {
                 case 'created':
                     $this->processNewBills($parser->getBills());
                     break;
                 case 'paid':
                     $this->processPaidBills($parser->getBills());
                     break;
                 default:
                     $this->processBills($parser->getAction(), $parser->getBills());
             }
             break;
         case 'pre_authorization':
             $this->processPreAuths($parser->getAction(), $parser->getPreAuthList());
             break;
         case 'subscription':
             $this->processSubscriptions($parser->getSubscriptions());
             break;
     }
     return \Response::make('Success', 200);
 }