wp-pay-gateways /
multisafepay
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Pronamic\WordPress\Pay\Gateways\MultiSafepay\XML; |
||
| 4 | |||
| 5 | use Pronamic\WordPress\Pay\Core\XML\Util as XML_Util; |
||
| 6 | use Pronamic\WordPress\Pay\Gateways\MultiSafepay\Customer; |
||
| 7 | use Pronamic\WordPress\Pay\Gateways\MultiSafepay\GatewayInfo; |
||
| 8 | use Pronamic\WordPress\Pay\Gateways\MultiSafepay\Merchant; |
||
| 9 | use Pronamic\WordPress\Pay\Gateways\MultiSafepay\Transaction; |
||
| 10 | |||
| 11 | /** |
||
| 12 | * Title: MultiSafepay Connect XML direct transaction request message |
||
| 13 | * Description: |
||
| 14 | * Copyright: 2005-2019 Pronamic |
||
| 15 | * Company: Pronamic |
||
| 16 | * |
||
| 17 | * @author Remco Tolsma |
||
| 18 | * @version 2.0.2 |
||
| 19 | * @since 1.2.0 |
||
| 20 | */ |
||
| 21 | class DirectTransactionRequestMessage extends RequestMessage { |
||
| 22 | /** |
||
| 23 | * The document element name |
||
| 24 | * |
||
| 25 | * @var string |
||
| 26 | */ |
||
| 27 | const NAME = 'directtransaction'; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Gateway info. |
||
| 31 | * |
||
| 32 | * @var GatewayInfo |
||
| 33 | */ |
||
| 34 | private $gateway_info; |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Constructs and initialize an directory response message |
||
| 38 | * |
||
| 39 | * @param Merchant $merchant Merchant. |
||
| 40 | * @param Customer $customer Customer. |
||
| 41 | * @param Transaction $transaction Transaction. |
||
| 42 | * @param GatewayInfo $gateway_info Gateway info. |
||
| 43 | */ |
||
| 44 | public function __construct( Merchant $merchant, Customer $customer, Transaction $transaction, GatewayInfo $gateway_info = null ) { |
||
| 45 | parent::__construct( self::NAME ); |
||
| 46 | |||
| 47 | $this->merchant = $merchant; |
||
| 48 | $this->customer = $customer; |
||
| 49 | $this->transaction = $transaction; |
||
| 50 | $this->gateway_info = $gateway_info; |
||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Get document |
||
| 55 | * |
||
| 56 | * @see Pronamic_Gateways_IDealAdvancedV3_XML_RequestMessage::get_document() |
||
| 57 | */ |
||
| 58 | public function get_document() { |
||
| 59 | $document = parent::get_document(); |
||
| 60 | |||
| 61 | // Merchant. |
||
| 62 | $merchant = XML_Util::add_element( $document, $document->documentElement, 'merchant' ); |
||
| 63 | |||
| 64 | XML_Util::add_elements( |
||
| 65 | $document, |
||
| 66 | $merchant, |
||
| 67 | array( |
||
| 68 | 'account' => $this->merchant->account, |
||
| 69 | 'site_id' => $this->merchant->site_id, |
||
| 70 | 'site_secure_code' => $this->merchant->site_secure_code, |
||
| 71 | 'notification_url' => $this->merchant->notification_url, |
||
| 72 | 'redirect_url' => $this->merchant->redirect_url, |
||
| 73 | 'cancel_url' => $this->merchant->cancel_url, |
||
| 74 | 'close_window' => $this->merchant->close_window, |
||
| 75 | ) |
||
| 76 | ); |
||
| 77 | |||
| 78 | // Customer. |
||
| 79 | $customer = XML_Util::add_element( $document, $document->documentElement, 'customer' ); |
||
| 80 | |||
| 81 | XML_Util::add_elements( |
||
| 82 | $document, |
||
| 83 | $customer, |
||
| 84 | array( |
||
| 85 | 'locale' => $this->customer->locale, |
||
| 86 | 'ipaddress' => $this->customer->ip_address, |
||
| 87 | 'forwardedip' => $this->customer->forwarded_ip, |
||
| 88 | 'firstname' => $this->customer->first_name, |
||
| 89 | 'lastname' => $this->customer->last_name, |
||
| 90 | 'address1' => $this->customer->address_1, |
||
| 91 | 'address2' => $this->customer->address_2, |
||
| 92 | 'housenumber' => $this->customer->house_number, |
||
| 93 | 'zipcode' => $this->customer->zip_code, |
||
| 94 | 'city' => $this->customer->city, |
||
| 95 | 'country' => $this->customer->country, |
||
| 96 | 'phone' => $this->customer->phone, |
||
| 97 | 'email' => $this->customer->email, |
||
| 98 | ) |
||
| 99 | ); |
||
| 100 | |||
| 101 | // Transaction. |
||
| 102 | $transaction = XML_Util::add_element( $document, $document->documentElement, 'transaction' ); |
||
| 103 | |||
| 104 | XML_Util::add_elements( |
||
| 105 | $document, |
||
| 106 | $transaction, |
||
| 107 | array( |
||
| 108 | 'id' => $this->transaction->id, |
||
| 109 | 'currency' => $this->transaction->currency, |
||
| 110 | 'amount' => $this->transaction->amount, |
||
| 111 | 'description' => $this->transaction->description, |
||
| 112 | 'var1' => $this->transaction->var1, |
||
| 113 | 'var2' => $this->transaction->var2, |
||
| 114 | 'var3' => $this->transaction->var3, |
||
| 115 | 'items' => $this->transaction->items, |
||
| 116 | 'manual' => $this->transaction->manual, |
||
| 117 | 'gateway' => $this->transaction->gateway, |
||
| 118 | 'daysactive' => $this->transaction->days_active, |
||
| 119 | ) |
||
| 120 | ); |
||
| 121 | |||
| 122 | // Gateway info. |
||
| 123 | if ( $this->gateway_info ) { |
||
| 124 | $gateway_info = XML_Util::add_element( $document, $document->documentElement, 'gatewayinfo' ); |
||
| 125 | |||
| 126 | XML_Util::add_elements( |
||
| 127 | $document, |
||
| 128 | $gateway_info, |
||
| 129 | array( |
||
| 130 | 'issuerid' => $this->gateway_info->issuer_id, |
||
| 131 | ) |
||
| 132 | ); |
||
| 133 | } |
||
| 134 | |||
| 135 | // Signature. |
||
| 136 | XML_Util::add_element( $document, $document->documentElement, 'signature', $this->signature ); |
||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 137 | |||
| 138 | return $document; |
||
| 139 | } |
||
| 140 | } |
||
| 141 |