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

xenPlatform - create invoice with "with-fee-rule" header value #194

Closed menjilx closed 1 year ago

menjilx commented 1 year ago

Hi, I tried to create an "invoice" under xenPlatform account but I can't make it work when I tried to add custom headers value $headers = [ 'Content-Type' => 'application/json', 'for-user-id' => '62d14fbebb76ff3520f7cacc', 'with-fee-rule' => 'xpfeeru_c45922a7-e88c-49f9-8164-c1aed8a76769', ];

The invoice will be created but it will just place under the "main account" and not on the "xenPlatform user account".

complete invoice request code:


use Xendit\Xendit;

require 'vendor/autoload.php';

Xendit::setApiKey('API KEY');

$headers = [];
$headers = [
    'Content-Type' => 'application/json',
    'for-user-id' => '62d14fbebb76ff3520f7cacc',
    'with-fee-rule' => 'xpfeeru_c45922a7-e88c-49f9-8164-c1aed8a76769',
    ];

$params = [
    'external_id' => 'demo_2',
    'amount' => 599,
    'description' => 'Invoice Demo #2',
    'invoice_duration' => 86400,
    'customer' => [
        'given_names' => 'Pedro',
        'surname' => 'Juan',
        'email' => 'johndoe@example.com',
        'mobile_number' => '+6287774441111',
        'addresses' => [
            [
                'city' => 'Jakarta Selatan',
                'country' => 'Indonesia',
                'postal_code' => '12345',
                'state' => 'Daerah Khusus Ibukota Jakarta',
                'street_line1' => 'Jalan Makan',
                'street_line2' => 'Kecamatan Kebayoran Baru'
            ]
        ]
    ],
    'customer_notification_preference' => [
        'invoice_created' => [
            'whatsapp',
            'sms',
            'email',
            'viber'
        ],
        'invoice_reminder' => [
            'whatsapp',
            'sms',
            'email',
            'viber'
        ],
        'invoice_paid' => [
            'whatsapp',
            'sms',
            'email',
            'viber'
        ],
        'invoice_expired' => [
            'whatsapp',
            'sms',
            'email',
            'viber'
        ]
    ],
    'success_redirect_url' => 'https=>//www.google.com',
    'failure_redirect_url' => 'https=>//www.google.com',
    'currency' => 'PHP',
    'items' => [
        [
            'name' => 'TIP',
            'quantity' => 1,
            'price' => 599,
            'category' => 'TIP',
            'url' => 'https://example.com'
        ]
    ]
];

$createInvoice = \Xendit\Invoice::create($params, $headers);
var_dump($createInvoice);
feliciagojali commented 1 year ago

hello @menjilx can you follow the example request for create invoice stated in the readme?

image
adityarx commented 1 year ago

Closed as answered, thanks @feliciagojali!