Идентификатор неверного плана Paypal - PullRequest
0 голосов
/ 14 января 2019

Я использую членский взнос от PayPal на Laravel 5.5 Я использую следующую ссылку для интеграции PayPal в Laravel

https://devdojo.com/tutorials/using-paypal-in-your-laravel-app

Я добавляю сюда свою функцию

   public function paypalRedirect($planID){
        $response = array();
        $this->plan_id = $planID;
        // Create new agreement
        $agreement = new Agreement();
        $agreement->setName('Vechflow Monthly Subscription Agreement')
        ->setDescription('Basic Subscription')
        ->setStartDate(\Carbon\Carbon::now()->addMinutes(5)->toIso8601String());

        // Set plan id
        $plan = new Plan();
        $plan->setId($this->plan_id);
        $agreement->setPlan($plan);
        // Add payer type
        $payer = new Payer();
        $payer->setPaymentMethod('paypal');
        $agreement->setPayer($payer);

        try {
          // Create agreement
          $agreement = $agreement->create($this->apiContext);
          // Extract approval URL to redirect user
          $approvalUrl = $agreement->getApprovalLink();
          $response['status_code'] = 200; 
          $response['url'] = $approvalUrl;
          return $response;
      } catch (PayPal\Exception\PayPalConnectionException $ex) {
          $response['status_code'] = 500; 
          $response['error'] = $ex;
          return $response;
      } catch (Exception $ex) {
          $response['status_code'] = 500; 
          $response['error'] = $ex;
          return $response;
      }
}

До сих пор он работает отлично и возвращает соглашение правильно, но после этого, когда мы выполняем соглашение, оно выдает исключение, которое показывает следующую ошибку после отладки

{"name":"TEMPLATE_ID_INVALID","details":[{"field":"template id is invalid","issue":"Incorrect Plan Id."}],"message":"","information_link":"https://developer.paypal.com/docs/api/payments.billing-agreements#errors","debug_id":"4afbcfb5dd18a"}
...