Loading...
 

Dynamic Pricing


Dynamic Pricing allows you to create new pricing options dynamically by passing variables into the CCBill FlexForm. This can be done by including the variables into the URL string or by passing the variables into the CCBill FlexForms widget. To enhance security, an MD5 Hex Digest is used to validate the input of the new price. Single billing and recurring billing subscriptions can be created using Dynamic Pricing, with the passed-in variables defining the pricing structure.

Why use Dynamic Pricing?

Dynamic Pricing is useful in many different types of Merchant Account Setups:

  • It's more secure. You need to encrypt the data that is being sent to the form.
  • Ideal for shopping carts. Dynamic Pricing is used for shopping carts to pass a total value of a cart or multiple products into one.
  • Great for modifying Price Points on the fly. Merchants can use Dynamic Pricing to easily modify their pricing.

VARIABLES

The set of variables passed into the form will depend on the type of transaction. The following variables
are required for both single and recurring transactions:

  • clicntAccnum. An integer value representing the 6-digit merchant account number.
  • clientSubacc. An integer value representing the 4-digit merchant subaccount number the customer should be charged on.
  • initialPrice. A decimal value representing the initial price.
  • initialPeriod. An integer representing the length, in days, of the initial billing period. By default this is a 30, 60, or 90 day period.
  • currencyCode. An integer representing the 3-digit currency code that will be used for the transaction.
    • 978 - EUR
    • 036 - AUD
    • 124 - CAD
    • 826 - GBP
    • 392 - JPY
    • 840 - USD
  • formDigest. An MD5 Hex Digest based on the above values; this is explained further in the next section.
The following variables are required for recurring transactions only. Omitting these variables will result in a single billing transaction:

  • recurringPrice. A decimal value representing the recurring billing price.
  • recurringPeriod. An integer representing the number of days between each rebill.
  • numRebills. An integer representing the total times the subscription will rebill. Passing a value of 99 will cause the subscription to rebill indefinitely.

GENERATING THE MD5 HASH

The formDigest value is a hex-encoded MD5 hash, calculated using a combination of the above fields and a salt value. More information can be found about salt cryptography here.

CCBill uses your salt value to verify the hash and can be obtained in one of two ways:
  1. Contact merchant support and receive the salt value, OR
  2. Create your own salt value (up to 32 alphanumeric characters) and provide it to Merchant Support.
Using your preferred MD5 hash generation tool and the Hex encoding method, you will need to create an MD5 Hex Digest using certain variable values. Values should be concatenated into one single string with no spaces prior to hashing.

For single billing transactions, use the following values in the order they are listed:
  1. initialPrice
  2. initialPeriod
  3. currencyCode
  4. salt
For recurring transactions, use the following values in the order they are listed:
  1. initialPrice
  2. initialPeriod
  3. recurringPrice
  4. recurringPeriod
  5. numRebills
  6. currencyCode
  7. salt
The resulting MD5 hash will be used as the value for the formDigest variable. This value can be statically hard-coded into a page or generated “on the fly” using a custom script.

Prior to hashing: 10.0030840qwertyasdfgzxcvbnhyujm
After hashing: 931d2fa3cf0ed016780712901308bfad
formDigest value: formDigest=931d2fa3cf0ed016780712901308bfad

CODE EXAMPLES

The following example shows the data being passed through the URL string:

https://api.ccbill.com/wap-frontflex/flexforms/687fa3e0-e60d-4466-88e2-181fa56dd6a9?clientSubacc=0000&initialPrice=2.99&initialPeriod=3&recurringPrice=29.95&recurringPeriod=30&numRebills=99&currencyCode=840&formDigest=b297c69ade4d73a84b47c0f5909256ff

You can also pass the variables into the CCBill widget to utilize dynamic pricing.
Original Version (from admin):

<script type="text/javascript" class="CCBillWidget687fa3e0-e60d-4466-88e2-181fa56dd6a9_109" src="https://images.ccbill.com/flexforms/ccbill-widget-live.js">

Modified Version:

<script type="text/javascript" class="CCBillWidget687fa3e0-e60d-4466-88e2-181fa56dd6a9_109" src="https://images.ccbill.com/flexforms/ccbill-widget-live.js">        
{ "parameters" :              
	{ 
	"formDigest" : "b297c69ade4d73a84b47c0f5909256ff", 
	"clientSubacc" : "0000",            
	"initialPrice" : "2.99",    
	"initialPeriod" : "3",      
	"recurringPrice" : "29.95",    
	"recurringPeriod" : "30",       
	"numRebills" : "99",            
	"currencyCode" : "840"           
	}      
}        
</script>
</div>

Response Digest Value

Dynamic Pricing requests will return the responseDigest value using the the Background Post System or the dynamicPricingValidationDigest in Webhooks.

This value is an MD5 hash of transaction results which can be used to verify that the response was received properly by CCBill. The value for responseDigest will contain an MD5 hash of the following values for approved transactions, concatenated into a single string:

Value Definition
subscriptionId The unique subscription ID number for the subscription.
1 This value is simply the number 1 (one), used to show the transaction was approved.
salt The same value for salt mentioned in the Generating the MD5 Hash section above.

These values will be sent to the Approval Post URL or Webhooks URL configured for newSaleSuccess.


The value for responseDigest will contain an MD5 hash of the following values for denied transactions, concatenated into a single string:

Value Definition
denialId The unique denial ID number for the subscription.
0 This value is simply the number 0 (zero), used to show the transaction was denied.
salt The same value for salt mentioned in the Generating the MD5 Hash section above.

These values will be sent to the Denial Post URL or the URL configured for newSaleFailures in Webhooks.