xendit / xendit-php

Xendit REST API Client for PHP - Card, Virtual Account, Invoice, Disbursement, Recurring Payments, Payout, EWallet, Balance, Retail Outlets Services, xenPlatforms
https://developers.xendit.co/api-reference/
MIT License
152 stars 76 forks source link

ErrorException Only variables should be passed by reference #226

Open steph1902 opened 4 months ago

steph1902 commented 4 months ago

ask

hi sori mau nanya perihal xendit

code from : projectname/vendor/xendit/xendit-php/lib/Invoice/InvoiceApi.php

/**
     * Operation createInvoice
     *
     * Create an invoice
     *
     * @param  \Xendit\Invoice\CreateInvoiceRequest $create_invoice_request create_invoice_request (required)
     * @param  string $for_user_id Business ID of the sub-account merchant (XP feature) (optional)
     * @param  string $contentType The value for the Content-Type header. Check self::contentTypes['createInvoice'] to see the possible values for this operation
     *
     * @throws \Xendit\XenditSdkException on non-2xx response
     * @throws \InvalidArgumentException
     * @return \Xendit\Invoice\Invoice
     */
    public function createInvoice($create_invoice_request, $for_user_id = null, string $contentType = self::contentTypes['createInvoice'][0])
    {
        list($response) = $this->createInvoiceWithHttpInfo($create_invoice_request, $for_user_id, $contentType);
        return $response;
    }

code saya:

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Xendit\Configuration;
use Xendit\Invoice\InvoiceApi;
use Xendit\Invoice\CreateInvoiceRequest;
use App\Models\Payment;
use Xendit\Invoice;
use Xendit\Xendit;

class PaymentController extends Controller
{
    public function createInvoice()
    {
        Configuration::setXenditKey(env('XENDIT_SECRET_KEY'));
        $apiInstance = new InvoiceApi();

        $create_invoice_request = new CreateInvoiceRequest([
            'external_id' => 'test1234',
            'description' => 'Test Invoice',
            'amount' => 10000,
            'invoice_duration' => 172800,
            'currency' => 'PHP',
            'reminder_time' => 1
        ]);

        try {            
            $result = $apiInstance->createInvoice($create_invoice_request);            
            return response()->json(['message' => 'Invoice created successfully', 'data' => $response]);

        } catch (\Xendit\XenditSdkException $e) {
            return response()->json(['message' => 'Exception when calling InvoiceApi->createInvoice: ' . $e->getMessage(), 'full_error' => $e->getFullError()], 500);
        }
    }

}

error:

ErrorException
Only variables should be passed by reference

tapi invoicenya berhasil kebuat di dashboard xenditnya, fixing errornya gimana ya .. trims before

mrepol742 commented 6 days ago

I'm also facing this kindof issue in v6.x.x of xendit-php. the only solution i found is to keep using the v2.x.x temporarily