Skip to content

Commit

Permalink
Add support to COF transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
facine committed Sep 16, 2020
1 parent d169341 commit 1a52b71
Show file tree
Hide file tree
Showing 2 changed files with 136 additions and 0 deletions.
73 changes: 73 additions & 0 deletions src/Sermepa.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,21 @@ class Sermepa implements SermepaInterface {
*/
private $DsMerchantChargeExpiryDate;

/**
* COF transaction indicator.
*/
private $DsMerchantCofIni;

/**
* COF transaction ID.
*/
private $DsMerchantCofTxnid;

/**
* Transaction type.
*/
private $DsMerchantCofType;

/**
* Optional: 3 is considered its maximum length. The value 000, indicating
* that there isn't determined the customer's language.
Expand Down Expand Up @@ -399,6 +414,9 @@ private function getParameters() {
'Ds_Merchant_ChargeExpiryDate' => $this->DsMerchantChargeExpiryDate,
'Ds_Merchant_ConsumerLanguage' => $this->DsMerchantConsumerLanguage,
'Ds_Merchant_Currency' => $this->DsMerchantCurrency,
'Ds_Merchant_Cof_Ini' => $this->DsMerchantCofIni,
'Ds_Merchant_Cof_Txnid' => $this->DsMerchantCofTxnid,
'Ds_Merchant_Cof_Type' => $this->DsMerchantCofType,
'Ds_Merchant_DateFrecuency' => $this->DsMerchantDateFrecuency,
'Ds_Merchant_Excep_SCA' => $this->DsMerchantExcepSCA,
'Ds_Merchant_Group' => $this->DsMerchantGroup,
Expand Down Expand Up @@ -931,6 +949,61 @@ public function getChargeExpiryDate() {
return $this->DsMerchantChargeExpiryDate;
}

/**
* {@inheritdoc}
*/
public function setCofIni($ini) {
$allowed_inis = array('S', 'N');
if (!in_array($ini, $allowed_inis)) {
throw new SermepaException('The specified Ds_Merchant_Cof_Ini: ' . $ini . ' is not valid.', self::BAD_PARAM);
}

return $this->set('DsMerchantCofIni', $ini);
}

/**
* {@inheritdoc}
*/
public function getCofIni() {
return $this->DsMerchantCofIni;
}

/**
* {@inheritdoc}
*/
public function setCofTxnid($txn_id) {
return $this->set('DsMerchantCofTxnid', $txn_id);
}

/**
* {@inheritdoc}
*/
public function getCofTxnid() {
return $this->DsMerchantCofTxnid;
}

/**
* {@inheritdoc}
*/
public function setCofType($type) {
$allowed_types = array(
'I', 'R', 'H', 'E',
'D', 'M', 'N', 'C',
);
if (!in_array($type, $allowed_types)) {
throw new SermepaException('The specified Ds_Merchant_Cof_Type: ' . $type . ' is not valid.', self::BAD_PARAM);
}

return $this->set('DsMerchantCofType', $type);
}

/**
* {@inheritdoc}
*/
public function getCofType() {
return $this->DsMerchantCofType;
}

/**
* {@inheritdoc}
*/
Expand Down
63 changes: 63 additions & 0 deletions src/SermepaInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,69 @@ public function setChargeExpiryDate($charge_expiry_date);
*/
public function getChargeExpiryDate();

/**
* Setter for Sermepa::DsMerchantCofIni property.
*
* @param string $ini
* The value to set.
*
* @return Sermepa
* Return itself.
*
* @throws \CommerceRedsys\Payment\SermepaException
*/
public function setCofIni($ini);

/**
* Getter for Sermepa::DsMerchantCofIni property.
*
* @return string
* Return the requested property.
*/
public function getCofIni();

/**
* Setter for Sermepa::DsMerchantCofTxnid property.
*
* @param string $txn_id
* The value to set.
*
* @return Sermepa
* Return itself.
*
* @throws \CommerceRedsys\Payment\SermepaException
*/
public function setCofTxnid($txn_id);

/**
* Getter for Sermepa::DsMerchantCofTxnid property.
*
* @return string
* Return the requested property.
*/
public function getCofTxnid();

/**
* Setter for Sermepa::DsMerchantCofType property.
*
* @param string $type
* The value to set.
*
* @return Sermepa
* Return itself.
*
* @throws \CommerceRedsys\Payment\SermepaException
*/
public function setCofType($type);

/**
* Getter for Sermepa::DsMerchantCofType property.
*
* @return string
* Return the requested property.
*/
public function getCofType();

/**
* Setter for Sermepa::DsMerchantConsumerLanguage property.
*
Expand Down

0 comments on commit 1a52b71

Please sign in to comment.