Update Sales Force DB with Docusign Envelope ID using Docusign API - docusignapi

Team,
I'm using the demo version of docusign API in my web application (test),
I have updated the connect functionality to connect to the salesforce in the demo account that i have. I need to understand how can I update the envelope status to sales force for the opportunity Im writing the contract for.
Steps
1 The user logs into our website
2 Clicks the DocuSign link (i call the demo API to show the docusign website in an IFrame)
3 The user is an Opportunity in salesforce
3 Depending upon the User response I show a final message page.
need to do.
Apart form the mails i receive, I want to update the docusign section for that user(oppurtinuity) in sales force. Our salesforce database is connected to the docusign.
Please do let me know if you need any other details. Appreciate your help.

Just add the following code:
envelopeInfo.CustomFields = new CustomField[] {
new CustomField {
Name = "##SFAccount",
Value = account.Id,
Show="",
Required=""
},
new CustomField {
Name = "##SFContract",
Value = contact.Id,
Show="",
Required=""
},
new CustomField {
Name = "##SFOpportunity",
Value = opportunity.Id,
Show="",Required=""
}
};

Related

DocuSign how to customize name and company for each envelope without create users?

Is that possible to customize name and company name for each envelope without create all users? or even just hide it?
If this is not possible, what is the recommendations for the following scenario?
We have 5,000 users, they are from different companies(different email domain)
User purchase points on our system, and they use points to buy eSign envelope
We don't want to create 5,000 users under our DocuSign account (not only adding them, we also don't want them to have account to login to DocuSign and create envelope without pay us.
We like to show their name and company in highlight area below
We are OK the email send to the singer is from DocuSign
What you show is the name and company of the sender, the account holder, the person who initiated the request to sign. Not the signer, the person who needs to act on it. Hope this is clear.
You can change the name and company name of the sender/company account programmatically, and then send the next envelope.
However, if you want to do something like this, you won't be able to use bulk send, because it doesn't allow you to make the change between each envelope.
You can run a loop that does this:
Change name/company
Create envelope
Send envelope
Doing this 5000 times also has an issue with API limit (default to 3000/hour) so you will either have to throttle this or contact support to increase your limit
Changing the name of the account holder can be done like this:
Here is C# code for this:
var apiClient = new ApiClient(basePath);
// You will need to obtain an access token using your chosen authentication method
apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + accessToken);
UsersApi usersApi = new UsersApi(apiClient);
UserProfile userProfile = new UserProfile();
userProfile.UserDetails = new UserInformation();
userProfile.UserDetails.FirstName = "Inbar";
userProfile.UserDetails.LastName = "Gazit";
usersApi.UpdateProfile(accountId, userId, userProfile);
You can find all other langs and more details here - https://www.docusign.com/blog/developers/common-api-tasks-update-the-name-docusign-user

handling stripe webhook in multiple stripe account laravel

I've multiple stripe account on my site, and each stripe account is associated with a webhook.
My webhook is returning 403 Error "No signatures found matching the expected signature for payload"
i've checked the Cashier middleware and its getting the webhook secret key from the env file.
Since this project attached to multiple stripe account, we can't store the webhook secret in env file. so, we're placing the webhook secret key of each stripe account in a table.
I would like to get the secret key from database instead of this config file.
Is it possible to listen to multiple stripe account's webhook?
Any help will be appreciated.
I am not sure if this is a good approach but you can:
Send meta data in the checkout which gets posted to the web hook
Get the raw json posted by the web hook before you use the web hook key to validate that the post was from Stripe. Stripe.Net contains a parse method and a construct method. Parse does not require the key. Construct uses the key to validate the post was from Stripe.
So with Stripe.net:
string endpointSecret;
// get the json posted
var json = await new
StreamReader(HttpContext.Request.Body).ReadToEndAsync();
// convert the json into a stripe event object
var objStripeEvent = EventUtility.ParseEvent(json);
if (objStripeEvent.Type == Events.CheckoutSessionCompleted)
{
// get the session object and see if it contains the Meta data we passed
// in at checkout
var session = objStripeEvent.Data.Object as Session;
var met = session.Metadata;
if (met.ContainsKey("FranchiseGuid"))
{
// if the meta data contains the franchise guid get the correct
// wh secret from the DB
var FranchiseGuid= new Guid(met["FranchiseGuid"]);
endpointSecret = _repo.GetWebHookSecret(FranchiseGuid);
}
}
// Then you can go on to use the Construct method to validate the post with the correct key for the Stripe account where the web hook is based.
try
{
// check if was from Stripe
var stripeEvent = EventUtility.ConstructEvent(
json,
Request.Headers["Stripe-Signature"],
endpointSecret);
---- etc
I've requested help on this from Stripe support but they have promised to get back to me. I'll test out the above to see if it works. I don't think it's ideal though because if a hacker were able to get a valid franchise guid they could possibly fake posts and spam the endpoint. It would not be easy to guess a guid and these id's are not available in any way publicly. Plus https is used. But it still makes me nervous because the franchise guid would be one of a dozen or more. Not like a booking guid which is generated and sent once for the booking that is marked as paid. The franchise guid would be sent every time a payment was made for that franchise.
I think what I may do is use the booking guid since this is randomly generated for every booking. I can join to the franchise table from the booking and get the web hook secret.
We'll see if Stripe come back with something useful.

How to implement Paypal subscription in a vue application?

I am working on a project which needs to deducts a fixed amount from a user's account to a business account on monthly basis. I am trying to create a Paypal button client side (vue) for accepting subscriptions on monthly basis. The users deduction information on monthly basis shall be stored in a database. The user shall also provided an option to cancel the subscription. Any help would be greatly appreciated.
Well i found out an answer after a little digging in the documentation provided at https://developer.paypal.com/docs/subscriptions/integrate and went through the steps they provided.
Steps
Create a product through their API by providing access_token in the headers.
After the product has been created, get product-Id from response and then create plan using the product_id in request body.
After the plan has been successfully created copy Plan_id and replace the id in smart subscription button.
paypal.Buttons({
createSubscription: function(data, actions) {
return actions.subscription.create({
'plan_id': 'P-your_plan_id'
});
onApprove: function(data, actions) {
alert('You have successfully created subscription ' + data.subscriptionID);
}
}

Apex Toolkit How to Create Embedded Signing Session for Contact that Isn't Logged in

We are using the DocuSign Apex Toolkit. We have a scenario where a sales representative is logged into Salesforce and is working with an in-person contact to fill out an application. Once they fill out the required fields in the application we would like to create an embedded signing session for the contact to sign a document.
I am following the instructions for Embedded Signing using the toolkit. I see that we have to create an embedded signer using the following method dfsle.Recipient.newEmbeddedSigner(). We have found that when we start the signing session the first recipient is always the user that is logged in. Instead, we need the recipient to be the contact related to the application. Is there any way to start an embedded signing session for the contact?
See code example below. You can replace the myContact.Email and myContact.Name with whatever you need to achieve your objective.
public class ApexToolkitDemo {
public static void sendEnvelopeMethod() {
Id mySourceId; // The ID of the initiating Salesforce object.
// Create an empty envelope.
dfsle.Envelope myEnvelope = dfsle.EnvelopeService.getEmptyEnvelope(
new dfsle.Entity(mySourceId));
// The initiating Salesforce entity.
// Use myEnvelope for later
// Use a Salesforce contact record as a Recipient here
Contact myContact = [SELECT Id, Name, Email FROM Contact LIMIT 1];
// Use the Recipient.fromSource method to create the Recipient
dfsle.Recipient myRecipient = dfsle.Recipient.fromSource(
myContact.Name, // Recipient name
myContact.Email, // Recipient email
null, // Optional phone number
'Signer 1', // Role Name. Specify the exact role name from template
new dfsle.Entity(myContact.Id)); // Source object for the Recipient
// Add Recipient to the Envelope
myEnvelope = myEnvelope.withRecipients(new List<dfsle.Recipient> { myRecipient });

Access the DocuSign API in your Force.com / Salesforce.com account in order to send an object with a single click of a button

DocuSignAPI for Salesforce.
Hello everybody, I'm following this manual to access the DocuSign API in Force.com / Salesforce.com account in order to send an object with a single click of a button to be isgned.
http://developer.force.com/cookbook/recipe/accessing-docusign-api-from-salesforcecom-to-send-contracts-for-esignatures
the problems is when i get the next error:
"The DocuSign EnvelopeId:Exception - System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: The email address for the recipient is invalid. The recipient Id follows. faultcode=soap:Client faultactor=https://demo.docusign.net/api/3.0/dsapi.asmx"
Do anyone know the solution?
Thank you.
Re your specific error, I suggest that you download the API call logging information from DocuSign itself to see exactly what you sent to DocuSign via Salesforce.
In general for Salesforce/DocuSign integration, recommended first step is to use DocuSign for Salesforce, available from the Salesforce app store.
Additional developer information and source code is available from this blog post. It includes info on recipes (including source code) from DocuSign that document how to call the DocuSign API from Salesforce.
One issue to watch out for: you can't send PDFs from Salesforce to DocuSign due to callout limitations enforced by Salesforce.
Solutions:
you can make a call to a gateway (which you write). Your gateway would then pull the doc from Salesforce and then send it to DocuSign
Or use DocuSign for Salesforce which does the above for you.
thank you for your answer.
At the end the solution was that the email of the person that I wanted to send the document to sign didnt exist :P.
But now my problem is How can I update the Docusign status? becouse when I put this in an "execute anonymous windows" that creates me a Status:
dsfs__DocuSign_Status__c status = new dsfs__DocuSign_Status__c();
status.dsfs__Contract__c='0293900000xD';
status.dsfs__Envelope_Status__c='Sent';
upsert status;
but when i use this inside of a controller extension:
try {
DocuSignAPI.EnvelopeStatus es = dsApiSend.CreateAndSendEnvelope(envelope);
envelopeId = es.EnvelopeID;
// this.contract.DocuSign_Status__c=es.Status;
dsfs__DocuSign_Status__c status = new dsfs__DocuSign_Status__c();
status.dsfs__Contract__c=this.contract.Id;
status.dsfs__Envelope_Status__c=es.Status;
upsert status;
} catch ( CalloutException e) {
System.debug('Exception - ' + e );
envelopeId = 'Exception - ' + e;
}
Doesn't work, the Status is never created.
Thank you for your help.

Resources