wp-pay-gateways /
ideal-advanced-v3
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Pronamic\WordPress\Pay\Gateways\IDealAdvancedV3\XML; |
||
| 4 | |||
| 5 | use Pronamic\WordPress\Pay\Gateways\IDealAdvancedV3\IDeal; |
||
| 6 | use Pronamic\WordPress\Pay\Gateways\IDealAdvancedV3\Issuer; |
||
| 7 | use Pronamic\WordPress\Pay\Gateways\IDealAdvancedV3\Transaction; |
||
| 8 | |||
| 9 | /** |
||
| 10 | * Title: iDEAL transaction request XML message |
||
| 11 | * Description: |
||
| 12 | * Copyright: 2005-2019 Pronamic |
||
| 13 | * Company: Pronamic |
||
| 14 | * |
||
| 15 | * @author Remco Tolsma |
||
| 16 | * @version 2.0.1 |
||
| 17 | */ |
||
| 18 | class TransactionRequestMessage extends RequestMessage { |
||
| 19 | /** |
||
| 20 | * The document element name |
||
| 21 | * |
||
| 22 | * @var string |
||
| 23 | */ |
||
| 24 | const NAME = 'AcquirerTrxReq'; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * Issuer |
||
| 28 | * |
||
| 29 | * @var Issuer |
||
| 30 | */ |
||
| 31 | public $issuer; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Transaction |
||
| 35 | * |
||
| 36 | * @var Transaction |
||
| 37 | */ |
||
| 38 | public $transaction; |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Constructs and initializes an transaction request message |
||
| 42 | */ |
||
| 43 | public function __construct() { |
||
| 44 | parent::__construct( self::NAME ); |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Get document |
||
| 49 | * |
||
| 50 | * @see RequestMessage::get_document() |
||
| 51 | */ |
||
| 52 | public function get_document() { |
||
| 53 | $document = parent::get_document(); |
||
| 54 | |||
| 55 | // Issuer. |
||
| 56 | $issuer = $this->issuer; |
||
| 57 | |||
| 58 | $element = self::add_element( $document, $document->documentElement, 'Issuer' ); |
||
| 59 | |||
| 60 | self::add_element( |
||
| 61 | $document, |
||
| 62 | $element, |
||
| 63 | 'issuerID', |
||
| 64 | $issuer->get_id() |
||
| 65 | ); |
||
| 66 | |||
| 67 | // Merchant. |
||
| 68 | $merchant = $this->get_merchant(); |
||
| 69 | |||
| 70 | $element = self::add_element( $document, $document->documentElement, 'Merchant' ); |
||
| 71 | |||
| 72 | self::add_elements( |
||
| 73 | $document, |
||
| 74 | $element, |
||
| 75 | array( |
||
| 76 | 'merchantID' => $merchant->get_id(), |
||
| 77 | 'subID' => $merchant->get_sub_id(), |
||
| 78 | 'merchantReturnURL' => $merchant->get_return_url(), |
||
| 79 | ) |
||
| 80 | ); |
||
| 81 | |||
| 82 | // Transaction. |
||
| 83 | $transaction = $this->transaction; |
||
| 84 | |||
| 85 | $element = self::add_element( $document, $document->documentElement, 'Transaction' ); |
||
| 86 | |||
| 87 | self::add_elements( |
||
| 88 | $document, |
||
| 89 | $element, |
||
| 90 | array( |
||
| 91 | 'purchaseID' => $transaction->get_purchase_id(), |
||
| 92 | 'amount' => IDeal::format_amount( $transaction->get_amount() ), |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 93 | 'currency' => $transaction->get_currency(), |
||
| 94 | 'expirationPeriod' => $transaction->get_expiration_period(), |
||
| 95 | 'language' => $transaction->get_language(), |
||
| 96 | 'description' => $transaction->get_description(), |
||
| 97 | 'entranceCode' => $transaction->get_entrance_code(), |
||
| 98 | ) |
||
| 99 | ); |
||
| 100 | |||
| 101 | // Return. |
||
| 102 | return $document; |
||
| 103 | } |
||
| 104 | } |
||
| 105 |