xendit docs

Membuat Tagihan ( Creating Charges )

Deskripsi

Pada bagian ini kami berasumsi Anda telah melakukan pengumpulan dan tokenisasi kartu kredit pelanggan. Silakan lihat Mengumpulkan detail kartu sebelum melanjutkan.

Xendit.js dan form pembayaran saja belum dapat membuat tagihan credit card. Xendit.js dan form HTML baru memenuhi setengah proses yang harus dilakukan, dan kode pada sisi server diperlukan untuk menyelesaikan proses ini.

Ketika token telah berhasil dibuat baik dengan Xendit.js atau mobile SDK, token tersebut harus dikirimkan ke server kartu akan digunakan untuk membuat tagihan.

Setelah Anda berhasil memperoleh data kartu pelanggan yang telah di-tokensiasi dengan Xendit.js atau mobile SDK, Anda dapat melakukan penagihan kartu. Tidak seperti tokenisasi yang dilakukan di browser, penagihan dilakukan dari server Anda, pada umumnya menggunakan client library kami. Pada server Anda, gunakan token Xendit pada parameter POST yang akan Anda kirimkan. Setelah itu lakukan panggilan API dengan Xendit PHP client library untuk menagih kartu:

  • Curl
  • PHP
curl https://api.xendit.co/credit_card_charges -X POST \
	 -u xnd_development_O46JfOtygef9kMNsK+ZPGT+ZZ9b3ooF4w3Dn+R1k+2fT/7GlCAN3jg==: \
	 -d external_id=your-external-id \
	 -d token_id=your-token-id \
     -d amount=17000

Pastikan untuk menggunakan Secret API key dan bukan Publishable API key disini.

Selesai! jika request tagihan berhasil, maka kartu telah berhasil ditagih. Anda akan secara otomatis dalam tujuh hari. Jika penagihan gagal, Anda akan mendapatkan eror dari sistem.

Diagram berikut menunjukkan proses penagihan kartu kredit.

Ada dua tipe biaya dari pembayaran kartu kredit: biaya tetap dan biaya variabel. Biaya-biaya ini akan secara langsung dipotong dari tiap transaksi. Anda dapat melihat total biaya dari tiap transaksi melalui dasbor .

Referensi

Untuk referensi API selengkapnya dapat Anda lihat di API Reference kami.

Langkah Selanjutnya

Pertanyaan?

Masih memiliki pertanyaan? Dengan senang hati kami akan membantu Anda. Kirimkan email atau pesan melalui live chat .

Description

This section assumes you've already implemented a solution for collecting and tokenizing your customers' credit cards. If you haven't, see Collecting card details before proceeding.

Xendit.js and your payment form alone do not create a charge. Combined, Xendit.js and the HTML form fulfill the first half of the payment process, but server-side code is also necessary to complete the workflow.

Once the token has been successfully created with either Xendit.js or mobile SDK, it must be submitted to your server where the card can be charged use. After tokenization, the payment form should have a hidden field with the token ID, at which point the form should be submitted using JavaScript. (As a reminder, the form's submission was prevented earlier so the script could wait for Xendit to tokenize the credit card details.) All of the form's data will be sent as a POST request to the URL in the form's action. If you have other form elements, such as the user's email address, that will be submitted per usual.

After you've securely collected and tokenized your customer's credit card using Xendit.js or mobile SDK, you can charge the card. Unlike collection, which occurs in the browser, charge attempts are made from your server, normally using our client library. On your server, grab the Xendit token in the POST parameters submitted by your form. From there, it's one simple API call or Xendit PHP client library method call to charge the card:

  • Curl
  • PHP
curl https://api.xendit.co/credit_card_charges -X POST \
	 -u xnd_development_O46JfOtygef9kMNsK+ZPGT+ZZ9b3ooF4w3Dn+R1k+2fT/7GlCAN3jg==: \
	 -d external_id=your-external-id \
	 -d token_id=your-token-id \
     -d amount=17000

Be sure to use the Secret API key instead of the publishable API key here.

That's it! If the charge creation request succeeds, the card has been successfully charged. You will automatically receive your money in seven days. If the charge attempt fails, we'll return an error instead.

The diagam below shows this process at a high level.

There are two types of fee for credit card payment: fixed fee and variable fees. These fees will be deducted immediately for each transaction. You can see total fees for each transaction in dashboard .

There are two types of fee for credit card payment: fixed fee and variable fees. These fees will be deducted immediately for each transaction. You can see total fees for each transaction in dashboard .

Capture Reference

For full API reference you can check our API Reference .

Next Steps

Questions?

Still have more questions? We're always happy to help however we can. Shoot us an email or chat to us in live chat.