|
List Info
Thread: Generating a HMAC_SHA1 signature
|
|
| Generating a HMAC_SHA1 signature |
  United States |
2007-05-25 13:28:58 |
Please forgive me I have just started using google checkout.
I am
trying to integrate Google Checkout with API and I am having
some
difficulty getting the signature to generate using HMACSHA1
and return
it in Binary. This is the simple code I am using I was
wondering if
anyone could help. It is in ASP.NET/VB.
I keep getting the error "Bad Signature on Cart"
When I look at the xml Google received, it is my xml cart
exactly that
has been encoded in base 64, so I know the base 64 function
is good.
'****Convert the Byte array to Binary value
Private Function ByteArrayToBinary(ByVal byteArray As
Byte()) As
String
Dim result As String
result = ""
For Each b As Byte In byteArray
result &= Convert.ToString(b, 2)
Next
Return result
End Function
'****Encode the str to Base 64
Private Function Encode(ByVal str As String) As String
Dim encbuff =
System.Text.Encoding.UTF8.GetBytes(str)
Return Convert.ToBase64String(encbuff)
End Function
xmlFile = "Shopping cart in xml format"
Dim SHA = New
System.Security.Cryptography.HMACSHA1(Encoding.UTF8.GetBytes
("[sandbox
vendor key]"))
Dim hashByte =
SHA.ComputeHash(Encoding.UTF8.GetBytes(xmlFile))
Dim Signature = Encode(ByteArrayToBinary(hashByte))
Thank you.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "API Integration Basics" group.
To post to this group, send email to
google-checkout-api-integration googlegroups.com
To unsubscribe from this group, send email to
google-checkout-api-integration-unsubscribe googlegroups.com
For more options, visit this group at http://groups.google.com/group/google-checko
ut-api-integration?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: Generating a HMAC_SHA1 signature |
  United States |
2007-05-30 22:18:47 |
Hi Chuck,
Are you using the .NET sample code we provided? If not, you
can find
it here: http://code.google.com/p/google-checkout-dotnet-samp
le-code/
Thanks,
Jacob
On May 25, 11:28 am, Chuck <c... autotrucktoys.com>
wrote:
> Please forgive me I have just started using google
checkout. I am
> trying to integrate Google Checkout with API and I am
having some
> difficulty getting the signature to generate using
HMACSHA1 and return
> it in Binary. This is the simple code I am using I was
wondering if
> anyone could help. It is in ASP.NET/VB.
>
> I keep getting the error "Bad Signature on
Cart"
>
> When I look at the xml Google received, it is my xml
cart exactly that
> has been encoded in base 64, so I know the base 64
function is good.
>
> '****Convert the Byte array to Binary value
> Private Function ByteArrayToBinary(ByVal byteArray
As Byte()) As
> String
> Dim result As String
> result = ""
> For Each b As Byte In byteArray
> result &= Convert.ToString(b, 2)
> Next
> Return result
> End Function
>
> '****Encode the str to Base 64
> Private Function Encode(ByVal str As String) As
String
> Dim encbuff =
System.Text.Encoding.UTF8.GetBytes(str)
> Return Convert.ToBase64String(encbuff)
> End Function
>
> xmlFile = "Shopping cart in xml format"
>
> Dim SHA = New
>
System.Security.Cryptography.HMACSHA1(Encoding.UTF8.GetBytes
("[sandbox
> vendor key]"))
> Dim hashByte =
SHA.ComputeHash(Encoding.UTF8.GetBytes(xmlFile))
>
> Dim Signature = Encode(ByteArrayToBinary(hashByte))
>
> Thank you.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "API Integration Basics" group.
To post to this group, send email to
google-checkout-api-integration googlegroups.com
To unsubscribe from this group, send email to
google-checkout-api-integration-unsubscribe googlegroups.com
For more options, visit this group at http://groups.google.com/group/google-checko
ut-api-integration?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: Generating a HMAC_SHA1 signature |
  United States |
2007-05-30 22:20:35 |
The .NET sample code implements the alternate method of
posting carts
to Google Checkout, so no HMAC_SHA1 signature is generated.
If you've tried out our sample code, is there a particular
reason why
you aren't utilizing it?
Thanks,
Jacob
On May 30, 8:18 pm, GoogleCheckoutDevPro
<checkout-dev-... google.com>
wrote:
> Hi Chuck,
>
> Are you using the .NET sample code we provided? If not,
you can find
> it here:http://code.google.com/p/google-checkout-dotnet-samp
le-code/
>
> Thanks,
> Jacob
>
> On May 25, 11:28 am, Chuck <c... autotrucktoys.com> wrote:
>
> > Please forgive me I have just started using google
checkout. I am
> > trying to integrate Google Checkout with API and I
am having some
> > difficulty getting the signature to generate using
HMACSHA1 and return
> > it in Binary. This is the simple code I am using
I was wondering if
> > anyone could help. It is in ASP.NET/VB.
>
> > I keep getting the error "Bad Signature on
Cart"
>
> > When I look at the xml Google received, it is my
xml cart exactly that
> > has been encoded in base 64, so I know the base 64
function is good.
>
> > '****Convert the Byte array to Binary value
> > Private Function ByteArrayToBinary(ByVal
byteArray As Byte()) As
> > String
> > Dim result As String
> > result = ""
> > For Each b As Byte In byteArray
> > result &= Convert.ToString(b, 2)
> > Next
> > Return result
> > End Function
>
> > '****Encode the str to Base 64
> > Private Function Encode(ByVal str As String)
As String
> > Dim encbuff =
System.Text.Encoding.UTF8.GetBytes(str)
> > Return Convert.ToBase64String(encbuff)
> > End Function
>
> > xmlFile = "Shopping cart in xml format"
>
> > Dim SHA = New
> >
System.Security.Cryptography.HMACSHA1(Encoding.UTF8.GetBytes
("[sandbox
> > vendor key]"))
> > Dim hashByte =
SHA.ComputeHash(Encoding.UTF8.GetBytes(xmlFile))
>
> > Dim Signature =
Encode(ByteArrayToBinary(hashByte))
>
> > Thank you.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "API Integration Basics" group.
To post to this group, send email to
google-checkout-api-integration googlegroups.com
To unsubscribe from this group, send email to
google-checkout-api-integration-unsubscribe googlegroups.com
For more options, visit this group at http://groups.google.com/group/google-checko
ut-api-integration?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: Generating a HMAC_SHA1 signature |
  United States |
2007-05-31 14:05:27 |
I am not using the sample code because it is written in C
not VB and
we use VB here. I have looked at the code and ripped what I
can from
it. I have gotten the posting the cart working to Google,
now I am
having troubles with the merchant calculations.
I was under the assumption I would need to reply to Google,
when they
access my XML Service, in XML but it doesn't look that way.
It looks
like what I need to do is just return a string in the psuedo
XML
format you request. Is this a correct statement?
Also for everyone that is using VB.net in their ASP.NET and
they are
having problems posting their carts here is the code I used
that
works.
'******This creates the HMACSHA1 object and seeds it
with your
merchant key so it will gen the signature with your
specific
key*******'
Dim SHA = New
System.Security.Cryptography.HMACSHA1(Encoding.UTF8.GetBytes
("[Merchant
Key]"))
'******This takes the xmlFile string which is the
xml cart
Google requests and creates a signature based on it******'
Dim hashByte =
SHA.ComputeHash(Encoding.UTF8.GetBytes(xmlFile))
'******This base 64 encodes the signature you will
send to
Google in the signature form field******'
Dim base64Signature =
Convert.ToBase64String(hashByte)
'******This assigns the hidden form field
"signature" in the
html below the base64 encoded signature******'
signature.Value = base64Signature
'******This base64 encodes the xmlFile and assigns
it to the
hidden form field "cart" in the html below******'
cart.Value =
Convert.ToBase64String(Encoding.UTF8.GetBytes(xmlFile))
.
.
.
<!--These two form fields are what are submitted to
Google in the
google form using the google checkout button-->
<asp:HiddenField
ID="cart"
Value="Nothing"
runat="server"
/>
<asp:HiddenField
ID="signature"
value="Nothing"
runat="server"
/>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "API Integration Basics" group.
To post to this group, send email to
google-checkout-api-integration googlegroups.com
To unsubscribe from this group, send email to
google-checkout-api-integration-unsubscribe googlegroups.com
For more options, visit this group at http://groups.google.com/group/google-checko
ut-api-integration?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: Generating a HMAC_SHA1 signature |

|
2007-05-31 14:52:42 |
|
Hi i dont really understand what you are saying about merchant calculations but basically you will receive a merchant calculation callback (
http://code.google.com/apis/checkout/developer/index.html#tag_merchant-calculation-callback) and you will have to response a merchant calculation results (
http://code.google.com/apis/checkout/developer/index.html#tag_merchant-calculation-results) Let me know if this is not what you are asking.
Regards,
Ignacio.
On 5/31/07,
Chuck < chuck autotrucktoys.com">chuck autotrucktoys.com> wrote:
I am not using the sample code because it is written in C not VB and we use VB here. I have looked at the code and ripped what I can from it. I have gotten the posting the cart working to Google, now I am having troubles with the merchant calculations.
I was under the assumption I would need to reply to Google, when they access my XML Service, in XML but it doesn't look that way. It looks like what I need to do is just return a string in the psuedo XML
format you request. Is this a correct statement?
Also for everyone that is using VB.net in their ASP.NET and they are having problems posting their carts here is the code I used that
works.
39;******This creates the HMACSHA1 object and seeds it with your merchant key so it will gen the signature with your specific key*******39;
Dim SHA = New System.Security.Cryptography.HMACSHA1
(Encoding.UTF8.GetBytes("[Merchant Key]"))
'******This takes the xmlFile string which is the xml cart Google requests and creates a signature based on it******39; Dim hashByte =
SHA.ComputeHash(Encoding.UTF8.GetBytes(xmlFile))
'******This base 64 encodes the signature you will send to Google in the signature form field******' Dim base64Signature = Convert.ToBase64String
(hashByte)
9;******This assigns the hidden form field "signature" in the html below the base64 encoded signature******' signature.Value = base64Signature
'******This base64 encodes the xmlFile and assigns it to the
hidden form field "cart" in the html below******' cart.Value = Convert.ToBase64String(Encoding.UTF8.GetBytes(xmlFile))
. . .
<!--These two form fields are what are submitted to Google in the
google form using the google checkout button--> <asp:HiddenField ID="cart" Value="Nothing" runat="server" /> <asp:HiddenField
ID="signature" value="Nothing" runat="server" />
If i have an apple and you have an apple and we switch then we both have an apple. But if i have an idea and you have an idea and we switch then we both have two ideas.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "API Integration Basics" group. To post to this group, send email to google-checkout-api-integration googlegroups.com To unsubscribe from this group, send email to google-checkout-api-integration-unsubscribe googlegroups.com For more options, visit this group at http://groups.google.com/group/google-checkout-api-integration?hl=en -~----------~----~----~----~------~----~------~--~---
|
[1-5]
|
|
|
about | contact Other archives ( Real Estate discussion Medical topics )
|