You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using latest MobileBuy but seems I'm not able to create an order on shopify after I successfully do a purchase order on Apple Pay. My goal is to create an order on shopify so the user that already paid using Apple Pay can have the order created on Shopify but seems this is not working and there is no other way to do this AFAIk. Please explain if this is ok and why it's not working. Thanks in advice. I'm dealing with this since at least 2 weeks.
/// APPLE PAY
func completeCheckoutWithApplePay(checkout:CheckoutViewModel,
billingAddress:PKContact,
token:String,
idempotencyToken:String,
data:String,
header:Storefront.ApplePayWalletHeaderInput,
signature:String,
version:String,
last4Digits:String,
completion:@escaping(CheckoutAppleResult)->Void){letmutation=ClientQuery.mutationForCompleteCheckoutUsingApplePay(checkout: checkout, billingAddress: billingAddress,
token: token,
idempotencyToken: idempotencyToken,
data: data,
header: header,
signature: signature,
version: version,
last4Digits: last4Digits)lettask=self.client.mutateGraphWith(mutation){ response, error iniflet errors = response?.cartPaymentUpdate?.userErrors {foruserErrorin errors {print("Field: \(userError.field), Message: \(userError.message)")}}iflet error = error {print("GraphQL Error: \(error.localizedDescription)")completion(.failure("GraphQL error: \(error.localizedDescription)"))return}iflet cart = response?.cartPaymentUpdate?.cart {print("Cart updated successfully, fetching order details...\(cart)")self.fetchCompletedPayment(cart.id.rawValue){ order iniflet order = order {print("Order ID: \(order.id)")completion(.success(order))}elseiflet userErrors = response?.cartPaymentUpdate?.userErrors, !userErrors.isEmpty {leterrorMessage= userErrors.map{ $0.message }.joined(separator:", ")print("User Errors from cartPaymentUpdate: \(errorMessage)")
//completion(.failure("cartPaymentUpdate error: \(errorMessage)"))
leterrorMessage2= userErrors.first?.message ??"Unknown error"print("cartPaymentUpdate error: \(errorMessage2)")completion(.failure(errorMessage2))}else{completion(.failure("Failed to fetch order ID"))}}}else{print("Error completing cartPaymentUpdate")completion(.failure("Failed to complete cartPaymentUpdate"))}}
task.resume()}
//// CLIENT
staticfunc mutationForCompleteCheckoutUsingApplePay(
checkout:CheckoutViewModel,
billingAddress:PKContact,
token:String,
idempotencyToken:String,
data:String,
header:Storefront.ApplePayWalletHeaderInput,
signature:String,
version:String,
last4Digits:String)->Storefront.MutationQuery{letpostalAddress= billingAddress.postalAddress
letmailingAddress=Storefront.MailingAddressInput.create(
address1:Input.value(postalAddress?.street), // Calle
address2:Input.value(""), // Puedes mapear cualquier campo adicional aquí si es necesario
city:Input.value(postalAddress?.city), // Ciudad
country:Input.value(postalAddress?.isoCountryCode), // Código ISO del país
firstName:Input.value(billingAddress.name?.givenName ??""), // Primer nombre
lastName:Input.value(billingAddress.name?.familyName ??""), // Apellido
province:Input.value(postalAddress?.state), // Provincia o Estado
zip:Input.value(postalAddress?.postalCode) // Código postal
)letcurrencyCode=Storefront.CurrencyCode(rawValue: checkout.currencyCode)!
letpaymentAmount=Storefront.MoneyInput(amount: checkout.paymentDue, currencyCode: currencyCode)letapplePayContent=Storefront.ApplePayWalletContentInput.create(
billingAddress: mailingAddress,
data: data,
header: header,
signature: signature,
version: version,
lastDigits:Input.value(last4Digits))letpaymentInput=Storefront.CartPaymentInput.create(
amount: paymentAmount,
walletPaymentMethod:.value(Storefront.CartWalletPaymentMethodInput.create(
applePayWalletContent:.value(applePayContent))))letmutation=Storefront.buildMutation{ $0
.cartPaymentUpdate(cartId:GraphQL.ID(rawValue: checkout.id), payment: paymentInput){ $0
.userErrors{ $0
.field().message()}.cart{ $0
.id()}}}return mutation
}
But I'm getting every time the same error
GraphQL Error: No se ha podido completar la operación. (Error de Buy.Graph.QueryError 4.)
Failed paymentAuthorizationViewController: GraphQL error: No se ha podido completar la operación. (Error de Buy.Graph.QueryError 4.)
The text was updated successfully, but these errors were encountered:
I'm using latest MobileBuy but seems I'm not able to create an order on shopify after I successfully do a purchase order on Apple Pay. My goal is to create an order on shopify so the user that already paid using Apple Pay can have the order created on Shopify but seems this is not working and there is no other way to do this AFAIk. Please explain if this is ok and why it's not working. Thanks in advice. I'm dealing with this since at least 2 weeks.
But I'm getting every time the same error
GraphQL Error: No se ha podido completar la operación. (Error de Buy.Graph.QueryError 4.)
Failed paymentAuthorizationViewController: GraphQL error: No se ha podido completar la operación. (Error de Buy.Graph.QueryError 4.)
The text was updated successfully, but these errors were encountered: