Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
update payment method callback to be promise
Browse files Browse the repository at this point in the history
  • Loading branch information
nerrad committed Mar 20, 2020
1 parent dbf8e73 commit b37a7a9
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,11 @@ const CreditCardComponent = ( {
onChange={ onChange }
/>
);
useEffect( () => {}, [] );

const createSource = async ( stripeBilling ) => {
return await stripe.createSource( stripeBilling );
};
const onSubmit = () => {
const onSubmit = async () => {
const { billingData } = billing;
const stripeBilling = {
address: {
Expand All @@ -235,13 +234,15 @@ const CreditCardComponent = ( {
stripeBilling.name = `${ billingData.first_name } ${ billingData.last_name }`;
}

const response = createSource( stripeBilling );
const response = await createSource( stripeBilling );
if ( response.error ) {
// @todo set payment error
// return error object including any validation errors if present?
}
paymentStatus.setPaymentStatus().success( billingData, {
sourceId: response.source.id,
paymentMethod: PAYMENT_METHOD_NAME,
paymentRequestType: 'cc',
} );

// this should hook into checkout processing? Basically when the checkout
Expand Down

0 comments on commit b37a7a9

Please sign in to comment.