public function testTransaction() { $return = <<<XML <?xml version="1.0" encoding="UTF-8"?> <MerchantTransactions> <MerchantTransactions> <TransactionId>449087232</TransactionId> <ConsumerKey>cLb0tKkEJhGTITp_6ltDIibO5Wgbx4rIldeXM_jRd4b0476c!414f4859446c4a366c726a327474695545332b353049303d</ConsumerKey> <Currency>USD</Currency> <OrderAmount>100</OrderAmount> <PurchaseDate>2016-07-27T05:31:45+02:00</PurchaseDate> <TransactionStatus>Success</TransactionStatus> <ApprovalCode>sample</ApprovalCode> </MerchantTransactions> </MerchantTransactions> XML; $purchase = new \DateTime(); $transaction = new Transaction(); $transaction->transactionId = 449087232; $transaction->consumerKey = 'cLb0tKkEJhGTITp_6ltDIibO5Wgbx4rIldeXM_jRd4b0476c!414f4859446c4a366c726a327474695545332b353049303d'; $transaction->currency = 'USD'; $transaction->setAmount(1.0); $transaction->transactionStatus = 'Success'; $transaction->setPurchaseDate($purchase); $transaction->approvalCode = 'sample'; $connector = $this->getMockConnector($return, self::TRANSACTION); $service = new MasterpassService($connector); $response = $service->postTransaction($transaction); $this->assertRegExp('<TransactionId>', $response, 'Response does not contain TransactionId'); }
/** * This method submits the receipt transaction list to MasterCard as a final step * in the Wallet process. * * @param Transaction $transaction * * @return string The XML response from MasterCard services */ public function postTransaction(Transaction $transaction) { $xmlTransaction = $transaction->toXML(); $params = array(Connector::OAUTH_BODY_HASH => $this->connector->generateBodyHash($xmlTransaction)); return $this->connector->doTransaction($params, $xmlTransaction); }