DocumentUpload.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace Braintree;
  3. use InvalidArgumentException;
  4. /**
  5. * Upload documents to Braintree in exchange for a DocumentUpload object.
  6. *
  7. * An example of creating a document upload with all available fields:
  8. * $result = Braintree\DocumentUpload::create([
  9. * "kind" => Braintree\DocumentUpload::EVIDENCE_DOCUMENT,
  10. * "file" => $pngFile
  11. * ]);
  12. *
  13. * For more information on DocumentUploads, see https://developers.braintreepayments.com/reference/request/document_upload/create
  14. */
  15. class DocumentUpload extends Base
  16. {
  17. /* DocumentUpload Kind */
  18. const EVIDENCE_DOCUMENT = "evidence_document";
  19. protected function _initialize($documentUploadAttribs)
  20. {
  21. $this->_attributes = $documentUploadAttribs;
  22. }
  23. /**
  24. * Creates a DocumentUpload object
  25. * @param kind The kind of document
  26. * @param file The open file to upload
  27. * @throws InvalidArgumentException if the params are not expected
  28. */
  29. public static function create($params)
  30. {
  31. return Configuration::gateway()->documentUpload()->create($params);
  32. }
  33. public static function factory($attributes)
  34. {
  35. $instance = new self();
  36. $instance->_initialize($attributes);
  37. return $instance;
  38. }
  39. }
  40. class_alias('Braintree\DocumentUpload', 'Braintree_DocumentUpload');