Skip to content

Commit

Permalink
add new fields in payment method
Browse files Browse the repository at this point in the history
  • Loading branch information
rondogency committed Jun 28, 2018
1 parent e651272 commit ac15f4b
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public function setEmail($value)
/**
* Get the customer's tax exemptions
*
* @return null|TaxExemptionBag
* @return null|array
*/
public function getTaxExemptions()
{
Expand Down
3 changes: 3 additions & 0 deletions src/ObjectHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ public function buildPaymentMethod(stdClass $object)
return new PaymentMethod(array(
'paymentMethodId' => isset($object->merchantPaymentMethodId) ? $object->merchantPaymentMethodId : null,
'paymentMethodReference' => isset($object->VID) ? $object->VID : null,
'type' => isset($object->type) ? $object->type : null,
'postcode' => isset($object->billingAddress->postalCode) ? $object->billingAddress->postalCode : null,
'country' => isset($object->billingAddress->country) ? $object->billingAddress->country : null,
// NonStrippingCreditCard won't remove the X's that Vindicia masks with
'card' => new NonStrippingCreditCard(array(
'name' => isset($object->accountHolderName) ? $object->accountHolderName : null,
Expand Down
63 changes: 63 additions & 0 deletions src/PaymentMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,69 @@ public function setCard($value)
return $this->setParameter('card', $value);
}

/**
* Get the payment method type, either PayPal or CreditCard
*
* @return null|string
*/
public function getType()
{
return $this->getParameter('type');
}

/**
* Sets the payment method type
*
* @param string $value
* @return static
*/
public function setType($value)
{
return $this->setParameter('type', $value);
}

/**
* Get the billing postcode.
*
* @return null|string
*/
public function getPostcode()
{
return $this->getParameter('postcode');
}

/**
* Sets the billing postcode.
*
* @param string $value
* @return static
*/
public function setPostcode($value)
{
return $this->setParameter('postcode', $value);
}

/**
* Get the billing country.
*
* @return null|string
*/
public function getCountry()
{
return $this->getParameter('country');
}

/**
* Sets the billing country.
*
* @param string $value
* @return static
*/
public function setCountry($value)
{
return $this->setParameter('country', $value);
}

/**
* A list of attributes
*
Expand Down
30 changes: 30 additions & 0 deletions tests/PaymentMethodTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,36 @@ public function testCard()
$this->assertSame($card, $this->paymentMethod->getCard());
}

/**
* @return void
*/
public function testType()
{
$type = 'PayPal';
$this->assertSame($this->paymentMethod, $this->paymentMethod->setType($type));
$this->assertSame($type, $this->paymentMethod->getType());
}

/**
* @return void
*/
public function testPostcode()
{
$postcode = $this->faker->postcode();
$this->assertSame($this->paymentMethod, $this->paymentMethod->setPostcode($postcode));
$this->assertSame($postcode, $this->paymentMethod->getPostcode());
}

/**
* @return void
*/
public function testCountry()
{
$country = $this->faker->region();
$this->assertSame($this->paymentMethod, $this->paymentMethod->setCountry($country));
$this->assertSame($country, $this->paymentMethod->getCountry());
}

/**
* @return void
*/
Expand Down

0 comments on commit ac15f4b

Please sign in to comment.