Gift represents a subscription of a customer(recipient) to a 'gift plan' which has been gifted by another customer(gifter). It may also have addons and coupons. Gift will be created only on immediate successful payment collection from the gifter's payment method.
Gift is initially created in 'scheduled' state. The gift can be scheduled to be notified on a particular date to the recipient by passing 'scheduled_at'. If not, the recipient is notified immediately. Gift will be moved to 'unclaimed' state on the date of notification. If you pass auto_claim as true, gift status will be moved to ‘claimed’ immediately, otherwise, the gift will remain 'unclaimed' till the recipient claims the gift.
If the gift is not claimed before the claim_expiry_date, it will be moved to the 'expired' state.
Gift subscriptions will be created in 'future' state. Once the gift is claimed, the subscription will be moved to 'non-renewing' state.
Gift subscriptions will be invoiced immediately. The invoice created has is_gifted as 'true' and term_finalized as 'false'. This is because initially the invoice term_start and term_end are set as the subscription's start_date till the end of the plan period. Once the gift is claimed, the invoice's term_finalized will be marked as 'true'. The term_start will be changed to the actual invoice's term, which is the gift-claim date and the term_end will be changed till plan's period.
{
"auto_claim": false,
"claim_expiry_date": 1525850488,
"gift_receiver": {
"customer_id": "receiver",
"email": "james@user.com",
"first_name": "James",
"last_name": "William",
"object": "gift_receiver",
"subscription_id": "__test__8asuuSB15GTGh"
},
"gift_timelines": [
{
"object": "gift_timeline",
"occurred_at": 1517469689,
"status": "scheduled"
}
],
"gifter": {
"customer_id": "gifter",
"invoice_id": "__demo_inv__1",
"object": "gifter",
"signature": "Sam"
},
"id": "__test__8asuuSB15GYVo__test__sfsBDu8yg3K6cFiTkMu3cdNcF5Hz9NufM",
"no_expiry": false,
"object": "gift",
"resource_version": 1517469689000,
"scheduled_at": 1518074488,
"status": "scheduled",
"updated_at": 1517469689
}
chargebee.gift
scheduled_at
. If the gift is not claimed within claim_expiry_date
, it will expire and the subscription will move to cancelled
state. When not passed, the value specified in the site settings will be used.
Pass as NULL
or do not pass when auto_claim
or no_expiry
are set. import { ChargeBee, _gift } from 'chargebee-typescript'; var chargebee = new ChargeBee(); chargebee.configure({site : "{site}", api_key : "{site_api_key}"}); chargebee.gift.create_for_items({ scheduled_at : 1518074488, gifter : { customer_id : "gifter", signature : "Sam" }, gift_receiver : { customer_id : "receiver", first_name : "James", last_name : "William", email : "james@user.com" }, subscription_items : [ { item_price_id : "day-pass-USD" }, { item_price_id : "basic-USD", quantity : 2 }] }).request(function(error,result) { if(error){ //handle error console.log(error); }else{ console.log(`${result}`); var gift: typeof chargebee.gift = result.gift; var subscription: typeof chargebee.subscription = result.subscription; var invoice: typeof chargebee.invoice = result.invoice; } });
import { ChargeBee, _gift } from 'chargebee-typescript'; var chargebee = new ChargeBee(); chargebee.configure({site : "{site}", api_key : "{site_api_key}"}); chargebee.gift.create_for_items({ scheduled_at : 1518074488, gifter : { customer_id : "gifter", signature : "Sam" }, gift_receiver : { customer_id : "receiver", first_name : "James", last_name : "William", email : "james@user.com" }, subscription_items : [ { item_price_id : "day-pass-USD" }, { item_price_id : "basic-USD", quantity : 2 }] }).request(function(error,result) { if(error){ //handle error console.log(error); }else{ console.log(`${result}`); var gift: typeof chargebee.gift = result.gift; var subscription: typeof chargebee.subscription = result.subscription; var invoice: typeof chargebee.invoice = result.invoice; } });
chargebee.gift.create_for_items({<param name> : <value>,<param name> : <value> ...})
scheduled_at
. If the gift is not claimed within claim_expiry_date
, it will expire and the subscription will move to cancelled
state. When not passed, the value specified in the site settings will be used.
Pass as NULL
or do not pass when auto_claim
or no_expiry
are set. checkout_com
: While adding a new payment method using permanent token or passing raw card details to Checkout.com, document
ID and country_of_residence
are required to support payments through dLocal.payer
: User related information.country_of_residence
: This is required since the billing country associated with the user’s payment method may not be the same as their country of residence. Hence the user’s country of residence needs to be specified. The country code should be a two-character ISO code.document
: Document ID is the user’s identification number based on their country.bluesnap
: While passing raw card details to BlueSnap, if fraud_session_id
is added, additional validation is performed to avoid fraudulent transactions.fraud
: Fraud identification related information.fraud_session_id
: Your BlueSnap fraud session ID required to perform anti-fraud validation.braintree
: While passing raw card details to Braintree, your fraud_merchant_id
and the user’s device_session_id
can be added to perform additional validation and avoid fraudulent transactions.fraud
: Fraud identification related information.device_session_id
: Session ID associated with the user's device.fraud_merchant_id
: Your merchant ID for fraud detection.chargebee_payments
: While passing raw card details to Chargebee Payments, if fraud_session_id
is added, additional validation is performed to avoid fraudulent transactions.fraud
: Fraud identification related information.fraud_session_id
: Your Chargebee Payments fraud session ID required to perform anti-fraud validation.bank_of_america
: While passing raw card details to Bank of America, your user’s device_session_id
can be added to perform additional validation and avoid fraudulent transactions.fraud
: Fraud identification related information.device_session_id
: Session ID associated with the user's device.ecentric
: This parameter is used to verify and process payment method details in Ecentric. If the merchant_id
parameter is included, Chargebee will vault it / perform a lookup and verification against this merchant_id
, overriding the one configured in Chargebee. If tokens and processing occur in the same Merchant GUID, you can just skip this part. merchant_id
: Merchant GUID where the card is vaulted or need to be vaulted.ebanx
: While passing raw card details to EBANX, the user's document
is required for some countries and device_session_id
can be added to perform additional validation and avoid fraudulent transactions. payer
: User related information. document
: Document is the user's identification number based on their country. fraud
: Fraud identification related information. device_session_id
: Session ID associated with the user's device state_code
as AZ
(not US-AZ
). For Tamil Nadu (India), set as TN
(not IN-TN
). For British Columbia (Canada), set as BC
(not CA-BC
). state_code
is provided. Brexit
If you have enabled EU VAT in 2021 or later, or have manually enable the Brexit configuration, then XI
(the code for United Kingdom – Northern Ireland) is available as an option.
import { ChargeBee, _gift } from 'chargebee-typescript'; var chargebee = new ChargeBee(); chargebee.configure({site : "{site}", api_key : "{site_api_key}"}); chargebee.gift.retrieve("__test__KyVnHhSBWTKhSAD__test__XF08jFEYWbAon3fSbc3IriS1N4UNhacdS").request(function(error,result) { if(error){ //handle error console.log(error); }else{ console.log(`${result}`); var gift: typeof chargebee.gift = result.gift; var subscription: typeof chargebee.subscription = result.subscription; } });
import { ChargeBee, _gift } from 'chargebee-typescript'; var chargebee = new ChargeBee(); chargebee.configure({site : "{site}", api_key : "{site_api_key}"}); chargebee.gift.retrieve("__test__KyVnHhSBWTKhSAD__test__XF08jFEYWbAon3fSbc3IriS1N4UNhacdS").request(function(error,result) { if(error){ //handle error console.log(error); }else{ console.log(`${result}`); var gift: typeof chargebee.gift = result.gift; var subscription: typeof chargebee.subscription = result.subscription; } });
chargebee.gift.retrieve(<gift_id>,{<param name> : <value>,<param name> : <value> ...})
import { ChargeBee, _gift } from 'chargebee-typescript'; var chargebee = new ChargeBee(); chargebee.configure({site : "{site}", api_key : "{site_api_key}"}); chargebee.gift.list({ limit : 2, status : { is : "scheduled" } }).request(function(error,result) { if(error){ //handle error console.log(error); }else{ for(var i = 0; i < result.list.length;i++){ var entry=result.list[i] console.log(`${entry}`); var gift: typeof chargebee.gift = entry.gift; var subscription: typeof chargebee.subscription = entry.subscription; } } });
import { ChargeBee, _gift } from 'chargebee-typescript'; var chargebee = new ChargeBee(); chargebee.configure({site : "{site}", api_key : "{site_api_key}"}); chargebee.gift.list({ limit : 2, status : { is : "scheduled" } }).request(function(error,result) { if(error){ //handle error console.log(error); }else{ for(var i = 0; i < result.list.length;i++){ var entry=result.list[i] console.log(`${entry}`); var gift: typeof chargebee.gift = entry.gift; var subscription: typeof chargebee.subscription = entry.subscription; } } });
chargebee.gift.list({<param name> : <value>,<param name> : <value> ...})
import { ChargeBee, _gift } from 'chargebee-typescript'; var chargebee = new ChargeBee(); chargebee.configure({site : "{site}", api_key : "{site_api_key}"}); chargebee.gift.claim("__test__KyVnHhSBWTK3l9N__test__ydFDqluaE3CT6DkcdbI5SNhpzjXlrnh5G").request(function(error,result) { if(error){ //handle error console.log(error); }else{ console.log(`${result}`); var gift: typeof chargebee.gift = result.gift; var subscription: typeof chargebee.subscription = result.subscription; } });
import { ChargeBee, _gift } from 'chargebee-typescript'; var chargebee = new ChargeBee(); chargebee.configure({site : "{site}", api_key : "{site_api_key}"}); chargebee.gift.claim("__test__KyVnHhSBWTK3l9N__test__ydFDqluaE3CT6DkcdbI5SNhpzjXlrnh5G").request(function(error,result) { if(error){ //handle error console.log(error); }else{ console.log(`${result}`); var gift: typeof chargebee.gift = result.gift; var subscription: typeof chargebee.subscription = result.subscription; } });
chargebee.gift.claim(<gift_id>,{<param name> : <value>,<param name> : <value> ...})
import { ChargeBee, _gift } from 'chargebee-typescript'; var chargebee = new ChargeBee(); chargebee.configure({site : "{site}", api_key : "{site_api_key}"}); chargebee.gift.cancel("__test__KyVnHhSBWTJsq9A__test__Y3tQPFRGBG1DZEFsDztdQMlBxpQcdkTcdM").request(function(error,result) { if(error){ //handle error console.log(error); }else{ console.log(`${result}`); var gift: typeof chargebee.gift = result.gift; var subscription: typeof chargebee.subscription = result.subscription; } });
import { ChargeBee, _gift } from 'chargebee-typescript'; var chargebee = new ChargeBee(); chargebee.configure({site : "{site}", api_key : "{site_api_key}"}); chargebee.gift.cancel("__test__KyVnHhSBWTJsq9A__test__Y3tQPFRGBG1DZEFsDztdQMlBxpQcdkTcdM").request(function(error,result) { if(error){ //handle error console.log(error); }else{ console.log(`${result}`); var gift: typeof chargebee.gift = result.gift; var subscription: typeof chargebee.subscription = result.subscription; } });
chargebee.gift.cancel(<gift_id>,{<param name> : <value>,<param name> : <value> ...})
import { ChargeBee, _gift } from 'chargebee-typescript'; var chargebee = new ChargeBee(); chargebee.configure({site : "{site}", api_key : "{site_api_key}"}); chargebee.gift.update_gift("__test__KyVnHhSBWTKnYAO__test__KdVPIxcd0gzgN1seidYQtm0ScuBcUgc3av",{ comment : "Customer called and requested the change.", scheduled_at : 1517587891 }).request(function(error,result) { if(error){ //handle error console.log(error); }else{ console.log(`${result}`); var gift: typeof chargebee.gift = result.gift; var subscription: typeof chargebee.subscription = result.subscription; } });
import { ChargeBee, _gift } from 'chargebee-typescript'; var chargebee = new ChargeBee(); chargebee.configure({site : "{site}", api_key : "{site_api_key}"}); chargebee.gift.update_gift("__test__KyVnHhSBWTKnYAO__test__KdVPIxcd0gzgN1seidYQtm0ScuBcUgc3av",{ comment : "Customer called and requested the change.", scheduled_at : 1517587891 }).request(function(error,result) { if(error){ //handle error console.log(error); }else{ console.log(`${result}`); var gift: typeof chargebee.gift = result.gift; var subscription: typeof chargebee.subscription = result.subscription; } });
chargebee.gift.update_gift(<gift_id>,{<param name> : <value>,<param name> : <value> ...})