Index: third_party/WebKit/Source/modules/payments/PaymentResponse.cpp |
diff --git a/third_party/WebKit/Source/modules/payments/PaymentResponse.cpp b/third_party/WebKit/Source/modules/payments/PaymentResponse.cpp |
index bf3d7662f2e52a463842400554baf2365e5a8418..b2e9b574223c4016e602b3b5ced2536aad1e0936 100644 |
--- a/third_party/WebKit/Source/modules/payments/PaymentResponse.cpp |
+++ b/third_party/WebKit/Source/modules/payments/PaymentResponse.cpp |
@@ -4,7 +4,9 @@ |
#include "modules/payments/PaymentResponse.h" |
+#include "bindings/core/v8/ExceptionStatePlaceholder.h" |
#include "bindings/core/v8/JSONValuesForV8.h" |
+#include "bindings/core/v8/V8ObjectBuilder.h" |
#include "modules/payments/PaymentAddress.h" |
#include "modules/payments/PaymentCompleter.h" |
#include "wtf/Assertions.h" |
@@ -27,6 +29,35 @@ PaymentResponse::~PaymentResponse() |
{ |
} |
+ScriptValue PaymentResponse::toJSONForBinding(ScriptState* scriptState) const |
+{ |
+ V8ObjectBuilder result(scriptState); |
+ result.addString("methodName", methodName()); |
+ result.add("details", details(scriptState, ASSERT_NO_EXCEPTION)); |
+ |
+ if (shippingAddress()) |
+ result.add("shippingAddress", shippingAddress()->toJSONForBinding(scriptState)); |
+ else |
+ result.addNull("shippingAddress"); |
+ |
+ if (shippingOption().isNull()) |
+ result.addNull("shippingOption"); |
+ else |
+ result.addString("shippingOption", shippingOption()); |
+ |
+ if (payerEmail().isNull()) |
+ result.addNull("payerEmail"); |
+ else |
+ result.addString("payerEmail", payerEmail()); |
+ |
+ if (payerPhone().isNull()) |
+ result.addNull("payerPhone"); |
+ else |
+ result.addString("payerPhone", payerPhone()); |
+ |
+ return result.scriptValue(); |
+} |
+ |
ScriptValue PaymentResponse::details(ScriptState* scriptState, ExceptionState& exceptionState) const |
{ |
return ScriptValue(scriptState, fromJSONString(scriptState, m_stringifiedDetails, exceptionState)); |