0

Create partner referral

by
Published Apr 8, 2025

Creates a partner referral that is shared by the partner or API caller. The partner referral is used to onboard the seller, and contains the seller's personal, business, financial and operations.

Script paypal Verified

The script

Submitted by hugo697 Bun
Verified 427 days ago
1
//native
2
type Paypal = {
3
  clientId: string;
4
  clientSecret: string;
5
};
6

7
async function getToken(auth: Paypal): Promise<string> {
8
  const url = new URL(`https://api-m.paypal.com/v1/oauth2/token`);
9
  const response = await fetch(url, {
10
    method: "POST",
11
    headers: {
12
      Authorization: `Basic ${btoa(`${auth.clientId}:${auth.clientSecret}`)}`,
13
    },
14
    body: new URLSearchParams({
15
      grant_type: "client_credentials",
16
    }),
17
  });
18
  if (!response.ok) {
19
    const text = await response.text();
20
    throw new Error(`Could not get token: ${response.status} ${text}`);
21
  }
22
  const json = await response.json();
23
  return json.access_token;
24
}
25
/**
26
 * Create partner referral
27
 * Creates a partner referral that is shared by the partner or API caller. The partner referral is used to onboard the seller, and contains the seller's personal, business, financial and operations.
28
 */
29
export async function main(
30
  auth: Paypal,
31
  body: {
32
    individual_owners?: {
33
      id?: string;
34
      names?: {
35
        prefix?: string;
36
        given_name?: string;
37
        surname?: string;
38
        middle_name?: string;
39
        suffix?: string;
40
        full_name?: string;
41
      } & { type?: "LEGAL" }[];
42
      citizenship?: string;
43
      addresses?: {
44
        address_line_1?: string;
45
        address_line_2?: string;
46
        address_line_3?: string;
47
        admin_area_4?: string;
48
        admin_area_3?: string;
49
        admin_area_2?: string;
50
        admin_area_1?: string;
51
        postal_code?: string;
52
        country_code: string;
53
        address_details?: {
54
          street_number?: string;
55
          street_name?: string;
56
          street_type?: string;
57
          delivery_service?: string;
58
          building_name?: string;
59
          sub_building?: string;
60
        };
61
      } & { type?: "HOME"; primary?: false | true; inactive?: false | true }[];
62
      phones?: {
63
        country_code: string;
64
        national_number: string;
65
        extension_number?: string;
66
      } & {
67
        contact_name?: string;
68
        inactive?: false | true;
69
        primary?: false | true;
70
        primary_mobile?: false | true;
71
        type?: "HOME" | "FAX" | "MOBILE" | "OTHER" | "PAGER";
72
        tags?: "MOBILE" | "LANDLINE"[];
73
      }[];
74
      birth_details?: { date_of_birth: string };
75
      documents?: {
76
        id?: string;
77
        labels?: string[];
78
        name?: string;
79
        identification_number?: string;
80
        issue_date?: string;
81
        expiry_date?: string;
82
        issuing_country_code?: string;
83
        files?: {
84
          id?: string;
85
          reference_url?: string;
86
          content_type?: string;
87
          create_time?: string;
88
          size?: string;
89
        }[];
90
        links?: {
91
          href: string;
92
          rel: string;
93
          method?:
94
            | "GET"
95
            | "POST"
96
            | "PUT"
97
            | "DELETE"
98
            | "HEAD"
99
            | "CONNECT"
100
            | "OPTIONS"
101
            | "PATCH";
102
        }[];
103
      } & {
104
        type?:
105
          | "SOCIAL_SECURITY_NUMBER"
106
          | "EMPLOYMENT_IDENTIFICATION_NUMBER"
107
          | "TAX_IDENTIFICATION_NUMBER"
108
          | "PASSPORT_NUMBER"
109
          | "PENSION_FUND_ID"
110
          | "MEDICAL_INSURANCE_ID"
111
          | "CNPJ"
112
          | "CPF"
113
          | "PAN";
114
      }[];
115
    } & { type?: "PRIMARY" }[];
116
    business_entity?: {
117
      business_type?: {
118
        type?:
119
          | "ANY_OTHER_BUSINESS_ENTITY"
120
          | "ASSOCIATION"
121
          | "CORPORATION"
122
          | "GENERAL_PARTNERSHIP"
123
          | "GOVERNMENT"
124
          | "INDIVIDUAL"
125
          | "LIMITED_LIABILITY_PARTNERSHIP"
126
          | "LIMITED_LIABILITY_PROPRIETORS"
127
          | "LIMITED_LIABILITY_PRIVATE_CORPORATION"
128
          | "LIMITED_PARTNERSHIP"
129
          | "LIMITED_PARTNERSHIP_PRIVATE_CORPORATION"
130
          | "NONPROFIT"
131
          | "ONLY_BUY_OR_SEND_MONEY"
132
          | "OTHER_CORPORATE_BODY"
133
          | "PARTNERSHIP"
134
          | "PRIVATE_PARTNERSHIP"
135
          | "PROPRIETORSHIP"
136
          | "PROPRIETORSHIP_CRAFTSMAN"
137
          | "PROPRIETORY_COMPANY"
138
          | "PRIVATE_CORPORATION"
139
          | "PUBLIC_COMPANY"
140
          | "PUBLIC_CORPORATION"
141
          | "PUBLIC_PARTNERSHIP"
142
          | "REGISTERED_COOPERATIVE";
143
        subtype?:
144
          | "ASSO_TYPE_INCORPORATED"
145
          | "ASSO_TYPE_NON_INCORPORATED"
146
          | "GOVT_TYPE_ENTITY"
147
          | "GOVT_TYPE_EMANATION"
148
          | "GOVT_TYPE_ESTD_COMM"
149
          | "GOVT_TYPE_ESTD_FC"
150
          | "GOVT_TYPE_ESTD_ST_TR";
151
      };
152
      business_industry?: {
153
        category: string;
154
        mcc_code: string;
155
        subcategory: string;
156
      };
157
      business_incorporation?: {
158
        incorporation_country_code?: string;
159
        incorporation_date?: string;
160
        incorporation_province_code?: string;
161
      };
162
      names?: { business_name?: string } & {
163
        id?: string;
164
        type?: "DOING_BUSINESS_AS" | "LEGAL_NAME";
165
      }[];
166
      emails?: { type: "CUSTOMER_SERVICE"; email: string }[];
167
      website?: string;
168
      addresses?: {
169
        address_line_1?: string;
170
        address_line_2?: string;
171
        address_line_3?: string;
172
        admin_area_4?: string;
173
        admin_area_3?: string;
174
        admin_area_2?: string;
175
        admin_area_1?: string;
176
        postal_code?: string;
177
        country_code: string;
178
        address_details?: {
179
          street_number?: string;
180
          street_name?: string;
181
          street_type?: string;
182
          delivery_service?: string;
183
          building_name?: string;
184
          sub_building?: string;
185
        };
186
      } & { type?: "WORK"; primary?: false | true; inactive?: false | true }[];
187
      phones?: {
188
        country_code: string;
189
        national_number: string;
190
        extension_number?: string;
191
      } & {
192
        contact_name?: string;
193
        inactive?: false | true;
194
        primary?: false | true;
195
        type?: "CUSTOMER_SERVICE" | "BUSINESS";
196
        tags?: "MOBILE" | "LANDLINE"[];
197
      }[];
198
      documents?: {
199
        id?: string;
200
        labels?: string[];
201
        name?: string;
202
        identification_number?: string;
203
        issue_date?: string;
204
        expiry_date?: string;
205
        issuing_country_code?: string;
206
        files?: {
207
          id?: string;
208
          reference_url?: string;
209
          content_type?: string;
210
          create_time?: string;
211
          size?: string;
212
        }[];
213
        links?: {
214
          href: string;
215
          rel: string;
216
          method?:
217
            | "GET"
218
            | "POST"
219
            | "PUT"
220
            | "DELETE"
221
            | "HEAD"
222
            | "CONNECT"
223
            | "OPTIONS"
224
            | "PATCH";
225
        }[];
226
      } & {
227
        type?:
228
          | "SOCIAL_SECURITY_NUMBER"
229
          | "EMPLOYMENT_IDENTIFICATION_NUMBER"
230
          | "TAX_IDENTIFICATION_NUMBER"
231
          | "PASSPORT_NUMBER"
232
          | "PENSION_FUND_ID"
233
          | "MEDICAL_INSURANCE_ID"
234
          | "CNPJ"
235
          | "CPF"
236
          | "PAN";
237
      }[];
238
    } & {
239
      beneficial_owners?: {
240
        individual_beneficial_owners?: {
241
          id?: string;
242
          names?: {
243
            prefix?: string;
244
            given_name?: string;
245
            surname?: string;
246
            middle_name?: string;
247
            suffix?: string;
248
            full_name?: string;
249
          } & { type?: "LEGAL" }[];
250
          citizenship?: string;
251
          addresses?: {
252
            address_line_1?: string;
253
            address_line_2?: string;
254
            address_line_3?: string;
255
            admin_area_4?: string;
256
            admin_area_3?: string;
257
            admin_area_2?: string;
258
            admin_area_1?: string;
259
            postal_code?: string;
260
            country_code: string;
261
            address_details?: {
262
              street_number?: string;
263
              street_name?: string;
264
              street_type?: string;
265
              delivery_service?: string;
266
              building_name?: string;
267
              sub_building?: string;
268
            };
269
          } & {
270
            type?: "HOME";
271
            primary?: false | true;
272
            inactive?: false | true;
273
          }[];
274
          phones?: {
275
            country_code: string;
276
            national_number: string;
277
            extension_number?: string;
278
          } & {
279
            contact_name?: string;
280
            inactive?: false | true;
281
            primary?: false | true;
282
            primary_mobile?: false | true;
283
            type?: "HOME" | "FAX" | "MOBILE" | "OTHER" | "PAGER";
284
            tags?: "MOBILE" | "LANDLINE"[];
285
          }[];
286
          birth_details?: { date_of_birth: string };
287
          documents?: {
288
            id?: string;
289
            labels?: string[];
290
            name?: string;
291
            identification_number?: string;
292
            issue_date?: string;
293
            expiry_date?: string;
294
            issuing_country_code?: string;
295
            files?: {
296
              id?: string;
297
              reference_url?: string;
298
              content_type?: string;
299
              create_time?: string;
300
              size?: string;
301
            }[];
302
            links?: {
303
              href: string;
304
              rel: string;
305
              method?:
306
                | "GET"
307
                | "POST"
308
                | "PUT"
309
                | "DELETE"
310
                | "HEAD"
311
                | "CONNECT"
312
                | "OPTIONS"
313
                | "PATCH";
314
            }[];
315
          } & {
316
            type?:
317
              | "SOCIAL_SECURITY_NUMBER"
318
              | "EMPLOYMENT_IDENTIFICATION_NUMBER"
319
              | "TAX_IDENTIFICATION_NUMBER"
320
              | "PASSPORT_NUMBER"
321
              | "PENSION_FUND_ID"
322
              | "MEDICAL_INSURANCE_ID"
323
              | "CNPJ"
324
              | "CPF"
325
              | "PAN";
326
          }[];
327
        } & { percentage_of_ownership?: string }[];
328
        business_beneficial_owners?: {
329
          business_type?: {
330
            type?:
331
              | "ANY_OTHER_BUSINESS_ENTITY"
332
              | "ASSOCIATION"
333
              | "CORPORATION"
334
              | "GENERAL_PARTNERSHIP"
335
              | "GOVERNMENT"
336
              | "INDIVIDUAL"
337
              | "LIMITED_LIABILITY_PARTNERSHIP"
338
              | "LIMITED_LIABILITY_PROPRIETORS"
339
              | "LIMITED_LIABILITY_PRIVATE_CORPORATION"
340
              | "LIMITED_PARTNERSHIP"
341
              | "LIMITED_PARTNERSHIP_PRIVATE_CORPORATION"
342
              | "NONPROFIT"
343
              | "ONLY_BUY_OR_SEND_MONEY"
344
              | "OTHER_CORPORATE_BODY"
345
              | "PARTNERSHIP"
346
              | "PRIVATE_PARTNERSHIP"
347
              | "PROPRIETORSHIP"
348
              | "PROPRIETORSHIP_CRAFTSMAN"
349
              | "PROPRIETORY_COMPANY"
350
              | "PRIVATE_CORPORATION"
351
              | "PUBLIC_COMPANY"
352
              | "PUBLIC_CORPORATION"
353
              | "PUBLIC_PARTNERSHIP"
354
              | "REGISTERED_COOPERATIVE";
355
            subtype?:
356
              | "ASSO_TYPE_INCORPORATED"
357
              | "ASSO_TYPE_NON_INCORPORATED"
358
              | "GOVT_TYPE_ENTITY"
359
              | "GOVT_TYPE_EMANATION"
360
              | "GOVT_TYPE_ESTD_COMM"
361
              | "GOVT_TYPE_ESTD_FC"
362
              | "GOVT_TYPE_ESTD_ST_TR";
363
          };
364
          business_industry?: {
365
            category: string;
366
            mcc_code: string;
367
            subcategory: string;
368
          };
369
          business_incorporation?: {
370
            incorporation_country_code?: string;
371
            incorporation_date?: string;
372
            incorporation_province_code?: string;
373
          };
374
          names?: { business_name?: string } & {
375
            id?: string;
376
            type?: "DOING_BUSINESS_AS" | "LEGAL_NAME";
377
          }[];
378
          emails?: { type: "CUSTOMER_SERVICE"; email: string }[];
379
          website?: string;
380
          addresses?: {
381
            address_line_1?: string;
382
            address_line_2?: string;
383
            address_line_3?: string;
384
            admin_area_4?: string;
385
            admin_area_3?: string;
386
            admin_area_2?: string;
387
            admin_area_1?: string;
388
            postal_code?: string;
389
            country_code: string;
390
            address_details?: {
391
              street_number?: string;
392
              street_name?: string;
393
              street_type?: string;
394
              delivery_service?: string;
395
              building_name?: string;
396
              sub_building?: string;
397
            };
398
          } & {
399
            type?: "WORK";
400
            primary?: false | true;
401
            inactive?: false | true;
402
          }[];
403
          phones?: {
404
            country_code: string;
405
            national_number: string;
406
            extension_number?: string;
407
          } & {
408
            contact_name?: string;
409
            inactive?: false | true;
410
            primary?: false | true;
411
            type?: "CUSTOMER_SERVICE" | "BUSINESS";
412
            tags?: "MOBILE" | "LANDLINE"[];
413
          }[];
414
          documents?: {
415
            id?: string;
416
            labels?: string[];
417
            name?: string;
418
            identification_number?: string;
419
            issue_date?: string;
420
            expiry_date?: string;
421
            issuing_country_code?: string;
422
            files?: {
423
              id?: string;
424
              reference_url?: string;
425
              content_type?: string;
426
              create_time?: string;
427
              size?: string;
428
            }[];
429
            links?: {
430
              href: string;
431
              rel: string;
432
              method?:
433
                | "GET"
434
                | "POST"
435
                | "PUT"
436
                | "DELETE"
437
                | "HEAD"
438
                | "CONNECT"
439
                | "OPTIONS"
440
                | "PATCH";
441
            }[];
442
          } & {
443
            type?:
444
              | "SOCIAL_SECURITY_NUMBER"
445
              | "EMPLOYMENT_IDENTIFICATION_NUMBER"
446
              | "TAX_IDENTIFICATION_NUMBER"
447
              | "PASSPORT_NUMBER"
448
              | "PENSION_FUND_ID"
449
              | "MEDICAL_INSURANCE_ID"
450
              | "CNPJ"
451
              | "CPF"
452
              | "PAN";
453
          }[];
454
        } & { percentage_of_ownership?: string }[];
455
      };
456
      office_bearers?: {
457
        id?: string;
458
        names?: {
459
          prefix?: string;
460
          given_name?: string;
461
          surname?: string;
462
          middle_name?: string;
463
          suffix?: string;
464
          full_name?: string;
465
        } & { type?: "LEGAL" }[];
466
        citizenship?: string;
467
        addresses?: {
468
          address_line_1?: string;
469
          address_line_2?: string;
470
          address_line_3?: string;
471
          admin_area_4?: string;
472
          admin_area_3?: string;
473
          admin_area_2?: string;
474
          admin_area_1?: string;
475
          postal_code?: string;
476
          country_code: string;
477
          address_details?: {
478
            street_number?: string;
479
            street_name?: string;
480
            street_type?: string;
481
            delivery_service?: string;
482
            building_name?: string;
483
            sub_building?: string;
484
          };
485
        } & {
486
          type?: "HOME";
487
          primary?: false | true;
488
          inactive?: false | true;
489
        }[];
490
        phones?: {
491
          country_code: string;
492
          national_number: string;
493
          extension_number?: string;
494
        } & {
495
          contact_name?: string;
496
          inactive?: false | true;
497
          primary?: false | true;
498
          primary_mobile?: false | true;
499
          type?: "HOME" | "FAX" | "MOBILE" | "OTHER" | "PAGER";
500
          tags?: "MOBILE" | "LANDLINE"[];
501
        }[];
502
        birth_details?: { date_of_birth: string };
503
        documents?: {
504
          id?: string;
505
          labels?: string[];
506
          name?: string;
507
          identification_number?: string;
508
          issue_date?: string;
509
          expiry_date?: string;
510
          issuing_country_code?: string;
511
          files?: {
512
            id?: string;
513
            reference_url?: string;
514
            content_type?: string;
515
            create_time?: string;
516
            size?: string;
517
          }[];
518
          links?: {
519
            href: string;
520
            rel: string;
521
            method?:
522
              | "GET"
523
              | "POST"
524
              | "PUT"
525
              | "DELETE"
526
              | "HEAD"
527
              | "CONNECT"
528
              | "OPTIONS"
529
              | "PATCH";
530
          }[];
531
        } & {
532
          type?:
533
            | "SOCIAL_SECURITY_NUMBER"
534
            | "EMPLOYMENT_IDENTIFICATION_NUMBER"
535
            | "TAX_IDENTIFICATION_NUMBER"
536
            | "PASSPORT_NUMBER"
537
            | "PENSION_FUND_ID"
538
            | "MEDICAL_INSURANCE_ID"
539
            | "CNPJ"
540
            | "CPF"
541
            | "PAN";
542
        }[];
543
      } & {
544
        role?:
545
          | "CEO"
546
          | "CHAIRMAN"
547
          | "DIRECTOR"
548
          | "SECRETARY"
549
          | "TREASURER"
550
          | "TRUSTEE";
551
      }[];
552
      annual_sales_volume_range?: {
553
        minimum_amount?: { currency_code: string; value: string };
554
        maximum_amount?: { currency_code: string; value: string };
555
      };
556
      average_monthly_volume_range?: {
557
        minimum_amount?: { currency_code: string; value: string };
558
        maximum_amount?: { currency_code: string; value: string };
559
      };
560
      purpose_code?:
561
        | "P0104"
562
        | "P0301"
563
        | "P0801"
564
        | "P0802"
565
        | "P0803"
566
        | "P0805"
567
        | "P0806"
568
        | "P0902"
569
        | "P1004"
570
        | "P1005"
571
        | "P1006"
572
        | "P1007"
573
        | "P1008"
574
        | "P1009"[];
575
      business_description?: string;
576
    };
577
  } & {
578
    email?: string;
579
    preferred_language_code?: string;
580
    tracking_id?: string;
581
    partner_config_override?: {
582
      partner_logo_url?: string;
583
      return_url?: string;
584
      return_url_description?: string;
585
      action_renewal_url?: string;
586
      show_add_credit_card?: false | true;
587
    };
588
    financial_instruments?: {
589
      banks?: {
590
        nick_name?: string;
591
        account_number: string;
592
        account_type: "CHECKING" | "SAVINGS";
593
        currency_code?: string;
594
        identifiers?: {
595
          type?:
596
            | "BANK_CODE"
597
            | "BI_CODE"
598
            | "ROUTING_NUMBER_1"
599
            | "ROUTING_NUMBER_2"
600
            | "ROUTING_NUMBER_3"
601
            | "SWIFT_CODE"
602
            | "BRANCH_CODE"
603
            | "INTERMEDIARY_SWIFT_CODE"
604
            | "BBAN"
605
            | "BBAN_ENCRYPTED"
606
            | "BBAN_HMAC"
607
            | "AGGREGATOR_YODLEE";
608
          value?: string;
609
        }[];
610
        branch_location?: {
611
          address_line_1?: string;
612
          address_line_2?: string;
613
          address_line_3?: string;
614
          admin_area_4?: string;
615
          admin_area_3?: string;
616
          admin_area_2?: string;
617
          admin_area_1?: string;
618
          postal_code?: string;
619
          country_code: string;
620
          address_details?: {
621
            street_number?: string;
622
            street_name?: string;
623
            street_type?: string;
624
            delivery_service?: string;
625
            building_name?: string;
626
            sub_building?: string;
627
          };
628
        };
629
        mandate?: { accepted: false | true };
630
      }[];
631
    };
632
    operations?: {
633
      operation?:
634
        | "API_INTEGRATION"
635
        | "BANK_ADDITION"
636
        | "BILLING_AGREEMENT"
637
        | "CONTEXTUAL_MARKETING_CONSENT"
638
        | "SALESFORCE_REFERRAL";
639
      api_integration_preference?: {
640
        classic_api_integration?: {};
641
        rest_api_integration?: {
642
          integration_method?: "BRAINTREE" | "PAYPAL";
643
          integration_type?: "FIRST_PARTY" | "THIRD_PARTY";
644
          first_party_details?: {
645
            features:
646
              | "BILLING_AGREEMENT"
647
              | "PAYOUTS"
648
              | "PAYMENT"
649
              | "REFUND"
650
              | "FUTURE_PAYMENT"
651
              | "DIRECT_PAYMENT"
652
              | "PARTNER_FEE"
653
              | "DELAY_FUNDS_DISBURSEMENT"
654
              | "READ_SELLER_DISPUTE"
655
              | "UPDATE_SELLER_DISPUTE"
656
              | "ADVANCED_TRANSACTIONS_SEARCH"
657
              | "SWEEP_FUNDS_EXTERNAL_SINK"
658
              | "ACCESS_MERCHANT_INFORMATION"
659
              | "TRACKING_SHIPMENT_READWRITE"
660
              | "INVOICE_READ_WRITE"
661
              | "DISPUTE_READ_BUYER"
662
              | "UPDATE_CUSTOMER_DISPUTES"
663
              | "VAULT"[];
664
            seller_nonce: string;
665
          };
666
          third_party_details?: {
667
            features:
668
              | "BILLING_AGREEMENT"
669
              | "PAYOUTS"
670
              | "PAYMENT"
671
              | "REFUND"
672
              | "FUTURE_PAYMENT"
673
              | "DIRECT_PAYMENT"
674
              | "PARTNER_FEE"
675
              | "DELAY_FUNDS_DISBURSEMENT"
676
              | "READ_SELLER_DISPUTE"
677
              | "UPDATE_SELLER_DISPUTE"
678
              | "ADVANCED_TRANSACTIONS_SEARCH"
679
              | "SWEEP_FUNDS_EXTERNAL_SINK"
680
              | "ACCESS_MERCHANT_INFORMATION"
681
              | "TRACKING_SHIPMENT_READWRITE"
682
              | "INVOICE_READ_WRITE"
683
              | "DISPUTE_READ_BUYER"
684
              | "UPDATE_CUSTOMER_DISPUTES"
685
              | "VAULT"[];
686
          };
687
        };
688
      };
689
      billing_agreement?: {
690
        description?: string;
691
        billing_experience_preference?: {
692
          experience_id?: string;
693
          billing_context_set?: false | true;
694
        };
695
        merchant_custom_data?: string;
696
        approval_url?: string;
697
        ec_token?: string;
698
      };
699
    }[];
700
    products?:
701
      | "EXPRESS_CHECKOUT"
702
      | "PAYPAL_COMMERCE_PLATFORM_BUSINESS"
703
      | "PPPLUS"
704
      | "WEBSITE_PAYMENT_PRO"
705
      | "PAYMENT_METHODS"
706
      | "PPCP"
707
      | "ADVANCED_VAULTING"
708
      | "IZETTLE"[];
709
    capabilities?:
710
      | "PAYPAL_WALLET_VAULTING_ADVANCED"
711
      | "PAY_UPON_INVOICE"
712
      | "APPLE_PAY"[];
713
    outside_process_dependencies?: unknown[];
714
    legal_consents?: { type: "SHARE_DATA_CONSENT"; granted: false | true }[];
715
    payout_attributes?: {
716
      marketplace?: false | true;
717
      kyc_required?: false | true;
718
      country_transfer_method_currency_selection?: {
719
        country?: string;
720
        transfer_methods?: {
721
          transfer_method_type?:
722
            | "PAYPAL"
723
            | "BANK_ACCOUNT"
724
            | "VENMO"
725
            | "WIRE_ACCOUNT";
726
          currencies?: string[];
727
        }[];
728
      }[];
729
    };
730
  },
731
) {
732
  const token = await getToken(auth);
733
  const url = new URL(`https://api-m.paypal.com/v2/customer/partner-referrals`);
734

735
  const response = await fetch(url, {
736
    method: "POST",
737
    headers: {
738
      "Content-Type": "application/json",
739
      Authorization: "Bearer " + token,
740
    },
741
    body: JSON.stringify(body),
742
  });
743
  if (!response.ok) {
744
    const text = await response.text();
745
    throw new Error(`${response.status} ${text}`);
746
  }
747
  return await response.json();
748
}
749