C# and Google Checkout - getting the reply back from the server?

后端 未结 3 682
轮回少年
轮回少年 2021-01-02 01:11

Are there any tutorials out there on how to get the responses back from a Google Checkout transaction when using C# and the GCheckout API. All of the examples I could find w

3条回答
  •  情话喂你
    2021-01-02 01:51

    Without a HTTPS connection you'll only get a serial number POSTed to you. For safety, you should ensure that the authorisation is correct (there should be an Authorization header containing : encoded using base64 encoding)

    You then need to make a call via the Notification-History-API to request details of the update, loosely:

    IList ordersToGetUpdate = new List { serialNumber };
    
    NotificationHistoryRequest request = new NotificationHistoryRequest(ordersToGetUpdate);
    NotificationHistoryResponse resp = (NotificationHistoryResponse)request.Send();
    
    foreach (object notification in resp.NotificationResponses)
    {
        // You'd now need to handle the response, which could be one of NewOrderNotification, OrderStateChangeNotification, RiskInformationNotification, AuthorizationAmountNotification or a ChargeAmountNotification
        NewOrderNotification newOrder = notification as NewOrderNotification;
        if( newOrder != null )
        {
            // Yay! New order, so do "something" with it
        }
    
        OrderStateChangeNotification orderUpdate = notification as OrderStateChangeNotification;
        if (orderUpdate != null)
        {
             // Order updated (paid, shipped, etc), so do "something" with it
        }
    
        // you probably get the idea as to how to handle the other response types
    }
    

提交回复
热议问题