diff --git a/src/Message/Checkout/PurchaseRequest.php b/src/Message/Checkout/PurchaseRequest.php index d3d2386d..9f5b39a8 100644 --- a/src/Message/Checkout/PurchaseRequest.php +++ b/src/Message/Checkout/PurchaseRequest.php @@ -145,14 +145,37 @@ public function getClientReferenceId() return $this->getParameter('client_reference_id'); } + /** + * Set the customer_creation parameter + * + * @param string $value + * + * @return \Omnipay\Common\Message\AbstractRequest|PurchaseRequest + */ + public function setCustomerCreation($value) + { + return $this->setParameter('customer_creation', $value); + } + + /** + * Get the customer_creation parameter + * + * @return string + */ + public function getCustomerCreation() + { + return $this->getParameter('customer_creation'); + } public function getData() { $data = array( + 'client_reference_id' => $this->getClientReferenceId(), 'success_url' => $this->getSuccessUrl(), 'cancel_url' => $this->getCancelUrl(), 'payment_method_types' => $this->getPaymentMethodTypes(), 'mode' => $this->getMode(), + 'customer_creation' => $this->getCustomerCreation(), 'line_items' => $this->getLineItems() ); diff --git a/src/Message/PaymentIntents/AuthorizeRequest.php b/src/Message/PaymentIntents/AuthorizeRequest.php index 4a0ec8ad..5154042f 100644 --- a/src/Message/PaymentIntents/AuthorizeRequest.php +++ b/src/Message/PaymentIntents/AuthorizeRequest.php @@ -329,6 +329,42 @@ public function getOffSession() return $this->getParameter('off_session'); } + /** + * @return mixed + */ + public function getConfirmationMethod() + { + return $this->getParameter('confirmation_method'); + } + + /** + * @param string $value + * + * @return AbstractRequest provides a fluent interface. + */ + public function setConfirmationMethod($value) + { + return $this->setParameter('confirmation_method', $value); + } + + /** + * @return mixed + */ + public function getCaptureMethod() + { + return $this->getParameter('capture_method'); + } + + /** + * @param string $value + * + * @return AbstractRequest provides a fluent interface. + */ + public function setCaptureMethod($value) + { + return $this->setParameter('capture_method', $value); + } + /** * @inheritdoc */ @@ -392,8 +428,13 @@ public function getData() $data['off_session'] = $this->getOffSession() ? 'true' : 'false'; - $data['confirmation_method'] = 'manual'; - $data['capture_method'] = 'manual'; + if ($this->getConfirmationMethod()) { + $data['confirmation_method'] = $this->getConfirmationMethod(); + } + + if ($this->getCaptureMethod()) { + $data['capture_method'] = $this->getCaptureMethod(); + } $data['confirm'] = $this->getConfirm() ? 'true' : 'false'; diff --git a/src/Message/PaymentIntents/CreatePaymentMethodRequest.php b/src/Message/PaymentIntents/CreatePaymentMethodRequest.php index 61ee03d0..32c3642a 100644 --- a/src/Message/PaymentIntents/CreatePaymentMethodRequest.php +++ b/src/Message/PaymentIntents/CreatePaymentMethodRequest.php @@ -117,7 +117,7 @@ public function getBillingDetails() 'country' => $data['address_country'], 'line1' => $data['address_line1'], 'line2' => $data['address_line2'], - 'postal_code' => $data['address_zip'], + 'postal_code' => $data['address_zip'] ?? null, 'state' => $data['address_state'], ]), ]); diff --git a/tests/Message/Checkout/PurchaseRequestTest.php b/tests/Message/Checkout/PurchaseRequestTest.php new file mode 100644 index 00000000..801d701b --- /dev/null +++ b/tests/Message/Checkout/PurchaseRequestTest.php @@ -0,0 +1,31 @@ +request = new PurchaseRequest($this->getHttpClient(), $this->getHttpRequest()); + $this->request->initialize( + array( + 'client_reference_id' => 'cart_id_123' + ) + ); + } + + public function testGetData() + { + $data = $this->request->getData(); + + $this->assertSame('cart_id_123', $data['client_reference_id']); + } + +}