@@ -3930,6 +3930,15 @@ paths:
39303930 type : string
39313931 description : |
39323932 Search. Text to search in the description of the receipt's items or the SKU.
3933+ - in : query
3934+ name : customer
3935+ schema :
3936+ type : string
3937+ minLength : 24
3938+ maxLength : 24
3939+ description : |
3940+ ID of the customer associated to the receipt.
3941+ example : " 58e93bd8e86eb318b0197456"
39333942 - in : query
39343943 name : payment_form
39353944 schema :
@@ -4035,6 +4044,133 @@ paths:
40354044 $ref : " #/components/responses/Unauthenticated"
40364045 " 500 " :
40374046 $ref : " #/components/responses/UnexpectedError"
4047+ put :
4048+ operationId : assignReceiptCustomer
4049+ tags :
4050+ - receipt
4051+ summary : Assign customer to receipt
4052+ description : |
4053+ Assign an existing customer (by ID) to a receipt, or create a new one by sending the customer object.
4054+
4055+ If the receipt has a registered transaction, the transaction's `counterparty` will also be updated.
4056+ x-codeSamples :
4057+ - lang : Bash
4058+ label : cURL
4059+ source : |
4060+ curl https://www.facturapi.io/v2/receipts/58e93bd8e86eb318b019743d \
4061+ -H "Authorization: Bearer sk_test_API_KEY" \
4062+ -H "Content-Type: application/json" \
4063+ -X PUT \
4064+ -d '{
4065+ "customer": "58e93bd8e86eb318b0197456"
4066+ }'
4067+ - lang : JavaScript
4068+ label : Node.js
4069+ source : |
4070+ import Facturapi from 'facturapi'
4071+ const facturapi = new Facturapi('sk_test_API_KEY');
4072+
4073+ // Assign an existing customer by ID
4074+ const receipt = await facturapi.receipts.assignCustomer(
4075+ '58e93bd8e86eb318b019743d',
4076+ { customer: '58e93bd8e86eb318b0197456' }
4077+ );
4078+
4079+ // Or create the customer from payload and assign it to the receipt
4080+ const receiptWithNewCustomer = await facturapi.receipts.assignCustomer(
4081+ '58e93bd8e86eb318b019743d',
4082+ {
4083+ customer: {
4084+ legal_name: 'Dunder Mifflin',
4085+ tax_id: 'XAXX010101000',
4086+ tax_system: '616',
4087+ email: 'billing@dundermifflin.com',
4088+ address: { zip: '01234', country: 'MEX' }
4089+ }
4090+ }
4091+ );
4092+ - lang : csharp
4093+ label : C#
4094+ source : |
4095+ var facturapi = new FacturapiClient("sk_test_API_KEY");
4096+
4097+ // Assign an existing customer by ID
4098+ var receipt = await facturapi.Receipt.AssignCustomerAsync(
4099+ "58e93bd8e86eb318b019743d",
4100+ new Dictionary<string, object>
4101+ {
4102+ ["customer"] = "58e93bd8e86eb318b0197456"
4103+ }
4104+ );
4105+
4106+ // Or create the customer from payload and assign it to the receipt
4107+ var receiptWithNewCustomer = await facturapi.Receipt.AssignCustomerAsync(
4108+ "58e93bd8e86eb318b019743d",
4109+ new Dictionary<string, object>
4110+ {
4111+ ["customer"] = new Dictionary<string, object>
4112+ {
4113+ ["legal_name"] = "Dunder Mifflin",
4114+ ["tax_id"] = "XAXX010101000",
4115+ ["tax_system"] = "616",
4116+ ["email"] = "billing@dundermifflin.com",
4117+ ["address"] = new Dictionary<string, object>
4118+ {
4119+ ["zip"] = "01234",
4120+ ["country"] = "MEX"
4121+ }
4122+ }
4123+ }
4124+ );
4125+ - lang : PHP
4126+ source : |
4127+ $facturapi = new Facturapi( "sk_test_API_KEY" );
4128+
4129+ // Assign an existing customer by ID
4130+ $receipt = $facturapi->Receipts->assign_customer("58e93bd8e86eb318b019743d", [
4131+ "customer" => "58e93bd8e86eb318b0197456"
4132+ ]);
4133+
4134+ // Or create the customer from payload and assign it to the receipt
4135+ $receiptWithNewCustomer = $facturapi->Receipts->assign_customer("58e93bd8e86eb318b019743d", [
4136+ "customer" => [
4137+ "legal_name" => "Dunder Mifflin",
4138+ "tax_id" => "XAXX010101000",
4139+ "tax_system" => "616",
4140+ "email" => "billing@dundermifflin.com",
4141+ "address" => [
4142+ "zip" => "01234",
4143+ "country" => "MEX"
4144+ ]
4145+ ]
4146+ ]);
4147+ parameters :
4148+ - in : path
4149+ name : receipt_id
4150+ schema :
4151+ type : string
4152+ required : true
4153+ description : ID of the receipt to update
4154+ requestBody :
4155+ $ref : " #/components/requestBodies/ReceiptAssignCustomer"
4156+ security :
4157+ - " SecretLiveKey " : []
4158+ - " SecretTestKey " : []
4159+ responses :
4160+ " 200 " :
4161+ description : Updated `Receipt` object
4162+ content :
4163+ application/json :
4164+ schema :
4165+ $ref : " #/components/schemas/Receipt"
4166+ " 400 " :
4167+ $ref : " #/components/responses/BadRequest"
4168+ " 401 " :
4169+ $ref : " #/components/responses/Unauthenticated"
4170+ " 404 " :
4171+ $ref : " #/components/responses/NotFound"
4172+ " 500 " :
4173+ $ref : " #/components/responses/UnexpectedError"
40384174 delete :
40394175 operationId : cancelReceipt
40404176 tags :
@@ -7728,6 +7864,12 @@ components:
77287864 application/json :
77297865 schema :
77307866 $ref : " #/components/schemas/ReceiptInput"
7867+ ReceiptAssignCustomer :
7868+ required : true
7869+ content :
7870+ application/json :
7871+ schema :
7872+ $ref : " #/components/schemas/ReceiptAssignCustomerInput"
77317873 ReceiptInvoice :
77327874 required : true
77337875 content :
@@ -11863,6 +12005,10 @@ components:
1186312005 type : string
1186412006 example : 614496b471d422de4b6cfcc4
1186512007 description : ID of the associated invoice, if invoiced.
12008+ customer :
12009+ type : string
12010+ example : 58e93bd8e86eb318b0197456
12011+ description : ID of the customer associated to the receipt, if assigned.
1186612012 key :
1186712013 type : string
1186812014 example : r9YqYarL
@@ -11892,6 +12038,15 @@ components:
1189212038 - items
1189312039 - payment_form
1189412040 properties :
12041+ customer :
12042+ description : |
12043+ Customer associated to the receipt. You can send the ID of an existing customer or a customer object to create it.
12044+ oneOf :
12045+ - type : string
12046+ minLength : 24
12047+ maxLength : 24
12048+ example : 58e93bd8e86eb318b0197456
12049+ - $ref : " #/components/schemas/CustomerCreateInput"
1189512050 items :
1189612051 type : array
1189712052 maxItems : 5000
@@ -11947,6 +12102,20 @@ components:
1194712102 type : string
1194812103 description : |
1194912104 Optional identifier that you can use to relate this receipt to your records and later search by this number. Facturapi does not validate that this field is unique.
12105+ ReceiptAssignCustomerInput :
12106+ type : object
12107+ required :
12108+ - customer
12109+ properties :
12110+ customer :
12111+ description : |
12112+ Customer to assign to the receipt. You can send the ID of an existing customer or a customer object to create it.
12113+ oneOf :
12114+ - type : string
12115+ minLength : 24
12116+ maxLength : 24
12117+ example : 58e93bd8e86eb318b0197456
12118+ - $ref : " #/components/schemas/CustomerCreateInput"
1195012119 ReceiptSearchResult :
1195112120 allOf :
1195212121 - $ref : " #/components/schemas/SearchResult"
0 commit comments