/** * @test */ public function shouldAllowUpdatePayment() { $payment = new Payment(); $payment->setId(uniqid()); $payment->setTotalAmount(123); $payment->setClientEmail('*****@*****.**'); $storage = $this->app['payum']->getStorage($payment); $storage->update($payment); //guard $this->getClient()->putJson('/payments/' . $payment->getId(), ['totalAmount' => 123, 'currencyCode' => 'USD', 'clientEmail' => '*****@*****.**', 'clientId' => 'theClientId']); $this->assertClientResponseStatus(200); $this->assertClientResponseContentJson(); $content = $this->getClientResponseJsonContent(); $this->assertObjectHasAttribute('payment', $content); $this->assertObjectHasAttribute('clientEmail', $content->payment); $this->assertEquals('*****@*****.**', $content->payment->clientEmail); $this->assertObjectHasAttribute('totalAmount', $content->payment); $this->assertEquals(123, $content->payment->totalAmount); }
/** * @test */ public function shouldAllowUpdatePayment() { $payment = new Payment(); $payment->setTotalAmount(123); $payment->setClientEmail('*****@*****.**'); $payment->setAfterUrl('http://example.com'); $storage = $this->app['payum']->getStorage($payment); $storage->update($payment); $token = $this->app['payum.security.token_factory']->createToken('paypal_express_checkout', $payment, 'payment_get'); //guard $this->getClient()->putJson('/payments/' . $token->getHash(), ['totalAmount' => 123, 'currencyCode' => 'USD', 'clientEmail' => '*****@*****.**', 'clientId' => 'theClientId', 'gatewayName' => 'stripe_js', 'afterUrl' => 'http://example.com']); $this->assertClientResponseStatus(200); $this->assertClientResponseContentJson(); $content = $this->getClientResponseJsonContent(); $this->assertObjectHasAttribute('payment', $content); $this->assertObjectHasAttribute('clientEmail', $content->payment); $this->assertEquals('*****@*****.**', $content->payment->clientEmail); $this->assertObjectHasAttribute('totalAmount', $content->payment); $this->assertEquals(123, $content->payment->totalAmount); }
/** * @param Payment $payment * * @return array */ public function convert(Payment $payment) { $normalizedPayment = ['id' => $payment->getId(), 'status' => $payment->getStatus(), 'gatewayName' => $payment->getGatewayName(), 'number' => $payment->getNumber(), 'totalAmount' => $payment->getTotalAmount(), 'currencyCode' => $payment->getCurrencyCode(), 'clientEmail' => $payment->getClientEmail(), 'clientId' => $payment->getClientId(), 'description' => $payment->getDescription(), 'details' => $payment->getDetails(), '_links' => []]; foreach (['self', 'done', 'capture', 'authorize', 'notify'] as $name) { if ($link = $payment->getValue('links', $name)) { $normalizedPayment['_links'][$name] = ['href' => $link]; } } return $normalizedPayment; }
/** * @param Payment $payment * * @return array */ public function convert(Payment $payment) { $links = []; foreach ($payment->getLinks() as $name => $link) { $links[$name] = ['href' => $link]; } return ['id' => $payment->getPublicId(), 'gatewayName' => $payment->getGatewayName(), 'afterUrl' => $payment->getAfterUrl(), 'number' => $payment->getNumber(), 'totalAmount' => $payment->getTotalAmount(), 'currencyCode' => $payment->getCurrencyCode(), 'clientEmail' => $payment->getClientEmail(), 'clientId' => $payment->getClientId(), 'description' => $payment->getDescription(), 'details' => $payment->getDetails(), '_links' => $links]; }