Generate product keys after successful payment with Digital Downloads?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
13 years ago
Hey all,

I am very new to the product but so far think it is great. I am currently doing a lot of custom code for a store environment on my site. Currently, when a custom completes a payment, PayPal sends a notification to a web service of mine and I generate a set of product keys and associate them with the customer's ID and product(s) they purchased.
I was wondering if there was something similar to this, or a plugin, with nopCommerce? In other words, I can create the product keys, but how do I know once a payment has gone through? And is there a way to display other content with the digital download so the customer can have product keys listed in there accounts along with their downloadable products.

Thanks in advance!
13 years ago
Hello !

I've done that this morning.

I'll explain you how I've done that :

I've add a Table : Nop_Product_ProductKey
with 2 columns : ProductID,ProductKey
Primary Key : the 2 columns

I've changed the StoreProcedure for OrderUpdate :

/****** Objet :  StoredProcedure [dbo].[Nop_OrderUpdate]    Date de génération du script : 11/23/2010 10:46:16 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[Nop_OrderUpdate]
(
  @OrderID int,
  @OrderGUID uniqueidentifier,
  @CustomerID int,
  @CustomerLanguageID int,
  @CustomerTaxDisplayTypeID int,
  @CustomerIP nvarchar(50),
  @OrderSubtotalInclTax money,
  @OrderSubtotalExclTax money,
  @OrderShippingInclTax money,
  @OrderShippingExclTax money,
  @PaymentMethodAdditionalFeeInclTax money,
  @PaymentMethodAdditionalFeeExclTax money,
  @OrderTax money,
  @OrderTotal money,
  @OrderDiscount money,
  @OrderSubtotalInclTaxInCustomerCurrency money,
  @OrderSubtotalExclTaxInCustomerCurrency money,
  @OrderShippingInclTaxInCustomerCurrency money,
  @OrderShippingExclTaxInCustomerCurrency money,
  @PaymentMethodAdditionalFeeInclTaxInCustomerCurrency money,
  @PaymentMethodAdditionalFeeExclTaxInCustomerCurrency money,
  @OrderTaxInCustomerCurrency money,
  @OrderTotalInCustomerCurrency money,
  @OrderDiscountInCustomerCurrency money,
  @CheckoutAttributeDescription nvarchar(4000),
  @CheckoutAttributesXML xml,
  @CustomerCurrencyCode nvarchar(5),
  @OrderWeight float,
  @AffiliateID int,
  @OrderStatusID int,
  @AllowStoringCreditCardNumber bit,
  @CardType nvarchar(100),
  @CardName nvarchar(100),
  @CardNumber nvarchar(100),
  @MaskedCreditCardNumber nvarchar(100),
  @CardCVV2 nvarchar(100),
  @CardExpirationMonth nvarchar(100),
  @CardExpirationYear nvarchar(100),
  @PaymentMethodID int,
  @PaymentMethodName nvarchar(100),
  @AuthorizationTransactionID nvarchar(4000),
  @AuthorizationTransactionCode nvarchar(4000),
  @AuthorizationTransactionResult nvarchar(1000),
  @CaptureTransactionID nvarchar(4000),
  @CaptureTransactionResult nvarchar(1000),
  @SubscriptionTransactionID nvarchar(4000),
  @PurchaseOrderNumber nvarchar(100),
  @PaymentStatusID int,
  @PaidDate datetime,
  @BillingFirstName nvarchar(100),
  @BillingLastName nvarchar(100),
  @BillingPhoneNumber nvarchar(50),
  @BillingEmail nvarchar(255),
  @BillingFaxNumber nvarchar(50),
  @BillingCompany nvarchar(100),
  @BillingAddress1 nvarchar(100),
  @BillingAddress2 nvarchar(100),
  @BillingCity nvarchar(100),
  @BillingStateProvince nvarchar(100),
  @BillingStateProvinceID int,
  @BillingZipPostalCode nvarchar(10),
  @BillingCountry nvarchar(100),
  @BillingCountryID int,
  @ShippingStatusID int,
  @ShippingFirstName nvarchar(100),
  @ShippingLastName nvarchar(100),
  @ShippingPhoneNumber nvarchar(50),
  @ShippingEmail nvarchar(255),
  @ShippingFaxNumber nvarchar(50),
  @ShippingCompany nvarchar(100),
  @ShippingAddress1 nvarchar(100),
  @ShippingAddress2 nvarchar(100),
  @ShippingCity nvarchar(100),
  @ShippingStateProvince nvarchar(100),
  @ShippingStateProvinceID int,
  @ShippingZipPostalCode nvarchar(10),
  @ShippingCountry nvarchar(100),
  @ShippingCountryID int,
  @ShippingMethod nvarchar(100),
  @ShippingRateComputationMethodID int,
  @ShippedDate datetime,
  @DeliveryDate datetime,
  @TrackingNumber nvarchar(100),
  @Deleted bit,
  @CreatedOn datetime
)
AS
BEGIN
  UPDATE [Nop_Order]
  SET
    OrderGUID=@OrderGUID,
    CustomerID=@CustomerID,
    CustomerLanguageID=@CustomerLanguageID,    
    CustomerTaxDisplayTypeID=@CustomerTaxDisplayTypeID,
    CustomerIP=@CustomerIP,
    OrderSubtotalInclTax=@OrderSubtotalInclTax,
    OrderSubtotalExclTax=@OrderSubtotalExclTax,    
    OrderShippingInclTax=@OrderShippingInclTax,
    OrderShippingExclTax=@OrderShippingExclTax,
    PaymentMethodAdditionalFeeInclTax=@PaymentMethodAdditionalFeeInclTax,
    PaymentMethodAdditionalFeeExclTax=@PaymentMethodAdditionalFeeExclTax,
    OrderTax=@OrderTax,
    OrderTotal=@OrderTotal,
    OrderDiscount=@OrderDiscount,
    OrderSubtotalInclTaxInCustomerCurrency=@OrderSubtotalInclTaxInCustomerCurrency,
    OrderSubtotalExclTaxInCustomerCurrency=@OrderSubtotalExclTaxInCustomerCurrency,
    OrderShippingInclTaxInCustomerCurrency=@OrderShippingInclTaxInCustomerCurrency,
    OrderShippingExclTaxInCustomerCurrency=@OrderShippingExclTaxInCustomerCurrency,  
    PaymentMethodAdditionalFeeInclTaxInCustomerCurrency=@PaymentMethodAdditionalFeeInclTaxInCustomerCurrency,
    PaymentMethodAdditionalFeeExclTaxInCustomerCurrency=@PaymentMethodAdditionalFeeExclTaxInCustomerCurrency,  
    OrderTaxInCustomerCurrency=@OrderTaxInCustomerCurrency,
    OrderTotalInCustomerCurrency=@OrderTotalInCustomerCurrency,
    OrderDiscountInCustomerCurrency=@OrderDiscountInCustomerCurrency,
    CheckoutAttributeDescription=@CheckoutAttributeDescription,
    CheckoutAttributesXML=@CheckoutAttributesXML,
    CustomerCurrencyCode=@CustomerCurrencyCode,
    OrderWeight=@OrderWeight,
    AffiliateID=@AffiliateID,
    OrderStatusID=@OrderStatusID,
    AllowStoringCreditCardNumber=@AllowStoringCreditCardNumber,
    CardType=@CardType,
    CardName=@CardName,
    CardNumber=@CardNumber,
    MaskedCreditCardNumber=@MaskedCreditCardNumber,
    CardCVV2=@CardCVV2,
    CardExpirationMonth=@CardExpirationMonth,
    CardExpirationYear=@CardExpirationYear,
    PaymentMethodID=@PaymentMethodID,
    PaymentMethodName=@PaymentMethodName,
    AuthorizationTransactionID=@AuthorizationTransactionID,
    AuthorizationTransactionCode=@AuthorizationTransactionCode,
    AuthorizationTransactionResult=@AuthorizationTransactionResult,
    CaptureTransactionID=@CaptureTransactionID,
    CaptureTransactionResult=@CaptureTransactionResult,
    SubscriptionTransactionID=@SubscriptionTransactionID,
    PurchaseOrderNumber=@PurchaseOrderNumber,
    PaymentStatusID=@PaymentStatusID,
    PaidDate=@PaidDate,
    BillingFirstName=@BillingFirstName,
    BillingLastName=@BillingLastName,
    BillingPhoneNumber=@BillingPhoneNumber,
    BillingEmail=@BillingEmail,
    BillingFaxNumber=@BillingFaxNumber,
    BillingCompany=@BillingCompany,
    BillingAddress1=@BillingAddress1,
    BillingAddress2=@BillingAddress2,
    BillingCity=@BillingCity,
    BillingStateProvince=@BillingStateProvince,
    BillingStateProvinceID=@BillingStateProvinceID,
    BillingZipPostalCode=@BillingZipPostalCode,
    BillingCountry=@BillingCountry,
    BillingCountryID=@BillingCountryID,
    ShippingStatusID=@ShippingStatusID,
    ShippingFirstName=@ShippingFirstName,
    ShippingLastName=@ShippingLastName,
    ShippingPhoneNumber=@ShippingPhoneNumber,
    ShippingEmail=@ShippingEmail,
    ShippingFaxNumber=@ShippingFaxNumber,
    ShippingCompany=@ShippingCompany,
    ShippingAddress1=@ShippingAddress1,
    ShippingAddress2=@ShippingAddress2,
    ShippingCity=@ShippingCity,
    ShippingStateProvince=@ShippingStateProvince,
    ShippingStateProvinceID=@ShippingStateProvinceID,
    ShippingZipPostalCode=@ShippingZipPostalCode,
    ShippingCountry=@ShippingCountry,
    ShippingCountryID=@ShippingCountryID,
    ShippingMethod=@ShippingMethod,
    ShippingRateComputationMethodID=@ShippingRateComputationMethodID,
    ShippedDate=@ShippedDate,
    DeliveryDate=@DeliveryDate,
    TrackingNumber=@TrackingNumber,
    Deleted=@Deleted,
    CreatedOn=@CreatedOn
  WHERE
    OrderID = @OrderID

  UPDATE v set v.AttributeDescription='ProductKey : '+(SELECT TOP 1 ProductKey FROM Nop_Product_ProductKey WHERE ProductId=v.ProductVariantID ORDER BY NEWID())
  FROM Nop_OrderProductVariant v
  INNER JOIN Nop_Order o
  ON v.OrderID=o.OrderID
  WHERE o.OrderStatusID=30 AND v.AttributeDescription NOT LIKE 'ProductKey%'
    
END


Perhaps you'll need to add a condition in the where clause for the ProductVariantID (isdownloadable?)

For information, it's the last version of NopCommerce (1.80).
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.