#rajput.abd_22

1 messages ยท Page 1 of 1 (latest)

last hazelBOT
wise jungle
keen ridge
#

but i want to do like recurring that why i am using subscription

#

can i share my code here

wise jungle
#

sure

keen ridge
#

please check this

wise jungle
#

please paste whatever information you would like to share here in this channel

#

we won't open a Google doc to read any information inside

keen ridge
#

okay

#

module.exports.createProduct = async (clientFullName, nickname) => {
return await stripe.products.create({
name: ${clientFullName}-${nickname},
description: This product is for ${nickname} clientName: ${clientFullName}
});

}

#

module.exports.createPrice = async (nickname, amount, currency, productId, recurring = {}) => {
console.log("๐Ÿš€ ~ file: common.js:825 ~ module.exports.createPrice= ~ amount:", amount)
// let unit_amount = (parseFloat(amount) * 100).toFixed(2)
// console.log("๐Ÿš€ ~ file: common.js:828 ~ module.exports.createPrice= ~ unit_amount:", unit_amount)
console.log(typeof amount);
amount = parseFloat(amount);
console.log("๐Ÿš€ ~ file: common.js:830 ~ module.exports.createPrice= ~ amount:", amount)
console.log(typeof amount);
return await stripe.prices.create({
nickname: nickname,
unit_amount: parseInt(amount * 100),
currency: currency,
product: productId,
...recurring
})
}

#

module.exports.createSubscriptions = async (data) => {

const { customerId, description, items, add_invoice_items } = data;
return await stripe.subscriptions.create({
    customer: customerId,
    description: description,
    items: items,
    add_invoice_items: add_invoice_items,
    payment_settings: {
        payment_method_options: {
            card: {
                request_three_d_secure: 'any',
            },
        },
        payment_method_types: ['card'],
        save_default_payment_method: 'on_subscription',
    },
    expand: ['latest_invoice.payment_intent'],
});

}

#

module.exports.createSubscriptionOnUgradePlan = async (customerId, clientFullName, subscriptionAmount, interval) => {
const nickname = interval == constants.priceRecurringTimePeriod.MONTH ? 'Stikkum Monthly' : 'Stikkum Yearly'
const product = await exports.createProduct(clientFullName, nickname);
const recurringSubscription = await exports.createPrice(${clientFullName}-${nickname} PlatForm Amount, subscriptionAmount, currency, product.id, { recurring: { interval: interval } });

const subscription = await exports.createSubscriptions({
    customerId: customerId,
    description: `${clientFullName} ${nickname} Subscription`,
    items: [{ price: recurringSubscription.id }],
});

console.log("๐Ÿš€ ~ file: common.js:886 ~ module.exports.createSubscriptionOnStripe= ~ subscription:", subscription);
return subscription;

}

#

Please check now

wise jungle
#

what do you want me to check?

keen ridge
#

subscription is created with status: 'incomplete', but want it to created as succeceed

outer mulch
#

Hi! I'm taking over this thread.

keen ridge
#

what extra i need to do this

outer mulch
#

Can you share the Subscription ID (sub_xxx)?

keen ridge
#

its a test account

#

i am creating it using nodejs

#

sub_1NqAXKSBr5WCueGyqC960cdc this is subscription id