Payment Methods

Once you have a Conekta Customer, you can add Payment methods. Currently, only cards types are supported.

To add a payment method, you need the token of the corresponding card. You can read more about tokens on https://developers.conekta.com/page/bibliotecas-de-programaci%C3%B3n depending if you’re on web or mobile.

$token_id = $request->get('token_id') // The token for the card

$user = $request->user();
$payment_method = $user->addPaymentMethod($token_id); //Will return a LaravelConekta Paymentmethod instanceLenguaje del código: PHP (php)

If you want to retrive all the payment methods for the customer, you can do:

$user->paymentMethods();Lenguaje del código: PHP (php)

This will return a collection of LaravelConekta\PaymentMethod instances. For each of these, you can access to the Conekta\PaymentSource properties with the __get method:

$payment_method = $user->paymentMethods()->first();
$conekta_pm_id = $payment_method->__get('id'); // Will return the ConektaPaymentSource unique idLenguaje del código: PHP (php)

If you wish to set a default payment method, you can use the setDefaultPaymentMethod

$payment_method = $user->paymentMethods()->first();
$user->setDefaultPaymentMethod($payment_method);Lenguaje del código: PHP (php)

And, of course, later, you may retrive the user’s default payment method:

$default_payment_method = $user->getDefaultPaymentMethod(); // Will return a LaravelConekta\PaymentMethod instance.Lenguaje del código: PHP (php)

If you wish to find a specific payment method, you can:

$payment_method_id = 'src_conekta_payment_method_id';
$payment_method = $user->findPaymentMethod($payment_method_id); // Will return a LaravelConekta\PaymentMethod instance.Lenguaje del código: PHP (php)

And, if you want to remove a specific payment method:

$payment_method = $user->paymentMethods()->first();
$user->removePaymentMethod($payment_method);Lenguaje del código: PHP (php)

Was this page helpful?
Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *

Este sitio usa Akismet para reducir el spam. Aprende cómo se procesan los datos de tus comentarios.