How to remove parameters that has null from the docusign result - docusignapi

I have implemented the endpoint by using DocuSign Java SDK and it is working fine but the result is a bit different in comparison to the result getting from Postman. Below is the result from Postman when calling {{baseUrl}}/v2.1/accounts/{{accountId}}/envelopes?folder_ids=out_for_signature&include=recipients&exclude=folders,powerforms
result
{
"resultSetSize": "1",
"startPosition": "0",
"endPosition": "0",
"totalSetSize": "1",
"nextUri": "",
"previousUri": "",
"envelopes": [
{
"status": "sent",
"documentsUri": "/envelopes/xxxx-9777-7153b02d44e3/documents",
"recipientsUri": "/envelopes/axxxxfaf-9777-7153b02d44e3/recipients",
"attachmentsUri": "/envelopes/xxxxaf-9777-7153b02d44e3/attachments",
"envelopeUri": "/envelopes/xxxxx4faf-9777-7153b02d44e3",
"emailSubject": "Please sign this document set",
"envelopeId": "a826d1da-8cf6-4faf-9777-7153b02d44e3",
"customFieldsUri": "/envelopes/xxf-9777-7153b02d44e3/custom_fields",
"notificationUri": "/envelopes/x6-4faf-9777xxxx-7153b02d44e3/notification",
"createdDateTime": "2021-12-06T21:27:02.8300000Z",
"lastModifiedDateTime": "2021-12-14T19:45:07.3300000Z",
"initialSentDateTime": "2021-12-06T21:27:04.0800000Z",
"sentDateTime": "2021-12-13T20:19:00.8570000Z",
"statusChangedDateTime": "2021-12-14T19:45:07.3900000Z",
"documentsCombinedUri": "/envelopes/a826d1da-8cf6-4faf-9777-7153b02d44e3/documents/combined",
"certificateUri": "/envelopes/xxxx-4faf-9777-7153b02d44e3/documents/certificate",
"templatesUri": "/envelopes/xxxx4faf-9777-7153b02d44e3/templates",
"expireEnabled": "true",
"expireDateTime": "2022-04-05T21:27:04.0800000Z",
"expireAfter": "111",
"sender": {
"userName": "rizauddin Mohammad",
"userId": "xxxxxx11-987f-0c9253822c79",
"accountId": "xxxxx-46d2-9f5e-d39f7ffaeec3"
},
"certifiedDeliveries": [],
"inPersonSigners": [],
"seals": [],
"witnesses": [],
"notaries": [],
"recipientCount": "2",
"currentRoutingOrder": "1"
},
"purgeState": "unpurged",
"isSignatureProviderEnvelope": "false",
"anySigner": null,
"envelopeLocation": "current_site"
}
]
}
And the result from SDK when having this code
final EnvelopesApi envelopesApi = new EnvelopesApi(apiClient);
val options = envelopesApi.new ListStatusChangesOptions();
options.setFolderIds("out_for_signature");
options.setInclude("recipients");
options.setExclude("folders,powerForms");
EnvelopesInformation envelopesInformation = envelopesApi.listStatusChanges(accountId, options);
[
{
"accessControlListBase64": null,
"allowComments": null,
"allowMarkup": null,
"allowReassign": null,
"allowViewHistory": null,
"anySigner": null,
"asynchronous": null,
"attachmentsUri": "/envelopes/xxxxx9777-7153b02d44e3/attachments",
"authoritativeCopy": null,
"authoritativeCopyDefault": null,
"autoNavigation": null,
"brandId": null,
"brandLock": null,
"certificateUri": "/envelopes/a826d1da-8cf6-4faf-9777-7153b02d44e3/documents/certificate",
"completedDateTime": null,
"copyRecipientData": null,
"createdDateTime": "2021-12-06T21:27:02.8300000Z",
"customFields": null,
"customFieldsUri": "/envelopes/xxxx6-4faf-9777-7153b02d44e3/custom_fields",
"declinedDateTime": null,
"deletedDateTime": null,
"deliveredDateTime": null,
"disableResponsiveDocument": null,
"documentBase64": null,
"documentsCombinedUri": "/envelopes/a826d1da-8cf6-4faf-9777-7153b02d44e3/documents/combined",
"documentsUri": "/envelopes/xxxxx4faf-9777-7153b02d44e3/documents",
"emailBlurb": null,
"emailSettings": null,
"emailSubject": "Please sign this document set",
"enableWetSign": null,
"enforceSignerVisibility": null,
"envelopeAttachments": null,
"envelopeDocuments": null,
"envelopeId": "xxxx-9777-7153b02d44e3",
"envelopeIdStamping": null,
"envelopeLocation": "current_site",
"envelopeMetadata": null,
"envelopeUri": "/envelopes/xxxxx4faf-9777-7153b02d44e3",
"expireAfter": "111",
"expireDateTime": "2022-04-05T21:27:04.0800000Z",
"expireEnabled": "true",
"externalEnvelopeId": null,
"certifiedDeliveries": [],
"currentRoutingOrder": "1",
"editors": [],
"errorDetails": null,
"inPersonSigners": [],
"intermediaries": [],
"notaries": [],
"recipientCount": "2",
"seals": [],
"signers": [
{
"accessCode": null,
"accessCodeMetadata": null,
"addAccessCodeToEmail": null,
"additionalNotifications": null,
"agentCanEditEmail": null,
"agentCanEditName": null,
"allowSystemOverrideForLockedRecipient": null,
"autoNavigation": null,
"autoRespondedReason": null,
"bulkRecipientsUri": null,
"canSignOffline": null,
"clientUserId": null,
"completedCount": "0",
"creationReason": "sender",
"customFields": null,
"declinedDateTime": null,
"declinedReason": null,
"defaultRecipient": null,
"deliveredDateTime": null,
"deliveryMethod": "email",
"deliveryMethodMetadata": null,
"designatorId": null,
"designatorIdGuid": null,
"documentVisibility": null,
"email": "rizauddin446#gmail.com",
"emailMetadata": null,
"emailNotification": null,
"embeddedRecipientStartURL": null,
"errorDetails": null,
"excludedDocuments": null,
"faxNumber": null,
"faxNumberMetadata": null,
"firstName": "",
"firstNameMetadata": null,
"fullName": null,
"fullNameMetadata": null,
"idCheckConfigurationName": null,
"idCheckConfigurationNameMetadata": null,
"idCheckInformationInput": null,
"identityVerification": null,
"inheritEmailNotificationConfiguration": null,
"isBulkRecipient": null,
"isBulkRecipientMetadata": null,
"lastName": "",
"lastNameMetadata": null,
"lockedRecipientPhoneAuthEditable": null,
"lockedRecipientSmsEditable": null,
"name": "rizauddin mohammad",
"nameMetadata": null,
"notaryId": null,
"note": null,
"noteMetadata": null,
"offlineAttributes": null,
"phoneAuthentication": null,
"phoneNumber": null,
"proofFile": null,
"recipientAttachments": null,
"recipientAuthenticationStatus": null,
"recipientFeatureMetadata": null,
"recipientId": "1",
"recipientIdGuid": "xdcd3-4fxxxxc2-aec2-ef83d86cadaa",
"recipientSignatureProviders": null,
"recipientSuppliesTabs": null,
"recipientType": "signer",
"recipientTypeMetadata": null,
"requireIdLookup": "false",
"requireIdLookupMetadata": null,
"requireSignerCertificate": null,
"requireSignOnPaper": null,
"requireUploadSignature": "false",
"roleName": null,
"routingOrder": "1",
"routingOrderMetadata": null,
"sentDateTime": null,
"signatureInfo": null,
"signedDateTime": null,
"signInEachLocation": null,
"signInEachLocationMetadata": null,
"signingGroupId": null,
"signingGroupIdMetadata": null,
"signingGroupName": null,
"signingGroupUsers": null,
"smsAuthentication": null,
"socialAuthentications": null,
"status": "sent",
"statusCode": null,
"suppressEmails": null,
"tabs": null,
"templateLocked": null,
"templateRequired": null,
"totalTabCount": null,
"userId": "xxxxx-4e74-aab8-bd1f98e63fb6"
}
],
"witnesses": []
},
}
]
I have to get the same result as I get from Postman. Is there any options I need to add or remove in coding?

In C# and Java the DocuSign SDKs not yet using dynamic typing and modern techniques to build objects. The objects have to (from the nature of classic OOP design for both C# and Java) have all the various properties that can be returned, or else you will need a different object for each combination of returned data.
I have to get the same result as I get from Postman. Is there any
options I need to add or remove in coding?
Well, you are getting the same results in the JSON that the SDK sends behind the scenes, but the object has additional null properties. I'm not clear why this is an issue for you. Simple null checks can be used to determine which of these have a value. You can even build your own type of dynamic objects by creating them on the fly and eliminating nulls if you really need this.

Related

How to get Product and Quantity information from payment_intent.succeeded event via Webhooks in Stripe?

Here is how I'm initializing the Checkout Process in Node.js.
let email = req.body.email
let product_id = req.body.product_id
let YOUR_DOMAIN = 'http://localhost:8000'
const session = await stripe.checkout.sessions.create({
line_items: [{
price: product_id,
adjustable_quantity: {
enabled: true,
minimum: 1,
maximum: 5,
},
quantity: 1,
}],
customer_email: email,
mode: 'payment',
success_url: `${YOUR_DOMAIN}/payment-success`,
cancel_url: `${YOUR_DOMAIN}/payment-failure`,
});
Here are the events I have subscribed to in Webhooks
payment_intent.succeeded
checkout.session.completed
Object Received in Payment Intent Succeeded
{
"id": "evt_1KEqIxI5cib7rtVMoKMkak96",
"object": "event",
"api_version": "2020-03-02",
"created": 1641453754,
"data": {
"object": {
"id": "pi_1KEqIeI5cib7rtVMcz8zsXys",
"object": "payment_intent",
"amount": 59700,
"amount_capturable": 0,
"amount_received": 59700,
"application": null,
"application_fee_amount": null,
"automatic_payment_methods": null,
"canceled_at": null,
"cancellation_reason": null,
"capture_method": "automatic",
"charges": {
"object": "list",
"data": [{
"id": "ch_1KEqIvI5cib7rtVMYUVn5gfQ",
"object": "charge",
"amount": 59700,
"amount_captured": 59700,
"amount_refunded": 0,
"application": null,
"application_fee": null,
"application_fee_amount": null,
"balance_transaction": "txn_1KEqIwI5cib7rtVMGfJlEahg",
"billing_details": {
"address": {
"city": "NY",
"country": "US",
"line1": "sada",
"line2": "asd",
"postal_code": "10001",
"state": "NY"
},
"email": "test#gmail.com",
"name": "John Doe",
"phone": null
},
"calculated_statement_descriptor": "VIDEOFORM",
"captured": true,
"created": 1641453753,
"currency": "usd",
"customer": "cus_KufeYc1hifvZGA",
"description": null,
"destination": null,
"dispute": null,
"disputed": false,
"failure_code": null,
"failure_message": null,
"fraud_details": {},
"invoice": null,
"livemode": false,
"metadata": {},
"on_behalf_of": null,
"order": null,
"outcome": {
"network_status": "approved_by_network",
"reason": null,
"risk_level": "normal",
"risk_score": 25,
"seller_message": "Payment complete.",
"type": "authorized"
},
"paid": true,
"payment_intent": "pi_1KEqIeI5cib7rtVMcz8zsXys",
"payment_method": "pm_1KEqIuI5cib7rtVMYPWlLV8S",
"payment_method_details": {
"card": {
"brand": "visa",
"checks": {
"address_line1_check": "pass",
"address_postal_code_check": "pass",
"cvc_check": "pass"
},
"country": "US",
"exp_month": 1,
"exp_year": 2023,
"fingerprint": "QaiTi5PATFO8ZoC3",
"funding": "credit",
"installments": null,
"last4": "4242",
"mandate": null,
"network": "visa",
"three_d_secure": null,
"wallet": null
},
"type": "card"
},
"receipt_email": null,
"receipt_number": null,
"receipt_url": "https://pay.stripe.com/receipts/acct_1GhUSuI5cib7rtVM/ch_1KEqIvI5cib7rtVMYUVn5gfQ/rcpt_KufeysPW3LD8Yu47q14iYOIIlcGth9h",
"refunded": false,
"refunds": {
"object": "list",
"data": [],
"has_more": false,
"total_count": 0,
"url": "/v1/charges/ch_1KEqIvI5cib7rtVMYUVn5gfQ/refunds"
},
"review": null,
"shipping": null,
"source": null,
"source_transfer": null,
"statement_descriptor": null,
"statement_descriptor_suffix": null,
"status": "succeeded",
"transfer_data": null,
"transfer_group": null
}],
"has_more": false,
"total_count": 1,
"url": "/v1/charges?payment_intent=pi_1KEqIeI5cib7rtVMcz8zsXys"
},
"client_secret": "pi_1KEqIeI5cib7rtVMcz8zsXys_secret_uZwm3uziwfaWePgTHENYXeraD",
"confirmation_method": "automatic",
"created": 1641453736,
"currency": "usd",
"customer": "cus_KufeYc1hifvZGA",
"description": null,
"invoice": null,
"last_payment_error": null,
"livemode": false,
"metadata": {},
"next_action": null,
"on_behalf_of": null,
"payment_method": "pm_1KEqIuI5cib7rtVMYPWlLV8S",
"payment_method_options": {
"card": {
"installments": null,
"mandate_options": null,
"network": null,
"request_three_d_secure": "automatic"
}
},
"payment_method_types": ["card"],
"processing": null,
"receipt_email": null,
"review": null,
"setup_future_usage": null,
"shipping": null,
"source": null,
"statement_descriptor": null,
"statement_descriptor_suffix": null,
"status": "succeeded",
"transfer_data": null,
"transfer_group": null
}
},
"livemode": false,
"pending_webhooks": 3,
"request": {
"id": "req_Y87umQuitz9WCc",
"idempotency_key": "a4b6af76-73d8-49b4-8393-9017e673af7e"
},
"type": "payment_intent.succeeded"
}
Object Received in Checkout Session Completed
{
"id": "evt_1KEqQOI5cib7rtVMRwAHWDvV",
"object": "event",
"api_version": "2020-03-02",
"created": 1641454214,
"data": {
"object": {
"id": "cs_test_a1AQ9EKIaxi8dXFAJzZ86xYm5meRkWb9Vu0eLowfkiKgUO4cyToooBzSTd",
"object": "checkout.session",
"after_expiration": null,
"allow_promotion_codes": null,
"amount_subtotal": 59700,
"amount_total": 59700,
"automatic_tax": {
"enabled": false,
"status": null
},
"billing_address_collection": null,
"cancel_url": "http://localhost:8000/payment-failure",
"client_reference_id": null,
"consent": null,
"consent_collection": null,
"currency": "usd",
"customer": "cus_Kuflo6N0n4HTzL",
"customer_details": {
"email": "test#gmail.com",
"phone": null,
"tax_exempt": "none",
"tax_ids": []
},
"customer_email": "test#gmail.com",
"expires_at": 1641540596,
"livemode": false,
"locale": null,
"mode": "payment",
"payment_intent": "pi_1KEqQ4I5cib7rtVMyND6NhQG",
"payment_method_options": {},
"payment_method_types": ["card"],
"payment_status": "paid",
"phone_number_collection": {
"enabled": false
},
"recovered_from": null,
"setup_intent": null,
"shipping": null,
"shipping_address_collection": null,
"shipping_options": [],
"shipping_rate": null,
"status": "complete",
"submit_type": null,
"subscription": null,
"success_url": "http://localhost:8000/payment-success",
"total_details": {
"amount_discount": 0,
"amount_shipping": 0,
"amount_tax": 0
},
"url": null
}
},
"livemode": false,
"pending_webhooks": 4,
"request": {
"id": null,
"idempotency_key": null
},
"type": "checkout.session.completed"
}
I'm unable to figure out how to get the Product ID and the Quantity. Could anyone suggest the right approach here?
You can find the Product and the quantity from the Checkout Session by using expand on the line_items property. The code should look like this.
// In "checkout.session.completed" event handler, get the ID of the Checkout Session
const id = event.data.object.id; // "cs_xxx"
// Retrieve the Checkout Session with expand
const session = await stripe.checkout.sessions.retrieve(id, {
expand: [ "line_items" ]
});
// Get the quantity
console.log(session.line_items.data[0].quantity);
// Get the product ID
console.log(session.line_items.data[0].price.product);

Stripe events: How to capture the product that was successfully paid with Stripe events and a webhook?

My website's users will buy credits using Stripe's single-payment workflow with a checkout session. They can buy single credits or credit packages, like 10 credits package at discount price.
After a successfully payment I want to capture the event with a webhook and update the user balance according to the product and quantity paid by the user.
I'm currently tracking payment_intent.succeeded events and I can see payment and charge information however I can't find any information related to the product ordered. What am I missing? Thank you.
This is an example of the payment intent event I'm capturing:
{
"amount": 5250,
"amount_capturable": 0,
"amount_received": 5250,
"application": null,
"application_fee_amount": null,
"canceled_at": null,
"cancellation_reason": null,
"capture_method": "automatic",
"charges": {
"data": [
{
"amount": 5250,
"amount_captured": 5250,
"amount_refunded": 0,
"application": null,
"application_fee": null,
"application_fee_amount": null,
"balance_transaction": "txn_1HUSonCfZ37XLQD8mLERR2YR",
"billing_details": {
"address": {
"city": null,
"country": "JP",
"line1": null,
"line2": null,
"postal_code": null,
"state": null
},
"email": "xxxx.xxxx.xxxx#gmail.com",
"name": "asd",
"phone": null
},
"calculated_statement_descriptor": "XXX XXXX",
"captured": true,
"created": 1600847712,
"currency": "jpy",
"customer": "cus_I4c27DIUQuvAHQ",
"description": null,
"destination": null,
"dispute": null,
"disputed": false,
"failure_code": null,
"failure_message": null,
"fraud_details": {},
"id": "ch_1HUSomCfZ37XLQD8d133buOK",
"invoice": null,
"livemode": false,
"metadata": {},
"object": "charge",
"on_behalf_of": null,
"order": null,
"outcome": {
"network_status": "approved_by_network",
"reason": null,
"risk_level": "normal",
"risk_score": 39,
"seller_message": "Payment complete.",
"type": "authorized"
},
"paid": true,
"payment_intent": "pi_1HUSoWCfZ37XLQD82vnE1yQT",
"payment_method": "pm_1HUSolCfZ37XLQD8gSn0oy4x",
"payment_method_details": {
"card": {
"brand": "visa",
"checks": {
"address_line1_check": null,
"address_postal_code_check": null,
"cvc_check": "pass"
},
"country": "US",
"exp_month": 11,
"exp_year": 2050,
"fingerprint": "uaJa23vzDgA7fnSC",
"funding": "credit",
"installments": null,
"last4": "4242",
"network": "visa",
"three_d_secure": null,
"wallet": null
},
"type": "card"
},
"receipt_email": null,
"receipt_number": null,
"receipt_url": "https://pay.stripe.com/receipts/acct_1HU77uCfZ37XLQD8/ch_1HUSomCfZ37XLQD8d133buOK/rcpt_I4c233eGeSYOaN9cPvncC4AcU2Sm4s7",
"refunded": false,
"refunds": {},
"review": null,
"shipping": null,
"source": null,
"source_transfer": null,
"statement_descriptor": null,
"statement_descriptor_suffix": null,
"status": "succeeded",
"transfer_data": null,
"transfer_group": null
}
],
"has_more": false,
"object": "list",
"total_count": 1,
"url": "/v1/charges?payment_intent=pi_1HUSoWCfZ37XLQD82vnE1yQT"
},
"client_secret": "pi_1HUSoWCfZ37XLQD82vnE1yQT_secret_XXX",
"confirmation_method": "automatic",
"created": 1600847696,
"currency": "jpy",
"customer": "cus_I4c27DIUQuvAHQ",
"description": null,
"id": "pi_1HUSoWCfZ37XLQD82vnE1yQT",
"invoice": null,
"last_payment_error": null,
"livemode": false,
"metadata": {},
"next_action": null,
"object": "payment_intent",
"on_behalf_of": null,
"payment_method": "pm_1HUSolCfZ37XLQD8gSn0oy4x",
"payment_method_options": {
"card": {
"installments": null,
"network": null,
"request_three_d_secure": "automatic"
}
},
"payment_method_types": [
"card"
],
"receipt_email": null,
"review": null,
"setup_future_usage": null,
"shipping": null,
"source": null,
"statement_descriptor": null,
"statement_descriptor_suffix": null,
"status": "succeeded",
"transfer_data": null,
"transfer_group": null
}
Assuming you've put the product details in the line_items of the Checkout session you created (see guide step), then what you're looking for is how to "fulfill the order" (see guide step), which you can do by listening to checkout.session.completed events.
When you receive an event, the event data will be a Checkout session by id, and you can then retrieve that session and specify expand\[\]=line_items to be able to inspect the line_items for the session.
Update: I modified the above to reflect that line_items is not included by default. You must retrieve the session and include it in an expand.

How to update a subscription (adding a pricing plan) by Stripe in Node.js?

I'm building a web app which sells several products, each product corresponds to a pricing plan. All the payment system is managed by Stripe.
It happens very often that a user has a subscription that contains Product A (i.e., one pricing plan), and then he wants to add Product B (i.e., another pricing plan) to the same subscription. I want to know how to achieve this by APIs of Stripe.
There is a webpage of Stripe to update a subscription (e.g., https://dashboard.stripe.com/test/subscriptions/sub_H4pQGW8nnc80vF/edit where sub_H4pQGW8nnc80vF is the subscription ID). Let's assume this customer already has 1 Verificator in the subscription, and then he wants to add 1 Pretty Formula to the same subscription. I do this update via the website. Here is the log:
Here is the full Request POST body:
{
"items": {
"0": {
"billing_thresholds": "",
"deleted": "false",
"id": "si_H4pQal4ZxGzLbW",
"quantity": "1",
"tax_rates": ""
},
"1": {
"billing_thresholds": "",
"plan": "plan_Gz6i9yPVIjrDPX",
"deleted": "false",
"quantity": "1"
}
},
"off_session": "true",
"prorate": "true",
"cancel_at": "",
"days_until_due": "30",
"default_tax_rates": "",
"collection_method": "send_invoice",
"billing_thresholds": "",
"enable_incomplete_payments": "false",
"invoice_settings": {
"description": "",
"send_hosted_payment_email": "true",
"supported_payment_methods": {
"ach_credit_transfer": "false",
"au_becs_debit": "false",
"bancontact": "false",
"card": "true",
"fpx": "false",
"giropay": "false",
"ideal": "false",
"jp_credit_transfer": "false",
"paper_check": "false",
"sepa_credit_transfer": "false",
"sofort": "false"
},
"custom_fields": "",
"footer": ""
},
"default_payment_method": "",
"default_source": ""
}
Here is the full Response body:
{
"id": "sub_H4pQGW8nnc80vF",
"object": "subscription",
"application_fee_percent": null,
"billing_cycle_anchor": 1586597833,
"billing_thresholds": null,
"cancel_at": null,
"cancel_at_period_end": false,
"canceled_at": null,
"collection_method": "send_invoice",
"created": 1586597833,
"current_period_end": 1589189833,
"current_period_start": 1586597833,
"customer": "5e575130651c5721d808d25b",
"customer_email": "sdtikply#gmail.com",
"customer_name": "Thomas Joseph",
"days_until_due": 30,
"default_payment_method": null,
"default_source": null,
"default_tax_rates": [
],
"discount": null,
"ended_at": null,
"invoice_settings": {
"send_hosted_payment_email": true,
"supported_payment_methods": {
"ach_credit_transfer": false,
"au_becs_debit": false,
"bancontact": false,
"card": true,
"fpx": false,
"giropay": false,
"ideal": false,
"jp_credit_transfer": false,
"paper_check": false,
"sepa_credit_transfer": false,
"sofort": false
}
},
"items": {
"object": "list",
"data": [
{
"id": "si_H4pQal4ZxGzLbW",
"object": "subscription_item",
"billing_thresholds": null,
"created": 1586597833,
"metadata": {
},
"plan": {
"id": "plan_Ga6n9yMYCDnHCu",
"object": "plan",
"active": true,
"aggregate_usage": null,
"amount": 500,
"amount_decimal": "500",
"billing_scheme": "per_unit",
"created": 1579512574,
"currency": "usd",
"interval": "month",
"interval_count": 1,
"livemode": false,
"metadata": {
},
"name": "Verificator",
"nickname": "Verificator",
"owning_merchant": "acct_1CiOQBEV4K2GahYL",
"owning_merchant_info": "acct_1CiOQBEV4K2GahYL",
"product": "prod_Ga6mVdA8KXyZ8I",
"tiers": null,
"tiers_mode": null,
"transform_usage": null,
"trial_period_days": null,
"usage_type": "licensed"
},
"quantity": 1,
"subscription": "sub_H4pQGW8nnc80vF",
"tax_rates": [
]
},
{
"id": "si_H82ES9BdIKZCNG",
"object": "subscription_item",
"billing_thresholds": null,
"created": 1587337381,
"metadata": {
},
"plan": {
"id": "plan_Gz6i9yPVIjrDPX",
"object": "plan",
"active": true,
"aggregate_usage": null,
"amount": 500,
"amount_decimal": "500",
"billing_scheme": "per_unit",
"created": 1585278262,
"currency": "usd",
"interval": "month",
"interval_count": 1,
"livemode": false,
"metadata": {
},
"name": "Pretty Formula",
"nickname": "Pretty Formula",
"owning_merchant": "acct_1CiOQBEV4K2GahYL",
"owning_merchant_info": "acct_1CiOQBEV4K2GahYL",
"product": "prod_GxqkRFdI08DvyR",
"tiers": null,
"tiers_mode": null,
"transform_usage": null,
"trial_period_days": null,
"usage_type": "licensed"
},
"quantity": 1,
"subscription": "sub_H4pQGW8nnc80vF",
"tax_rates": [
]
}
],
"has_more": false,
"total_count": 2,
"url": "/v1/subscription_items?subscription=sub_H4pQGW8nnc80vF"
},
"latest_invoice": "in_1GWfm1EV4K2GahYLlmtUEISo",
"livemode": false,
"metadata": {
},
"next_pending_invoice_item_invoice": null,
"owning_merchant": "acct_1CiOQBEV4K2GahYL",
"owning_merchant_info": "acct_1CiOQBEV4K2GahYL",
"pause_collection": null,
"pending_invoice_item_interval": null,
"pending_setup_intent": null,
"pending_update": null,
"plan": null,
"quantity": null,
"schedule": null,
"start_date": 1586597833,
"status": "active",
"tax_percent": null,
"trial_end": null,
"trial_start": null
}
So my question is, how can I code in my backend (Node.js) to achieve exactly the same thing?
You just need to use the Update Subscription API and provide the items portion just as you're seeing above:
"items": {
"0": {
"billing_thresholds": "",
"deleted": "false",
"id": "si_H4pQal4ZxGzLbW",
"quantity": "1",
"tax_rates": ""
},
"1": {
"billing_thresholds": "",
"plan": "plan_Gz6i9yPVIjrDPX",
"deleted": "false",
"quantity": "1"
}
},
The first item is the existing Subscription Item (si_), and the second one is the new one you want to add.

Not Able to add TextTab

Hi I am able to send envelope by adding signhere tab but when i am trying to add TextTabs it is giving below error(I am using rest API's)
INVALID_REQUEST_BODY The request body is missing or improperly formatted. Null object cannot be converted to a value type.
Below is my request JSON of envelope definition
{
"documents": [{
"documentId": "1136641236",
"uri": null,
"remoteUrl": null,
"name": "ABC Merchant Agreement",
"password": null,
"transformPdfFields": null,
"fileExtension": null,
"matchBoxes": null,
"order": null,
"pages": null,
"documentFields": null,
"encryptedWithKeyManager": null,
"documentBase64": "documentBase64",
"applyAnchorTabs": null
}
],
"recipients": {
"signers": [{
"signatureInfo": null,
"defaultRecipient": null,
"tabs": {
"signHereTabs": [{
"name": null,
"tabLabel": null,
"scaleValue": null,
"optional": null,
"documentId": "1136641236",
"recipientId": "2044556663",
"pageNumber": "1",
"xPosition": null,
"yPosition": null,
"anchorString": "SIGNATUREOWNER1",
"anchorXOffset": null,
"anchorYOffset": null,
"anchorUnits": null,
"anchorIgnoreIfNotPresent": null,
"anchorCaseSensitive": "True",
"anchorMatchWholeWord": "True",
"anchorHorizontalAlignment": null,
"tabId": null,
"templateLocked": null,
"templateRequired": null,
"conditionalParentLabel": null,
"conditionalParentValue": null,
"customTabId": null,
"mergeField": null,
"status": null,
"errorDetails": null
}
],
"initialHereTabs": null,
"signerAttachmentTabs": null,
"approveTabs": null,
"declineTabs": null,
"fullNameTabs": null,
"dateSignedTabs": null,
"envelopeIdTabs": null,
"companyTabs": null,
"titleTabs": null,
"textTabs": [{
"height": null,
"isPaymentAmount": null,
"formula": null,
"validationPattern": null,
"validationMessage": null,
"shared": null,
"requireInitialOnSharedChange": null,
"senderRequired": null,
"requireAll": null,
"name": "TextTab",
"value": null,
"originalValue": null,
"width": null,
"required": "true",
"locked": "false",
"concealValueOnDocument": null,
"disableAutoSize": null,
"maxLength": null,
"tabLabel": "gjk",
"font": null,
"bold": null,
"italic": null,
"underline": null,
"fontColor": null,
"fontSize": "Size12",
"documentId": "1136641236",
"recipientId": "2044556663",
"pageNumber": "1",
"xPosition": null,
"yPosition": null,
"anchorString": "TEXTTABPLACEHOLDER",
"anchorXOffset": null,
"anchorYOffset": null,
"anchorUnits": null,
"anchorIgnoreIfNotPresent": null,
"anchorCaseSensitive": "True",
"anchorMatchWholeWord": "True",
"anchorHorizontalAlignment": null,
"tabId": null,
"templateLocked": null,
"templateRequired": null,
"conditionalParentLabel": null,
"conditionalParentValue": null,
"customTabId": null,
"mergeField": null,
"status": null,
"errorDetails": null
}
],
"numberTabs": null,
"ssnTabs": null,
"dateTabs": null,
"zipTabs": null,
"emailTabs": null,
"noteTabs": null,
"checkboxTabs": null,
"radioGroupTabs": null,
"listTabs": null,
"firstNameTabs": null,
"lastNameTabs": null,
"emailAddressTabs": null,
"formulaTabs": null
},
"signInEachLocation": null,
"offlineAttributes": null,
"requireSignerCertificate": null,
"requireSignOnPaper": null,
"canSignOffline": null,
"isBulkRecipient": null,
"bulkRecipientsUri": null,
"recipientSuppliesTabs": null,
"excludedDocuments": null,
"name": "name",
"email": "emailid",
"emailRecipientPostSigningURL": null,
"signingGroupId": null,
"signingGroupName": null,
"signingGroupUsers": null,
"recipientId": "2044556663",
"recipientIdGuid": null,
"accessCode": null,
"addAccessCodeToEmail": null,
"requireIdLookup": null,
"idCheckConfigurationName": null,
"socialAuthentications": null,
"phoneAuthentication": null,
"samlAuthentication": null,
"smsAuthentication": null,
"userId": null,
"clientUserId": null,
"embeddedRecipientStartURL": null,
"customFields": null,
"routingOrder": "1",
"idCheckInformationInput": null,
"recipientAttachments": null,
"note": null,
"roleName": null,
"status": null,
"signedDateTime": null,
"deliveredDateTime": null,
"declinedDateTime": null,
"sentDateTime": null,
"declinedReason": null,
"deliveryMethod": null,
"faxNumber": null,
"templateLocked": null,
"templateRequired": null,
"emailNotification": null,
"inheritEmailNotificationConfiguration": null,
"errorDetails": null,
"recipientAuthenticationStatus": null,
"totalTabCount": null
}
],
"agents": null,
"editors": null,
"intermediaries": null,
"carbonCopies": null,
"certifiedDeliveries": null,
"inPersonSigners": null,
"recipientCount": null,
"currentRoutingOrder": null,
"errorDetails": null
},
"customFields": {
"textCustomFields": [{
"fieldId": "788788",
"name": "AppNumber",
"show": "false",
"required": "false",
"value": "788788",
"configurationType": null,
"errorDetails": null
}
],
"listCustomFields": null
},
"eventNotification": null,
"brandId": "BrandId",
"allowRecipientRecursion": null,
"templateId": null,
"templateRoles": null,
"compositeTemplates": null,
"accessibility": null,
"transactionId": null,
"status": "sent",
"documentsUri": null,
"recipientsUri": null,
"asynchronous": null,
"envelopeUri": null,
"emailSubject": "ABC Agreement",
"emailBlurb": "Please Sign",
"envelopeId": null,
"signingLocation": null,
"customFieldsUri": null,
"envelopeIdStamping": null,
"authoritativeCopy": null,
"notification": {
"useAccountDefaults": null,
"reminders": {
"reminderEnabled": "true",
"reminderDelay": "1",
"reminderFrequency": "2"
},
"expirations": {
"expireEnabled": "true",
"expireAfter": "2",
"expireWarn": "1"
}
},
"notificationUri": null,
"enforceSignerVisibility": null,
"enableWetSign": null,
"allowMarkup": null,
"allowReassign": null,
"createdDateTime": null,
"lastModifiedDateTime": null,
"deliveredDateTime": null,
"sentDateTime": null,
"completedDateTime": null,
"voidedDateTime": null,
"voidedReason": null,
"deletedDateTime": null,
"declinedDateTime": null,
"statusChangedDateTime": null,
"documentsCombinedUri": null,
"certificateUri": null,
"templatesUri": null,
"messageLock": null,
"recipientsLock": null,
"useDisclosure": null,
"emailSettings": null,
"purgeState": null,
"lockInformation": null,
"is21CFRPart11": null
}
The error message says it all
Null object cannot be converted to a value type.
Remove the properties which have null value assigned to them. The following JSON should work.
{
"documents": [
{
"documentId": "1136641236",
"name": "ABC Merchant Agreement",
"documentBase64": "documentBase64"
}
],
"recipients": {
"signers": [
{
"tabs": {
"signHereTabs": [
{
"documentId": "1136641236",
"pageNumber": "1",
"anchorString": "SIGNATUREOWNER1",
"anchorCaseSensitive": "True",
"anchorMatchWholeWord": "True"
}
],
"textTabs": [
{
"name": "TextTab",
"required": "true",
"locked": "false",
"tabLabel": "gjk",
"fontSize": "Size12",
"documentId": "1136641236",
"pageNumber": "1",
"anchorString": "TEXTTABPLACEHOLDER",
"anchorCaseSensitive": "True",
"anchorMatchWholeWord": "True"
}
]
},
"name": "name",
"email": "emailid",
"recipientId": "2044556663",
"routingOrder": "1"
}
]
},
"customFields": {
"textCustomFields": [
{
"fieldId": "788788",
"name": "AppNumber",
"show": "false",
"required": "false",
"value": "788788"
}
]
},
"brandId": "BrandId",
"status": "sent",
"emailSubject": "ABC Agreement",
"emailBlurb": "Please Sign",
"notification": {
"reminders": {
"reminderEnabled": "true",
"reminderDelay": "1",
"reminderFrequency": "2"
},
"expirations": {
"expireEnabled": "true",
"expireAfter": "2",
"expireWarn": "1"
}
}
}

How to remove null objects of whois results

I use the python-whois module.
I have this code:
for whoisInfo in domainWhoisInfo :
stringWhoisInfo = str(stringWhoisInfo) + str(whoisInfo) + "\n\n"
domainWhoisInfo => array which contains whois data of each domain
stringWhoisInfo => string which concatenate whois data of all domains
I concatenate whois results of many domain name in a string.
And When I store these results in a log file I get the
following output :
{
"updated_date": null,
"status": null,
"name": null,
"dnssec": null,
"city": null,
"expiration_date": null,
"zipcode": null,
"domain_name": null,
"country": null,
"whois_server": null,
"state": null,
"registrar": null,
"referral_url": null,
"address": null,
"name_servers": null,
"org": null,
"creation_date": null,
"emails": null
}
{
"updated_date": null,
"status": [
"clientDeleteProhibited -- http://www.icann.org/epp#clientDeleteProhibited",
"clientTransferProhibited -- http://www.icann.org/epp#clientTransferProhibited",
"serverTransferProhibited -- http://www.icann.org/epp#serverTransferProhibited"
],
"name": "Panayiotis Yianni",
"dnssec": null,
"city": "Enfield",
"expiration_date": "2017-03-06 23:25:46",
"zipcode": "EN3 7FY",
"domain_name": "AMON.PRO",
"country": "GB",
"whois_server": null,
"state": "London, City of",
"registrar": "OVH (R2367-PRO)",
"referral_url": null,
"address": null,
"name_servers": [
"DNS200.ANYCAST.ME",
"NS200.ANYCAST.ME"
],
"org": "Amon Interactive Ltd",
"creation_date": null,
"emails": [
"panayiotisyianni#live.com",
"panayiotis#amon.pro"
]
}
{
"updated_date": null,
"status": null,
"name": null,
"dnssec": null,
"city": null,
"expiration_date": null,
"zipcode": null,
"domain_name": null,
"country": null,
"whois_server": null,
"state": null,
"registrar": null,
"referral_url": null,
"address": null,
"name_servers": null,
"org": null,
"creation_date": null,
"emails": null
}
I am looking for deleting the whois results which are null
from my string.
And get finally only this output :
{
"updated_date": null,
"status": [
"clientDeleteProhibited -- http://www.icann.org/epp#clientDeleteProhibited",
"clientTransferProhibited -- http://www.icann.org/epp#clientTransferProhibited",
"serverTransferProhibited -- http://www.icann.org/epp#serverTransferProhibited"
],
"name": "Panayiotis Yianni",
"dnssec": null,
"city": "Enfield",
"expiration_date": "2017-03-06 23:25:46",
"zipcode": "EN3 7FY",
"domain_name": "AMON.PRO",
"country": "GB",
"whois_server": null,
"state": "London, City of",
"registrar": "OVH (R2367-PRO)",
"referral_url": null,
"address": null,
"name_servers": [
"DNS200.ANYCAST.ME",
"NS200.ANYCAST.ME"
],
"org": "Amon Interactive Ltd",
"creation_date": null,
"emails": [
"panayiotisyianni#live.com",
"panayiotis#amon.pro"
]
}

Resources