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
156 stars 77 forks source link

How go generate token on credit cart #157

Closed ferdinand-tjandra closed 2 years ago

ferdinand-tjandra commented 3 years ago

Hi all,

sorry if im missing to read the documentation. i still confuse how do we generate the token ID when we want to use credit cart option payment?

please help

xen-HendryZheng commented 3 years ago

Hi @ferdinand-tjandra For the Token ID, it is part of tokenization process which you can find more details here: https://docs.xendit.co/credit-cards/integrations/tokenization

shafarizkyf commented 2 years ago

same question, I couldn't find it also on the postman example. That link refers to xendit.js, may I know the endpoint to create token API? I want to generate token using curl if this part does not exist yet in this library

shafarizkyf commented 2 years ago

in case anyone needs it, got it working ` public function charge() { $params = [ 'card_data' => [ 'account_number' => (string) request('card_number'), 'exp_month' => (string) request('exp_month'), 'exp_year' => (string) request('exp_year'), 'cvn' => (string) request('cvn'), ], 'card_cvn' => request('cvn'), 'amount' => request('amount'), 'is_single_use' => true, 'should_authenticate' => true, 'currency' => request()->has('currency') ? request('currency') : 'IDR', ];

$response = Http::withHeaders([
  'Authorization' => 'Basic ' . base64_encode(config('xendit.public_key'). ':'),
])->post(config('xendit.base_url') . '/credit_card_tokens', $params);

return $response->json();

} `