Open mihir8400 opened 1 month ago
I understand you're looking to add a payment field within your document. With using PHP, we do have an article that does frame the steps in obtaining this field.
This guide provides a comprehensive overview of utilizing DocuSign Payments to facilitate payment collection through envelopes. It outlines the steps required to configure a payment gateway for processing payments from signers. Additionally, it details the procedure for collecting online credit card payments via an order form sent within an envelope. For testing purposes, you may use one of the test credit cards supplied by Stripe.
The article below shares code samples of how you can create the field. https://developers.docusign.com/docs/esign-rest-api/how-to/request-a-payment/
This is the code sample: $envelope_definition = CollectPaymentService::makeEnvelope($args["envelope_args"], $demoDocsPath); public static function makeEnvelope(array $args, $demoDocsPath): EnvelopeDefinition {
$l1_name = "Harmonica"; $l1_price = 5; $l1_description = "$l1_price each"; $l2_name = "Xylophone"; $l2_price = 150; $l2_description = "$l2_price each"; $currency_multiplier = 100;
$doc1_file = 'order_form.html'; $doc1_html_v1 = file_get_contents($demoDocsPath . $doc1_file);
$doc1_html_v2 = str_replace( ['{signer_email}' , '{cc_name}' , '{cc_email}' ], [$args['signer_email'], $args['cc_name'], $args['cc_email']], $doc1_html_v1 );
$envelope_definition = new EnvelopeDefinition([ 'email_subject' => 'Please complete your order', 'status' => 'sent']);
$doc1_b64 = base64_encode($doc1_html_v2); $doc1 = new Document([ 'document_base64' => $doc1_b64, 'name' => 'Order form', # can be different from actual file name 'file_extension' => 'html', # Source data format. 'document_id' => '1' # a label used to reference the doc ]); $envelope_definition->setDocuments([$doc1]);
$signer1 = new Signer([ 'email' => $args['signer_email'], 'name' => $args['signer_name'], 'recipient_id' => "1", 'routing_order' => "1"]);
$cc1 = new CarbonCopy([ 'email' => $args['cc_email'], 'name' => $args['cc_name'], 'recipient_id' => "2", 'routing_order' => "2"]);
$sign_here1 = new SignHere([ 'anchor_string' => '/sn1/', 'anchor_y_offset' => '10', 'anchor_units' => 'pixels', 'anchor_x_offset' => '20']);
$list1 = new ModelList([ 'font' => "helvetica", 'font_size' => "size11", 'anchor_string' => '/l1q/', 'anchor_y_offset' => '-10', 'anchor_units' => 'pixels', 'anchor_x_offset' => '0', 'list_items' => [ ['text' => "1" , 'value' => "1" ], ['text' => "2", 'value' => "2"], ['text' => "3", 'value' => "3"], ['text' => "4" , 'value' => "4" ], ['text' => "5" , 'value' => "5" ], ['text' => "6", 'value' => "6"] ], 'required' => "true", 'tab_label' => "l1q" ]);
$list2 = new ModelList([ 'font' => "helvetica", 'font_size' => "size11", 'anchor_string' => '/l2q/', 'anchor_y_offset' => '-10', 'anchor_units' => 'pixels', 'anchor_x_offset' => '0', 'list_items' => [ ['text' => "1" , 'value' => "1" ], ['text' => "2", 'value' => "2"], ['text' => "3", 'value' => "3"], ['text' => "4" , 'value' => "4" ], ['text' => "5" , 'value' => "5" ], ['text' => "6", 'value' => "6"] ], 'required' => "true", 'tab_label' => "l2q" ]);
$formulal1e = new FormulaTab([ 'font' => "helvetica", 'font_size' => "size11", 'anchor_string' => '/l1e/', 'anchor_y_offset' => '-8', 'anchor_units' => 'pixels', 'anchor_x_offset' => '105', 'tab_label' => "l1e", 'formula' => "[l1q] $l1_price", 'round_decimal_places' => "0", 'required' => "true", 'locked' => "true", 'disable_auto_size' => "false", ]); $formulal2e = new FormulaTab([ 'font' => "helvetica", 'font_size' => "size11", 'anchor_string' => '/l2e/', 'anchor_y_offset' => '-8', 'anchor_units' => 'pixels', 'anchor_x_offset' => '105', 'tab_label' => "l2e", 'formula' => "[l2q] $l2_price", 'round_decimal_places' => "0", 'required' => "true", 'locked' => "true", 'disable_auto_size' => "false", ]);
$formulal3t = new FormulaTab([ 'font' => "helvetica", 'bold' => "true", 'font_size' => "size12", 'anchor_string' => '/l3t/', 'anchor_y_offset' => '-8', 'anchor_units' => 'pixels', 'anchor_x_offset' => '50', 'tab_label' => "l3t", 'formula' => '[l1e] + [l2e]', 'round_decimal_places' => "0", 'required' => "true", 'locked' => "true", 'disable_auto_size' => "false", ]);
$payment_line_iteml1 = new PaymentLineItem([ 'name' => $l1_name, 'description' => $l1_description, 'amount_reference' => "l1e"]); $payment_line_iteml2 = new PaymentLineItem([ 'name' => $l2_name, 'description' => $l2_description, 'amount_reference' => "l2e"]); $payment_details = new PaymentDetails([ 'gateway_account_id' => $args['gateway_account_id'], 'currency_code' => "USD", 'gateway_name' => $args['gateway_name'], 'line_items' => [$payment_line_iteml1, $payment_line_iteml2]]);
$formula_payment = new FormulaTab([ 'tab_label' => "payment", 'formula' => "([l1e] + [l2e]) * $currency_multiplier", 'round_decimal_places' => "0", 'payment_details' => $payment_details, 'hidden' => "true", 'required' => "true", 'locked' => "true", 'document_id' => "1", 'page_number' => "1", 'x_position' => "0", 'y_position' => "0"]);
$signer1_tabs = new Tabs([ 'sign_here_tabs' => [$sign_here1], 'list_tabs' => [$list1, $list2], 'formula_tabs' => [$formulal1e, $formulal2e, $formulal3t, $formula_payment]]); $signer1->setTabs($signer1_tabs);
$recipients = new Recipients([ 'signers' => [$signer1], 'carbon_copies' => [$cc1]]); $envelope_definition->setRecipients($recipients);
return $envelope_definition; }
Best, DocuSign Support
Hello, How can we add a Payment Item Field in the document?
in the above Image, they provide payment item fields.
using below code
` $this->authenticate();
$signer = new Signer([ 'email' => $recipientEmail, 'name' => $recipientName, 'recipient_id' => '1', 'tabs' => $tabs, 'client_user_id' => $token ]);
`
I put the signed and name field in a document. now How can we add a Payment Item Field in the document like a text field and signed field? I want only to save the credit card details of the signer. stripe Payment method