Email is invalid

Solved
shepelroman
New Member
3 0 0

Hello guys,
We are developing a private app with the ability to purchase products through Shopify. In Shopify settings, we set Stripe as a payment system. All purchases will be done using Apple Pay. During the purchase process, I receive the error: "Email is invalid". Here is the place where I receive the error:

Request:

let mailingAddress = Storefront.MailingAddressInput.create(address1: Input(orNull: "109 Park Ave E"),
address2: Input(orNull: nil),
city: Input(orNull: "New York"),
company: Input(orNull: "Zerofynet"),
country: Input(orNull: "United States"),
firstName: Input(orNull: "Roman"),
lastName: Input(orNull: "Shepel"),
phone: Input(orNull: nil),
province: Input(orNull: "New York"),
zip: Input(orNull: "10170"))

let currencyCode = Storefront.CurrencyCode(rawValue: "USD")!
let paymentAmount = Storefront.MoneyInput(amount: checkout.paymentDue, currencyCode: currencyCode)
let paymentInput = Storefront.TokenizedPaymentInputV3.create(
paymentAmount: paymentAmount,
idempotencyKey: idempotencyToken,
billingAddress: mailingAddress,
paymentData: token,
type: Storefront.PaymentTokenType.applePay
)

let mutation = Storefront.buildMutation { $0
.checkoutCompleteWithTokenizedPaymentV3(checkoutId: GraphQL.ID(rawValue: checkout.id), payment: paymentInput) { $0
.checkoutUserErrors { $0
.field()
.message()
}
.payment { $0
.fragmentForPayment()
}
}
}

let task = self.client.mutateGraphWith(mutation) { response, error in
error.debugPrint()

if let payment = response?.checkoutCompleteWithTokenizedPaymentV3?.payment {
print("Payment created, fetching status...")
self.fetchCompletedPayment(payment.id.rawValue) { paymentResult in
result(paymentResult)
}
} else {
let alert = UIAlertController(title: nil, message: response?.debugDescription, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .cancel, handler: nil))
SceneDelegate.current.rootController?.present(alert, animated: true)
result(nil)
}
}

Request checkoutCompleteWithTokenizedPaymentV3 returns in response:

["checkoutCompleteWithTokenizedPaymentV3": {
checkoutUserErrors = (
{
field = "<null>";
message = "Email is invalid";
}
);
payment = "<null>";
}]>

I have checked the checkout object, and PayAddress contains my correct email. Please can you recommend how to fix this error?

Thanks,
Roman

0 Likes
shepelroman
New Member
3 0 0

Hi guys, can someone suggest? Still can't figure out with this error.

0 Likes
Kevin_A
Shopify Staff
Shopify Staff
213 27 40

This is an accepted solution.

Hey @shepelroman 

Using the checkoutCompleteWithTokenizedPaymentV3 mutation requires a special permission for your app to be able to write checkouts that is reserved for sales channels. I'm not sure if that addresses this specific error, but I don't believe you will be able to complete payment without it. 

Kevin_A | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog