Search code examples
phppaypalpaypal-sandboxpaypal-rest-sdk

Paypal Rest Sandbox Error


When im try to create a Paypal Payment every time i get this Error "Failed to connect to api.sandbox.paypal.com port 443: Connection refused"

        $payer = new Payer();
    $payer->setPaymentMethod('paypal');

    $itemSignup = new Item();
    $itemSignup->setName('Test');
    $itemSignup->setCurrency('EUR');
    $itemSignup->setQuantity(1);
    $itemSignup->setPrice(self::SIGNUP_PRICE);

    $itemList =new ItemList();
    $itemList->setItems([$itemSignup]);

    $amount = new Amount();
    $amount->setCurrency('EUR');
    $amount->setTotal(self::SIGNUP_PRICE);

    $transaction = new Transaction();
    $transaction->setAmount($amount);
    $transaction->setItemList($itemList);
    $transaction->setDescription('Test');

    $redirectUrls = new RedirectUrls();
    $redirectUrls->setReturnUrl('http://localhost/test/');
    $redirectUrls->setCancelUrl('http://localhost/test/');

    $payment = new Payment();
    $payment->setIntent('Sale');
    $payment->setPayer($payer);
    $payment->setRedirectUrls($redirectUrls);
    $payment->setTransactions(array($transaction));

    try {
        $payment->create($this->_apiContext);
    } catch(\Exception $e){
        dd($e->getMessage());

Solution

  • The problem was with the firewall