我试图区分客户是决定按月还是按年订阅。关键是,在进行订阅操作的按钮中,我具有不同的属性,其中之一是其中包含对象的付款选项:
<button
class="button azul enviar ga-event subscription-charge hide-oxxo"
id="button-plan-frecuente"
data-toggle="modal"
data-target="{!! $subWrappperClass !!}"
data-event-category="Contratos"
data-payment-options=
'{
"periodicity":
{
"month":
{
"_id":"5ba43f8c8269750b1e7f5fb5",
"conekta":"saas_frecuente_mensual",
"paypal":"2ZLSZBT4AT896"
},
"annual":
{
"_id":"5c66fff8b071e20f9804de18",
"conekta":"saas_frecuente_anual",
"paypal":"76J5PW7YQA2H4"
}
}
}'
data-product=
'{
"user_id":"{!! $document->user->id !!}",
"product_id":"{!! $document->id !!}",
"product_type":"unregistered_document"
}'
value="plan">
SUSCRÍBETE
</button>
我已经完成了访问每月订阅的功能,但是我不知道如何使其动态化,因此我可以根据客户的决定访问这两个订阅(每月或每年)。
if (subscriptionChargeBtn.length > 0) {
subscriptionChargeBtn.on ('click touch', function (event){
var btn = $(this);
var paymentOptions = JSON.parse (btn.attr ('data-payment-options'));
var productOptions = btn.attr('data-product');
$("#custom_parms").val (productOptions);
$("#hosted_button_id").val (paymentOptions.periodicity.month.paypal);
$('#conekta_plan_id').val (paymentOptions.periodicity.month.conekta);
$("#membership_id").val (paymentOptions.periodicity.month._id);
});
}