private void CheckoutWithTokenizedPaymentV2(TokenizedPaymentInputV2 tokenizedPaymentInputV2, Checkout checkout, ApplePayEventHandlerCompletion callback) { CartState.CheckoutWithTokenizedPaymentV2(tokenizedPaymentInputV2, (ShopifyError error) => { if (error == null) { callback(null); } else { ApplePayEventResponse response = new ApplePayEventResponse(ApplePayAuthorizationStatus.Failure); // Check to see if this is a recoverable user error if (error.Type == ShopifyError.ErrorType.UserError) { var userErrors = CartState.UserErrors; var status = GetUpdateRequestStatusFromCheckoutUserErrors(userErrors); if (status.AuthorizationStatus != ApplePayAuthorizationStatus.Failure) { var summaryItems = GetSummaryItemsFromCheckout(CartState.CurrentCheckout); response = new ApplePayEventResponse(status.AuthorizationStatus, summaryItems, GetShippingMethods(), status.Errors); } } callback(response); } }); }
public void TestCheckoutCompleteWithTokenizedPaymentV2() { MutationQuery query = new MutationQuery(); string checkoutId = "an-id"; var billingAddress = new MailingAddressInput("123 Test Street", "456", "Toronto", "Shopify", "Canada", "First", "Last", "1234567890", "Ontario", "A1B2C3"); var paymentAmount = new MoneyInput(new decimal(1), CurrencyCode.CAD); var tokenizedPaymentInputV2 = new TokenizedPaymentInputV2( paymentAmount: paymentAmount, idempotencyKey: "unique_id", billingAddress: billingAddress, paymentData: "some_utf8_data_string", type: "apple_pay" ); DefaultQueries.checkout.CheckoutCompleteWithTokenizedPaymentV2(query, checkoutId, tokenizedPaymentInputV2); Assert.AreEqual( "mutation{checkoutCompleteWithTokenizedPaymentV2 (checkoutId:\"an-id\",payment:{paymentAmount:{amount:1,currencyCode:CAD},idempotencyKey:\"unique_id\",billingAddress:{address1:\"123 Test Street\",address2:\"456\",city:\"Toronto\",company:\"Shopify\",country:\"Canada\",firstName:\"First\",lastName:\"Last\",phone:\"1234567890\",province:\"Ontario\",zip:\"A1B2C3\"},type:\"apple_pay\",paymentData:\"some_utf8_data_string\"}){checkout {id webUrl currencyCode requiresShipping subtotalPrice totalTax totalPrice ready }payment {checkout {id webUrl currencyCode requiresShipping subtotalPrice totalTax totalPrice ready completedAt }errorMessage id ready }userErrors {field message }}}", query.ToString() ); }
public void FetchApplePayCheckoutStatusForToken(string serializedMessage) { var checkout = CartState.CurrentCheckout; var message = NativeMessage.CreateFromJSON(serializedMessage); var paymentAmount = new MoneyInput(checkout.totalPriceV2().amount(), checkout.currencyCode()); var payment = new NativePayment(message.Content); var tokenizedPaymentInputV2 = new TokenizedPaymentInputV2( paymentAmount: paymentAmount, billingAddress: payment.BillingAddress, idempotencyKey: payment.TransactionIdentifier, paymentData: payment.PaymentData, type: "apple_pay" ); Action performCheckout = () => { CheckoutWithTokenizedPaymentV2(tokenizedPaymentInputV2, checkout, (ApplePayEventResponse errorResponse) => { if (errorResponse == null) { message.Respond((new ApplePayEventResponse(ApplePayAuthorizationStatus.Success)).ToJsonString()); } else { message.Respond(errorResponse.ToJsonString()); } }); }; SetFinalCheckoutFieldsForPayment(payment, checkout, (ApplePayEventResponse errorResponse) => { if (errorResponse == null) { performCheckout(); } else { message.Respond(errorResponse.ToJsonString()); } }); }
/// <summary> /// Completes a checkout with a tokenized payment. /// </summary> /// <param name="checkoutId"> /// The ID of the checkout. /// </param> /// <param name="payment"> /// The info to apply as a tokenized payment. /// </param> public MutationQuery checkoutCompleteWithTokenizedPaymentV2(CheckoutCompleteWithTokenizedPaymentV2payloadDelegate buildQuery, string checkoutId, TokenizedPaymentInputV2 payment, string alias = null) { if (alias != null) { ValidationUtils.ValidateAlias(alias); Query.Append("checkoutCompleteWithTokenizedPaymentV2___"); Query.Append(alias); Query.Append(":"); } Query.Append("checkoutCompleteWithTokenizedPaymentV2 "); Arguments args = new Arguments(); args.Add("checkoutId", checkoutId); args.Add("payment", payment); Query.Append(args.ToString()); Query.Append("{"); buildQuery(new CheckoutCompleteWithTokenizedPaymentV2payloadQuery(Query)); Query.Append("}"); return(this); }
public void CheckoutCompleteWithTokenizedPaymentV2(MutationQuery query, string checkoutId, TokenizedPaymentInputV2 tokenizedPaymentInputV2) { query.checkoutCompleteWithTokenizedPaymentV2( buildQuery: checkoutCompleteWithTokenizedPaymentV2 => checkoutCompleteWithTokenizedPaymentV2 .checkout(checkout => Checkout(checkout)) .payment(payment => Payment(payment)) .userErrors(userErrors => userErrors .field() .message() ), checkoutId: checkoutId, payment: tokenizedPaymentInputV2 ); }