public void Should_Parse_A_Rest_Finished_Response() { string result = "{" + " \"requestId\":360," + " \"status\":" + " {" + " \"status\":\"APPROVED\"," + " \"reason\":\"00\"," + " \"message\":\"La petici\\u00f3n ha sido aprobada exitosamente\"," + " \"date\":\"2017-05-17T14:53:54-05:00\"" + " }," + " \"request\":" + " {" + " \"locale\":\"es_CO\"," + " \"payer\":" + " {" + " \"document\":\"1040035000\"," + " \"documentType\":\"CC\"," + " \"name\":\"Leilani\"," + " \"surname\":\"Zulauf\"," + " \"email\":\"[email protected]\"," + " \"mobile\":\"3006108300\"" + " }," + " \"buyer\":" + " {" + " \"document\":\"1040035000\"," + " \"documentType\":\"CC\"," + " \"name\":\"Leilani\"," + " \"surname\":\"Zulauf\"," + " \"email\":\"[email protected]\"," + " \"mobile\":\"3006108300\"" + " }," + " \"payment\":" + " {" + " \"reference\":\"TEST_20200516_154231\"," + " \"description\":\"Et et dolorem tenetur et cum.\"," + " \"amount\":" + " {" + " \"currency\":\"USD\"," + " \"total\":\"0.3\"" + " }," + " \"allowPartial\":false" + " }," + " \"subscription\":null," + " \"fields\":null," + " \"returnUrl\":\"http:\\/\\/redirect.p2p.dev\\/client\"," + " \"paymentMethod\":null," + " \"cancelUrl\":null," + " \"ipAddress\":\"127.0.0.1\"," + " \"userAgent\":\"Mozilla\\/5.0 (X11; Linux x86_64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/57.0.2987.98 Safari\\/537.36\"," + " \"expiration\":\"2017-05-17T15:42:31+00:00\"," + " \"captureAddress\":false," + " \"skipResult\":false," + " \"noBuyerFill\":false" + " }," + " \"payment\":" + " [" + " {" + " \"status\":" + " {" + " \"status\":\"APPROVED\"," + " \"reason\":\"00\"," + " \"message\":\"Aprobada\"," + " \"date\":\"2017-05-16T10:43:39-05:00\"" + " }," + " \"internalReference\":1447466623," + " \"paymentMethod\":\"paypal\"," + " \"paymentMethodName\":\"PayPal\"," + " \"amount\":" + " {" + " \"from\":" + " {" + " \"currency\":\"USD\"," + " \"total\":0.3" + " }," + " \"to\":" + " {" + " \"currency\":\"USD\"," + " \"total\":0.3" + " }," + " \"factor\":1" + " }," + " \"authorization\":\"2DG26929XX8381738\"," + " \"reference\":\"TEST_20200516_154231\"," + " \"receipt\":\"1447466623\"," + " \"franchise\":\"PYPAL\"," + " \"refunded\":false," + " \"processorFields\":" + " [" + " {" + " \"keyword\":\"trazabilyCode\"," + " \"value\":\"PAY-9BU08130ME378305MLENR4CI\"," + " \"displayOn\":\"none\"" + " }" + " ]" + " }" + " ]," + " \"subscription\":null" + "}"; var information = new RedirectInformation(result); Assert.AreEqual(360, information.RequestId); Assert.AreEqual(Status.ST_APPROVED, information.Status.StatusText); Assert.True(information.IsSuccessful()); Assert.True(information.IsApproved()); Assert.AreEqual("TEST_20200516_154231", information.Request.Payment.Reference); Assert.AreEqual("Leilani", information.Request.Payer.Name); Assert.AreEqual("Zulauf", information.Request.Payer.Surname); Assert.AreEqual("*****@*****.**", information.Request.Payer.Email); Assert.AreEqual("USD", information.Request.Payment.Amount.Currency); Assert.AreEqual("0.3", information.Request.Payment.Amount.Total.ToString("G", CultureInfo.InvariantCulture)); Assert.AreEqual("2DG26929XX8381738", information.LastAuthorization()); Assert.AreEqual("1447466623", information.LastTransaction().Receipt.ToString()); Assert.AreEqual("PYPAL", information.LastTransaction().Franchise); Assert.AreEqual(new JObject { { "trazabilyCode", "PAY-9BU08130ME378305MLENR4CI" } }, information.LastTransaction().AdditionalData()); Assert.That(information.ToJsonObject().ContainsKey("requestId")); }
public void Should_Parse_A_Rest_Created_Response() { string result = "{" + " \"requestId\":368," + " \"status\":" + " {" + " \"status\":\"PENDING\"," + " \"reason\":\"PC\"," + " \"message\":\"La petici\\u00f3n se encuentra activa\"," + " \"date\":\"2017-05-17T14:44:05-05:00\"" + " }," + " \"request\":" + " {" + " \"locale\":\"es_CO\"," + " \"payer\":null," + " \"buyer\":" + " {" + " \"document\":\"1040035000\"," + " \"documentType\":\"CC\"," + " \"name\":\"Jakob\"," + " \"surname\":\"Macejkovic\"," + " \"email\":\"[email protected]\"," + " \"mobile\":\"3006108300\"" + " }," + " \"payment\":" + " {" + " \"reference\":\"TEST_20200517_144129\"," + " \"description\":\"Quisquam architecto optio rem in non expedita.\"," + " \"amount\":" + " {" + " \"taxes\":" + " [" + " {" + " \"kind\":\"valueAddedTax\"," + " \"amount\":20," + " \"base\":140" + " }" + " ]," + " \"currency\":\"USD\"," + " \"total\":\"199.8\"" + " }," + " \"allowPartial\":false" + " }," + " \"subscription\":null," + " \"fields\":null," + " \"returnUrl\":\"http:\\/\\/local.dev\\/redirect\\/client\"," + " \"paymentMethod\":null," + " \"cancelUrl\":null," + " \"ipAddress\":\"192.168.33.20\"," + " \"userAgent\":\"Mozilla\\/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit\\/537.36 (KHTML, like Gecko) Chrome\\/58.0.3029.96 Safari\\/537.36\"," + " \"expiration\":\"2017-05-18T14:41:29+00:00\"," + " \"captureAddress\":false," + " \"skipResult\":false," + " \"noBuyerFill\":false" + " }," + " \"payment\":null," + " \"subscription\":null" + "}"; var information = new RedirectInformation(result); Assert.AreEqual(368, information.RequestId); Assert.AreEqual(Status.ST_PENDING, information.Status.StatusText); Assert.True(information.IsSuccessful()); Assert.False(information.IsApproved()); Assert.AreEqual("TEST_20200517_144129", information.Request.Payment.Reference); Assert.AreEqual("1040035000", information.Request.Buyer.Document); Assert.Null(information.LastApprovedTransaction()); Assert.Null(information.LastAuthorization()); Assert.Null(information.LastTransaction()); Assert.That(information.ToJsonObject().ContainsKey("requestId")); }